migrate: convert most components to svelte 5

This commit is contained in:
Xylight committed 2024-10-25 19:33:27 -07:00
1 parent d670f39f0a
commit 10ef4123da
225 files changed
+5441 -3341

No files matched your search

+76 -50
View File
@@ -1,10 +1,12 @@
<script lang="ts" context="module">
<script lang="ts" module>
import { derived as derivedStore } from 'svelte/store'
const calculateDockProperties = (
settings: {
top: boolean | null
noGap: boolean | null
},
screenWidth: number
screenWidth: number,
): {
noGap: boolean
top: boolean
@@ -35,7 +37,7 @@
export const calculatePadding = (
panel: boolean,
top: boolean,
content: boolean
content: boolean,
): {
top: number
bottom: number
@@ -63,12 +65,15 @@
export let screenWidth = writable(1000)
export let dockProps: Readable<ReturnType<typeof calculateDockProperties>> =
derived([userSettings, screenWidth], ([$settings, $screenWidth], set) => {
set(calculateDockProperties($settings.dock, $screenWidth))
})
derivedStore(
[userSettings, screenWidth],
([$settings, $screenWidth], set) => {
set(calculateDockProperties($settings.dock, $screenWidth))
},
)
export let contentPadding: Readable<ReturnType<typeof calculatePadding>> =
derived(dockProps, ($dockProps, set) =>
set(calculatePadding($dockProps.noGap, $dockProps.top, true))
derivedStore(dockProps, ($dockProps, set) =>
set(calculatePadding($dockProps.noGap, $dockProps.top, true)),
)
</script>
@@ -76,27 +81,47 @@
import { userSettings } from '$lib/settings.js'
import { themeVars } from '$lib/ui/colors'
import { routes } from '$lib/util.js'
import { derived, writable, type Readable, type Writable } from 'svelte/store'
import { writable, type Readable, type Writable } from 'svelte/store'
export let route: { id: string | null } | undefined = undefined
interface Props {
route?: { id: string | null } | undefined
class?: string
children?: import('svelte').Snippet
navbar?: import('svelte').Snippet<[any]>
sidebar?: import('svelte').Snippet<[any]>
main?: import('svelte').Snippet<[any]>
suffix?: import('svelte').Snippet<[any]>
[key: string]: any
}
$: title = route ? routes[(route.id as keyof typeof routes) ?? ''] : ''
let {
route = undefined,
class: clazz = '',
children,
navbar,
sidebar,
main,
suffix,
...rest
}: Props = $props()
$: sidePadding = calculatePadding($dockProps.noGap, $dockProps.top, false)
$: topPanel = $dockProps.noGap && $dockProps.top
let clazz: string = ''
export { clazz as class }
let title = $derived(
route ? routes[(route.id as keyof typeof routes) ?? ''] : '',
)
let sidePadding = $derived(
calculatePadding($dockProps.noGap, $dockProps.top, false),
)
let topPanel = $derived($dockProps.noGap && $dockProps.top)
</script>
<svelte:window bind:innerWidth={$screenWidth} />
<div
{...$$restProps}
{...rest}
class="shell bg-slate-50 dark:bg-zinc-950 {clazz}"
style={$themeVars}
>
<slot />
{@render children?.()}
<div
class="
{$dockProps.noGap ? '' : 'p-4 max-w-3xl left-1/2 -translate-x-1/2'}
@@ -108,47 +133,48 @@
transition-duration: 250ms;
transition-timing-function: cubic-bezier(0.075, 0.82, 0.165, 1);"
>
<slot
name="navbar"
class="
{$dockProps.noGap
? $dockProps.top
? 'border-b shadow-none rounded-none'
: 'border-t rounded-none'
: 'border rounded-full'}
{@render navbar?.({
class: `
${
$dockProps.noGap
? $dockProps.top
? 'border-b shadow-none rounded-none'
: 'border-t rounded-none'
: 'border rounded-full'
}
dark:bg-transparent transition-colors duration-500
pointer-events-auto backdrop-blur-xl {topPanel
? 'bg-slate-50/50 dark:bg-zinc-950/90 border-slate-100 dark:border-zinc-900'
: `border-slate-200 dark:border-zinc-800 shadow-2xl
bg-white/50 dark:bg-zinc-950/70`}"
{title}
style="transition: border-radius 250ms;"
/>
pointer-events-auto backdrop-blur-xl ${
topPanel
? 'bg-slate-50/50 dark:bg-zinc-950/90 border-slate-100 dark:border-zinc-900'
: `border-slate-200 dark:border-zinc-800 shadow-2xl
bg-white/50 dark:bg-zinc-950/70`
}`,
title,
style: 'transition: border-radius 250ms;',
})}
</div>
<div
class="content divide-x divide-slate-100 dark:divide-zinc-900 min-h-screen {$userSettings.newWidth
? 'limit-width'
: ''}"
>
<slot
name="sidebar"
class="hidden md:flex sticky top-0 left-0 h-max bg-slate-50 dark:bg-zinc-950
{@render sidebar?.({
class: `hidden md:flex sticky top-0 left-0 h-max bg-slate-50 dark:bg-zinc-950
z-40
{sidePadding.class}"
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 z-0
{$contentPadding.class} main"
style="grid-area: main"
/>
<slot
name="suffix"
class="max-xl:hidden w-full sticky top-0 left-0 max-h-screen bg-slate-50 dark:bg-zinc-950 z-40 {sidePadding.class}"
style="grid-area: suffix;"
/>
${sidePadding.class}`,
style: 'grid-area: sidebar; width: 100% !important;',
})}
{@render main?.({
class: `w-full bg-slate-25 dark:bg-zinc-925 justify-self-center shadow-sm z-0
${$contentPadding.class} main`,
style: 'grid-area: main',
})}
{@render suffix?.({
class:
'max-xl:hidden w-full sticky top-0 left-0 max-h-screen bg-slate-50 dark:bg-zinc-950 z-40 {sidePadding.class}',
style: 'grid-area: suffix;',
})}
</div>
</div>