feat: add panel mode and allow shifting of dock

This commit is contained in:
Xylight committed 2024-04-17 17:47:05 -07:00
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} />
+2 -2
View File
@@ -1,6 +1,6 @@
<aside <aside
class="sticky top-16 left-0 break-words flex flex-shrink class="sticky top-0 left-0 break-words flex flex-shrink
flex-col gap-4 p-6 max-w-full w-full h-full 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}" overflow-auto text-sm border-slate-200 dark:border-zinc-800 {$$props.class}"
> >
<slot /> <slot />
+48 -6
View File
@@ -6,6 +6,35 @@
export let route: { id: string | null } | undefined = undefined export let route: { id: string | null } | undefined = undefined
$: title = route ? routes[(route.id as keyof typeof routes) ?? ''] : '' $: 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> </script>
<div class="shell {$$props.class}" style={colorsToVars($colors)}> <div class="shell {$$props.class}" style={colorsToVars($colors)}>
@@ -17,28 +46,41 @@
> >
<slot <slot
name="sidebar" 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;" style="grid-area: sidebar; width: 100% !important;"
/> />
<slot <slot
name="main" 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" style="grid-area: main"
/> />
<slot <slot
name="suffix" 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;" style="grid-area: suffix;"
/> />
</div> </div>
<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;" style="grid-area: navbar;"
> >
<slot <slot
name="navbar" name="navbar"
class="border rounded-full border-slate-200 dark:border-zinc-800 shadow-2xl class="
backdrop-blur-xl dark:backdrop-brightness-[25%] bg-[#ffffff]/75 dark:bg-transparent transition-colors duration-500" {$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" style="grid-area: navbar"
{title} {title}
/> />
@@ -13,6 +13,7 @@
<Button <Button
color="tertiary" color="tertiary"
{...$$restProps} {...$$restProps}
on:click
class="rounded-full w-10 h-10 flex-shrink-0 {isSelected 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' ? 'bg-slate-200 dark:bg-zinc-900 text-primary-900 dark:!text-primary-100'
: ''} {$$props.class ?? ''}" : ''} {$$props.class ?? ''}"
+43 -3
View File
@@ -8,7 +8,7 @@
} from '$lib/components/lemmy/moderation/moderation.js' } from '$lib/components/lemmy/moderation/moderation.js'
import Avatar from '$lib/components/ui/Avatar.svelte' import Avatar from '$lib/components/ui/Avatar.svelte'
import { site } from '$lib/lemmy.js' import { site } from '$lib/lemmy.js'
import { Menu, MenuButton, MenuDivider, Spinner } from 'mono-svelte' import { Button, Menu, MenuButton, MenuDivider, Spinner } from 'mono-svelte'
import { import {
GlobeAlt, GlobeAlt,
Home, Home,
@@ -18,21 +18,57 @@
PencilSquare, PencilSquare,
Plus, Plus,
ServerStack, ServerStack,
XMark,
} from 'svelte-hero-icons' } from 'svelte-hero-icons'
import Profile from './Profile.svelte' import Profile from './Profile.svelte'
import NavButton from './NavButton.svelte' import NavButton from './NavButton.svelte'
import { scale } from 'svelte/transition' import { scale } from 'svelte/transition'
import { expoOut, backOut } from 'svelte/easing' import { expoOut, backOut } from 'svelte/easing'
import { flip } from 'svelte/animate' import { flip } from 'svelte/animate'
import SearchBar from '$lib/components/lemmy/util/SearchBar.svelte'
let searching = false
</script> </script>
<nav <nav
class="flex flex-row gap-2 items-center w-full mx-auto z-50 box-border h-16 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} {$$props.class}
" "
style={$$props.style} 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"> <div class="flex flex-row gap-2 py-2 px-2 items-center w-full">
<Profile <Profile
placement="top" placement="top"
@@ -134,7 +170,11 @@
{/if} {/if}
</NavButton> </NavButton>
{/if} {/if}
<NavButton href="/search" label="Search" icon={MagnifyingGlass} /> <NavButton
on:click={() => (searching = true)}
label="Search"
icon={MagnifyingGlass}
/>
<NavButton href="/" label="Home" icon={Home} /> <NavButton href="/" label="Home" icon={Home} />
<Menu placement="top"> <Menu placement="top">
<NavButton <NavButton
+8
View File
@@ -81,6 +81,10 @@ interface Settings {
clickToView: boolean clickToView: boolean
youtube: 'youtube' | 'invidious' | 'piped' youtube: 'youtube' | 'invidious' | 'piped'
} }
dock: {
noGap: boolean
top: boolean
}
} }
export const defaultSettings: Settings = { export const defaultSettings: Settings = {
@@ -135,6 +139,10 @@ export const defaultSettings: Settings = {
embeds: { embeds: {
clickToView: true, clickToView: true,
youtube: 'youtube', youtube: 'youtube',
},
dock: {
noGap: false,
top: false
} }
} }
+4 -2
View File
@@ -11,6 +11,7 @@
import { import {
colors, colors,
colorsToVars, colorsToVars,
defaultColors,
inDarkLegacyTheme, inDarkLegacyTheme,
legacyTheme, legacyTheme,
} from '$lib/ui/colors.js' } from '$lib/ui/colors.js'
@@ -73,8 +74,8 @@
<meta <meta
name="theme-color" name="theme-color"
content={darklegacyTheme content={darklegacyTheme
? $colors?.zinc?.[950] ?? '#09090b' ? $colors?.zinc?.[925] ?? defaultColors.zinc[925]
: $colors?.slate?.[50] ?? '#f8fafc'} : $colors?.slate?.[25] ?? defaultColors.slate[25]}
/> />
{#if $site} {#if $site}
<title>{$site.site_view.site.name}</title> <title>{$site.site_view.site.name}</title>
@@ -148,6 +149,7 @@
taglines={$site.taglines} taglines={$site.taglines}
admins={$site.admins} admins={$site.admins}
version={$site.version} version={$site.version}
class="pt-4"
/> />
{:else} {:else}
<div class="h-64 w-full grid place-items-center"> <div class="h-64 w-full grid place-items-center">
+18 -1
View File
@@ -150,10 +150,27 @@
{/if} {/if}
</Section> </Section>
<Section title="Navigation">
<Setting>
<span slot="title">Dock Alignment</span>
<span slot="description">Where the dock should be put</span>
<MultiSelect
options={[true, false]}
optionNames={['Top', 'Bottom']}
bind:selected={$userSettings.dock.top}
/>
</Setting>
<ToggleSetting
bind:checked={$userSettings.dock.noGap}
title="Panel"
description="Make the dock not float, similar to a panel."
/>
</Section>
<Section title="Embeds"> <Section title="Embeds">
<ToggleSetting <ToggleSetting
title="Click to view" title="Click to view"
description="Before loading embeds, click. (It is recommended to leave this on, to not load a video you don't want to load.)" description="Don't load an embed until you click it. (It is recommended to leave this on, to not load a video you don't want to load.)"
bind:checked={$userSettings.embeds.clickToView} bind:checked={$userSettings.embeds.clickToView}
/> />
<Setting> <Setting>
+3
View File
@@ -18,6 +18,9 @@ export default {
animation: { animation: {
'pop-in': 'pop-in 0.25s ease-out forwards', 'pop-in': 'pop-in 0.25s ease-out forwards',
}, },
spacing: {
'22': '88px'
},
keyframes: { keyframes: {
'pop-in': { 'pop-in': {
'0%, 100%': { transform: 'translateX(8px)', opacity: 0 }, '0%, 100%': { transform: 'translateX(8px)', opacity: 0 },