feat: add panel mode and allow shifting of dock
This commit is contained in:
1 parent
91c5a88509
commit
6ffd3ceb99
9 files changed
+148
-14
No files matched your search
@@ -0,0 +1,21 @@
|
||||
<script lang="ts">
|
||||
import { goto } from '$app/navigation'
|
||||
import { TextInput } from 'mono-svelte'
|
||||
|
||||
let query: string = ''
|
||||
let loading = false
|
||||
|
||||
function search() {
|
||||
loading = true
|
||||
goto(`/search?q=${query}`).then(() => (loading = false))
|
||||
}
|
||||
</script>
|
||||
|
||||
<form on:submit|preventDefault={search} class="w-full h-full {$$props.class}">
|
||||
<TextInput
|
||||
bind:value={query}
|
||||
class="w-full h-full {$$props.class}"
|
||||
placeholder="Search"
|
||||
/>
|
||||
</form>
|
||||
<slot {search} {loading} />
|
||||
@@ -1,6 +1,6 @@
|
||||
<aside
|
||||
class="sticky top-16 left-0 break-words flex flex-shrink
|
||||
flex-col gap-4 p-6 max-w-full w-full h-full
|
||||
class="sticky top-0 left-0 break-words flex flex-shrink
|
||||
flex-col gap-4 px-6 pt-4 max-w-full w-full h-full
|
||||
overflow-auto text-sm border-slate-200 dark:border-zinc-800 {$$props.class}"
|
||||
>
|
||||
<slot />
|
||||
|
||||
@@ -6,6 +6,35 @@
|
||||
export let route: { id: string | null } | undefined = undefined
|
||||
|
||||
$: title = route ? routes[(route.id as keyof typeof routes) ?? ''] : ''
|
||||
|
||||
const calculatePadding = (
|
||||
panel: boolean,
|
||||
top: boolean,
|
||||
content: boolean
|
||||
): string => {
|
||||
if (panel) {
|
||||
if (top) return '!pt-22'
|
||||
else return '!pb-22'
|
||||
} else {
|
||||
if (!content) return ''
|
||||
|
||||
if (top) return '!pt-24'
|
||||
else return '!pb-24'
|
||||
}
|
||||
|
||||
return 'hi this is easter egg, my code broke'
|
||||
}
|
||||
|
||||
$: contentPadding = calculatePadding(
|
||||
$userSettings.dock.noGap,
|
||||
$userSettings.dock.top,
|
||||
true
|
||||
)
|
||||
$: sidePadding = calculatePadding(
|
||||
$userSettings.dock.noGap,
|
||||
$userSettings.dock.top,
|
||||
false
|
||||
)
|
||||
</script>
|
||||
|
||||
<div class="shell {$$props.class}" style={colorsToVars($colors)}>
|
||||
@@ -17,28 +46,41 @@
|
||||
>
|
||||
<slot
|
||||
name="sidebar"
|
||||
class="hidden md:flex sticky top-0 left-0 w-full max-w-full bg-slate-50 dark:bg-zinc-950"
|
||||
class="hidden md:flex sticky top-0 left-0 w-full max-w-full bg-slate-50 dark:bg-zinc-950
|
||||
{sidePadding}"
|
||||
style="grid-area: sidebar; width: 100% !important;"
|
||||
/>
|
||||
<slot
|
||||
name="main"
|
||||
class="w-full bg-slate-25 dark:bg-zinc-925 justify-self-center shadow-sm !pb-24"
|
||||
class="w-full bg-slate-25 dark:bg-zinc-925 justify-self-center shadow-sm
|
||||
{contentPadding}"
|
||||
style="grid-area: main"
|
||||
/>
|
||||
<slot
|
||||
name="suffix"
|
||||
class="max-xl:hidden w-full sticky top-0 left-0 h-max bg-slate-50 dark:bg-zinc-950"
|
||||
class="max-xl:hidden w-full sticky top-0 left-0 h-max bg-slate-50 dark:bg-zinc-950
|
||||
{sidePadding}"
|
||||
style="grid-area: suffix;"
|
||||
/>
|
||||
</div>
|
||||
<div
|
||||
class="p-4 w-full fixed bottom-0 z-50 max-w-3xl left-1/2 -translate-x-1/2"
|
||||
class="
|
||||
{$userSettings.dock.noGap ? '' : 'p-4 max-w-3xl left-1/2 -translate-x-1/2'}
|
||||
{$userSettings.dock.top ? 'top-0' : 'bottom-0'}
|
||||
w-full fixed z-50 pointer-events-none"
|
||||
style="grid-area: navbar;"
|
||||
>
|
||||
<slot
|
||||
name="navbar"
|
||||
class="border rounded-full border-slate-200 dark:border-zinc-800 shadow-2xl
|
||||
backdrop-blur-xl dark:backdrop-brightness-[25%] bg-[#ffffff]/75 dark:bg-transparent transition-colors duration-500"
|
||||
class="
|
||||
{$userSettings.dock.noGap
|
||||
? $userSettings.dock.top
|
||||
? 'border-b'
|
||||
: 'border-t'
|
||||
: 'border rounded-full'}
|
||||
border-slate-200 dark:border-zinc-800 shadow-2xl
|
||||
backdrop-blur-xl dark:backdrop-brightness-[25%] bg-[#ffffff]/75 dark:bg-transparent transition-colors duration-500
|
||||
pointer-events-auto"
|
||||
style="grid-area: navbar"
|
||||
{title}
|
||||
/>
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
<Button
|
||||
color="tertiary"
|
||||
{...$$restProps}
|
||||
on:click
|
||||
class="rounded-full w-10 h-10 flex-shrink-0 {isSelected
|
||||
? 'bg-slate-200 dark:bg-zinc-900 text-primary-900 dark:!text-primary-100'
|
||||
: ''} {$$props.class ?? ''}"
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
} from '$lib/components/lemmy/moderation/moderation.js'
|
||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||
import { site } from '$lib/lemmy.js'
|
||||
import { Menu, MenuButton, MenuDivider, Spinner } from 'mono-svelte'
|
||||
import { Button, Menu, MenuButton, MenuDivider, Spinner } from 'mono-svelte'
|
||||
import {
|
||||
GlobeAlt,
|
||||
Home,
|
||||
@@ -18,21 +18,57 @@
|
||||
PencilSquare,
|
||||
Plus,
|
||||
ServerStack,
|
||||
XMark,
|
||||
} from 'svelte-hero-icons'
|
||||
import Profile from './Profile.svelte'
|
||||
import NavButton from './NavButton.svelte'
|
||||
import { scale } from 'svelte/transition'
|
||||
import { expoOut, backOut } from 'svelte/easing'
|
||||
import { flip } from 'svelte/animate'
|
||||
import SearchBar from '$lib/components/lemmy/util/SearchBar.svelte'
|
||||
|
||||
let searching = false
|
||||
</script>
|
||||
|
||||
<nav
|
||||
class="flex flex-row gap-2 items-center w-full mx-auto z-50 box-border h-16
|
||||
p-1 duration-150
|
||||
duration-150
|
||||
{$$props.class}
|
||||
"
|
||||
style={$$props.style}
|
||||
>
|
||||
{#if searching}
|
||||
<div
|
||||
class="w-full h-full absolute z-20 p-2 flex items-center gap-2 backdrop-brightness-0 rounded-full"
|
||||
transition:scale={{
|
||||
start: 0.96,
|
||||
duration: 250,
|
||||
easing: backOut,
|
||||
}}
|
||||
>
|
||||
<Button
|
||||
size="custom"
|
||||
rounding="pill"
|
||||
class="w-11 h-11 flex-shrink-0"
|
||||
on:click={() => (searching = false)}
|
||||
>
|
||||
<Icon src={XMark} size="18" mini />
|
||||
</Button>
|
||||
<SearchBar let:search let:loading class="!rounded-full z-20">
|
||||
<Button
|
||||
size="custom"
|
||||
rounding="pill"
|
||||
class="w-11 h-11 flex-shrink-0"
|
||||
on:click={search}
|
||||
color="primary"
|
||||
type="submit"
|
||||
{loading}
|
||||
>
|
||||
<Icon src={MagnifyingGlass} size="18" mini slot="prefix" />
|
||||
</Button>
|
||||
</SearchBar>
|
||||
</div>
|
||||
{/if}
|
||||
<div class="flex flex-row gap-2 py-2 px-2 items-center w-full">
|
||||
<Profile
|
||||
placement="top"
|
||||
@@ -134,7 +170,11 @@
|
||||
{/if}
|
||||
</NavButton>
|
||||
{/if}
|
||||
<NavButton href="/search" label="Search" icon={MagnifyingGlass} />
|
||||
<NavButton
|
||||
on:click={() => (searching = true)}
|
||||
label="Search"
|
||||
icon={MagnifyingGlass}
|
||||
/>
|
||||
<NavButton href="/" label="Home" icon={Home} />
|
||||
<Menu placement="top">
|
||||
<NavButton
|
||||
|
||||
@@ -81,6 +81,10 @@ interface Settings {
|
||||
clickToView: boolean
|
||||
youtube: 'youtube' | 'invidious' | 'piped'
|
||||
}
|
||||
dock: {
|
||||
noGap: boolean
|
||||
top: boolean
|
||||
}
|
||||
}
|
||||
|
||||
export const defaultSettings: Settings = {
|
||||
@@ -135,6 +139,10 @@ export const defaultSettings: Settings = {
|
||||
embeds: {
|
||||
clickToView: true,
|
||||
youtube: 'youtube',
|
||||
},
|
||||
dock: {
|
||||
noGap: false,
|
||||
top: false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user