design: use better credentials tabs layout

This commit is contained in:
James Xylight committed 2025-08-24 10:56:37 -07:00
1 parent 952120a886
commit e5896505d2
9 files changed
+185 -189

No files matched your search

+10 -2
View File
@@ -1,12 +1,14 @@
<script lang="ts">
import { Icon, type IconSource } from 'svelte-hero-icons'
import type { ClassValue } from 'svelte/elements'
interface Props {
icon?: IconSource | undefined
title: string
description?: string | undefined
class?: string
class?: ClassValue
children?: import('svelte').Snippet
iconClass?: ClassValue
}
let {
@@ -15,6 +17,7 @@
description = undefined,
class: clazz = '',
children,
iconClass,
}: Props = $props()
</script>
@@ -24,7 +27,12 @@
<div class="flex flex-col gap-2 items-center max-w-sm">
{#if icon}
<div
class="bg-slate-100 dark:bg-zinc-900 p-3 rounded-2xl text-primary-900 dark:text-primary-100"
class={[
,
iconClass
? iconClass
: 'bg-slate-100 dark:bg-zinc-900 p-3 rounded-2xl text-primary-900 dark:text-primary-100',
]}
>
<Icon src={icon} size="28" solid />
</div>
+25 -13
View File
@@ -1,6 +1,7 @@
<script lang="ts">
import { invalidateAll } from '$app/navigation'
import { page } from '$app/state'
import TabButton from '$lib/components/input/switch/TabButton.svelte'
import { SvelteURL } from 'svelte/reactivity'
interface Props {
@@ -11,6 +12,7 @@
currentRoute?: SvelteURL | undefined
buildUrl?: (currentRoute: SvelteURL | undefined, href: string) => string
children?: import('svelte').Snippet
style?: 'header' | 'subpage'
}
let {
@@ -18,6 +20,7 @@
currentRoute = undefined,
buildUrl = (_, href) => href,
children,
style = 'header',
}: Props = $props()
function isSelected(url: URL, href?: SvelteURL) {
@@ -27,25 +30,34 @@
</script>
<nav
class="flex flex-row items-center gap-x-8 gap-y-4 p-1 justify-center sm:justify-start my-2 sm:mt-0 flex-wrap z-20"
class={[
'flex flex-row items-center justify-center sm:justify-start my-2 sm:mt-0 flex-wrap z-20',
style == 'header' ? 'p-1 gap-x-8 gap-y-4' : 'gap-3',
]}
>
{#each routes as route (route.href)}
{@const selected = isSelected(
page.url,
new SvelteURL(`${page.url.origin}${route.href}`),
)}
<a
onclick={() => invalidateAll()}
href={buildUrl(currentRoute, route.href)}
class={[
'rounded-full font-medium transition-colors duration-100 relative z-0 shrink-0 hover:text-slate-900 hover:dark:text-zinc-100',
selected
? 'text-primary-900 dark:text-primary-100'
: 'text-slate-500 dark:text-zinc-500',
]}
>
{route.name}
</a>
{#if style == 'header'}
<a
onclick={() => invalidateAll()}
href={buildUrl(currentRoute, route.href)}
class={[
'rounded-full font-medium transition-colors duration-100 relative z-0 shrink-0 hover:text-slate-900 hover:dark:text-zinc-100',
selected
? 'text-primary-900 dark:text-primary-100'
: 'text-slate-500 dark:text-zinc-500',
]}
>
{route.name}
</a>
{:else}
<TabButton href={buildUrl(currentRoute, route.href)} {selected}>
{route.name}
</TabButton>
{/if}
{/each}
{@render children?.()}
</nav>