design: change profile page to use tabs
This commit is contained in:
1 parent
1aed9b3e48
commit
1a30bcee1d
3 files changed
+120
-63
No files matched your search
@@ -1,37 +1,10 @@
|
|||||||
<script lang="ts">
|
<script lang="ts" context="module">
|
||||||
import { userSettings } from '$lib/settings.js'
|
|
||||||
import { colors, colorsToVars } from '$lib/ui/colors'
|
|
||||||
import { routes } from '$lib/util.js'
|
|
||||||
|
|
||||||
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) {
|
|
||||||
if (content) return '!pt-20'
|
|
||||||
else return 'top-16 !max-h-[calc(100vh-4rem)]'
|
|
||||||
} else return '!pb-20'
|
|
||||||
} else {
|
|
||||||
if (!content) return ''
|
|
||||||
|
|
||||||
if (top) return '!pt-24'
|
|
||||||
else return '!pb-24'
|
|
||||||
}
|
|
||||||
|
|
||||||
return 'hi this is easter egg, my code broke'
|
|
||||||
}
|
|
||||||
|
|
||||||
let screenWidth = 1000
|
|
||||||
|
|
||||||
const calculateDockProperties = (
|
const calculateDockProperties = (
|
||||||
settings: typeof $userSettings.dock,
|
settings: {
|
||||||
screenWidth: number
|
top: boolean | null
|
||||||
|
noGap: boolean | null
|
||||||
|
},
|
||||||
|
screenWidth: number,
|
||||||
): {
|
): {
|
||||||
noGap: boolean
|
noGap: boolean
|
||||||
top: boolean
|
top: boolean
|
||||||
@@ -59,14 +32,55 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$: dockProps = calculateDockProperties($userSettings.dock, screenWidth)
|
export const calculatePadding = (
|
||||||
|
panel: boolean,
|
||||||
|
top: boolean,
|
||||||
|
content: boolean,
|
||||||
|
): {
|
||||||
|
top: number
|
||||||
|
class: string
|
||||||
|
} => {
|
||||||
|
if (panel) {
|
||||||
|
if (top) {
|
||||||
|
if (content) return { top: 80, class: '!pt-20' }
|
||||||
|
else return { top: 64, class: 'top-16 !max-h-[calc(100vh-4rem)]' }
|
||||||
|
} else return { top: 0, class: '!pb-20' }
|
||||||
|
} else {
|
||||||
|
if (!content) return { top: 0, class: '' }
|
||||||
|
|
||||||
$: contentPadding = calculatePadding(dockProps.noGap, dockProps.top, true)
|
if (top) return { top: 96, class: '!pt-24' }
|
||||||
$: sidePadding = calculatePadding(dockProps.noGap, dockProps.top, false)
|
else return { top: 0, class: '!pb-24' }
|
||||||
$: topPanel = dockProps.noGap && dockProps.top
|
}
|
||||||
|
|
||||||
|
return { top: 0, class: ' failed-to-calculate' }
|
||||||
|
}
|
||||||
|
|
||||||
|
export let screenWidth = writable(1000)
|
||||||
|
export let dockProps: Readable<ReturnType<typeof calculateDockProperties>> =
|
||||||
|
derived([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)),
|
||||||
|
)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:window bind:innerWidth={screenWidth} />
|
<script lang="ts">
|
||||||
|
import { userSettings } from '$lib/settings.js'
|
||||||
|
import { colors, colorsToVars } from '$lib/ui/colors'
|
||||||
|
import { routes } from '$lib/util.js'
|
||||||
|
import { derived, writable, type Readable, type Writable } from 'svelte/store'
|
||||||
|
|
||||||
|
export let route: { id: string | null } | undefined = undefined
|
||||||
|
|
||||||
|
$: title = route ? routes[(route.id as keyof typeof routes) ?? ''] : ''
|
||||||
|
|
||||||
|
$: sidePadding = calculatePadding($dockProps.noGap, $dockProps.top, false)
|
||||||
|
$: topPanel = $dockProps.noGap && $dockProps.top
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<svelte:window bind:innerWidth={$screenWidth} />
|
||||||
|
|
||||||
<div
|
<div
|
||||||
{...$$restProps}
|
{...$$restProps}
|
||||||
@@ -76,8 +90,8 @@
|
|||||||
<slot />
|
<slot />
|
||||||
<div
|
<div
|
||||||
class="
|
class="
|
||||||
{dockProps.noGap ? '' : 'p-4 max-w-3xl left-1/2 -translate-x-1/2'}
|
{$dockProps.noGap ? '' : 'p-4 max-w-3xl left-1/2 -translate-x-1/2'}
|
||||||
{dockProps.top ? 'top-0' : 'bottom-0'}
|
{$dockProps.top ? 'top-0' : 'bottom-0'}
|
||||||
{topPanel ? 'fixed top-0' : 'fixed'}
|
{topPanel ? 'fixed top-0' : 'fixed'}
|
||||||
w-full z-50 pointer-events-none"
|
w-full z-50 pointer-events-none"
|
||||||
style="grid-area: navbar;
|
style="grid-area: navbar;
|
||||||
@@ -88,8 +102,8 @@
|
|||||||
<slot
|
<slot
|
||||||
name="navbar"
|
name="navbar"
|
||||||
class="
|
class="
|
||||||
{dockProps.noGap
|
{$dockProps.noGap
|
||||||
? dockProps.top
|
? $dockProps.top
|
||||||
? 'border-b shadow-none rounded-none'
|
? 'border-b shadow-none rounded-none'
|
||||||
: 'border-t rounded-none'
|
: 'border-t rounded-none'
|
||||||
: 'border rounded-full'}
|
: 'border rounded-full'}
|
||||||
@@ -112,18 +126,18 @@
|
|||||||
name="sidebar"
|
name="sidebar"
|
||||||
class="hidden md:flex sticky top-0 left-0 max-w-full h-max bg-slate-50 dark:bg-zinc-950
|
class="hidden md:flex sticky top-0 left-0 max-w-full h-max bg-slate-50 dark:bg-zinc-950
|
||||||
z-40
|
z-40
|
||||||
{sidePadding}"
|
{sidePadding.class}"
|
||||||
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 z-0
|
class="w-full bg-slate-25 dark:bg-zinc-925 justify-self-center shadow-sm z-0
|
||||||
{contentPadding}"
|
{$contentPadding.class}"
|
||||||
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 max-h-screen bg-slate-50 dark:bg-zinc-950 z-40 {sidePadding}"
|
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;"
|
style="grid-area: suffix;"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import { page } from '$app/stores'
|
||||||
|
import { fly } from 'svelte/transition'
|
||||||
|
|
||||||
|
export let routes: {
|
||||||
|
href: string
|
||||||
|
name: string
|
||||||
|
}[]
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<nav
|
||||||
|
class="flex flex-row items-center gap-1 p-1 rounded-full bg-[#fff]/60 dark:bg-neutral-800/60
|
||||||
|
backdrop-blur-lg border border-gray-200/60 dark:border-neutral-800 shadow-lg overflow-auto
|
||||||
|
"
|
||||||
|
>
|
||||||
|
{#each routes as route}
|
||||||
|
<a
|
||||||
|
href={route.href}
|
||||||
|
class="font-medium rounded-full px-4 py-1 hover:bg-gray-200/40 hover:dark:bg-neutral-700/40
|
||||||
|
transition-colors duration-100 relative z-0"
|
||||||
|
>
|
||||||
|
{route.name}
|
||||||
|
{#if $page.url.pathname == route.href}
|
||||||
|
<div
|
||||||
|
class="rounded-full bg-gray-100/60 dark:bg-neutral-700/60
|
||||||
|
absolute inset-0 w-full h-full -z-10"
|
||||||
|
></div>
|
||||||
|
{/if}
|
||||||
|
</a>
|
||||||
|
{/each}
|
||||||
|
</nav>
|
||||||
@@ -3,6 +3,8 @@
|
|||||||
import { page } from '$app/stores'
|
import { page } from '$app/stores'
|
||||||
|
|
||||||
import MultiSelect from '$lib/components/input/Switch.svelte'
|
import MultiSelect from '$lib/components/input/Switch.svelte'
|
||||||
|
import Tabs from '$lib/components/ui/layout/pages/Tabs.svelte'
|
||||||
|
import { contentPadding } from '$lib/components/ui/layout/Shell.svelte'
|
||||||
import { t } from '$lib/translations'
|
import { t } from '$lib/translations'
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -11,23 +13,33 @@
|
|||||||
</svelte:head>
|
</svelte:head>
|
||||||
|
|
||||||
<div class="flex flex-col gap-4 h-full z-0">
|
<div class="flex flex-col gap-4 h-full z-0">
|
||||||
<MultiSelect
|
<div
|
||||||
options={[
|
class="sticky mx-auto z-50 max-w-full"
|
||||||
'/profile/user',
|
style="top: max(1.5rem, {$contentPadding.top}px);"
|
||||||
'/profile/settings',
|
>
|
||||||
'/profile/blocks',
|
<Tabs
|
||||||
'/profile/password',
|
routes={[
|
||||||
]}
|
{
|
||||||
optionNames={[
|
href: '/profile/user',
|
||||||
$t('routes.profile.user'),
|
name: $t('routes.profile.user'),
|
||||||
$t('routes.profile.settings'),
|
},
|
||||||
$t('routes.profile.blocks'),
|
|
||||||
$t('routes.profile.credentials'),
|
{
|
||||||
]}
|
href: '/profile/settings',
|
||||||
selected={$page.url.pathname}
|
name: $t('routes.profile.settings'),
|
||||||
on:select={(e) => {
|
},
|
||||||
goto(e.detail)
|
|
||||||
}}
|
{
|
||||||
/>
|
href: '/profile/blocks',
|
||||||
|
name: $t('routes.profile.blocks'),
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
href: '/profile/password',
|
||||||
|
name: $t('routes.profile.credentials'),
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<slot />
|
<slot />
|
||||||
</div>
|
</div>
|
||||||
Reference in new issue
Block a user