refactor: simplify settings page layout

This commit is contained in:
2026-03-09 14:19:59 -04:00
parent a3e49dc918
commit 10eaf84329
2 changed files with 46 additions and 53 deletions

View File

@@ -1,7 +1,5 @@
<script lang="ts">
import * as Sidebar from '$lib/components/ui/sidebar/index.js';
import { page } from '$app/state';
import Separator from '$lib/components/ui/separator/separator.svelte';
let { children } = $props();
const items = [
@@ -12,40 +10,29 @@
{
title: 'Libraries',
url: '/settings/libraries'
},
{
title: 'Devices',
url: '/settings/devices'
}
];
</script>
<div class="flex h-[calc(100vh-var(--header-height)-2rem)] flex-col">
<h1 class="text-xl font-bold">Settings</h1>
<Separator class="my-4" />
<div class="flex flex-1 gap-6 overflow-hidden">
<div class="flex gap-8">
<Sidebar.Provider class="shrink-0">
<Sidebar.Inset>
<Sidebar.Content>
<Sidebar.Group class="flex flex-col gap-1">
<div class="mt-6 flex flex-1 gap-8 overflow-hidden">
<nav class="flex w-48 shrink-0 flex-col gap-1">
{#each items as item}
<Sidebar.MenuItem class="w-48">
<Sidebar.MenuButton
class="rounded hover:bg-muted {page.url.pathname.endsWith(item.url)
<a
href={item.url}
class="rounded-md px-3 py-2 text-sm font-medium transition-colors hover:bg-muted {page.url.pathname.endsWith(item.url)
? 'bg-muted'
: ''}"
: 'text-muted-foreground'}"
>
{#snippet child({ props })}
<a href={item.url} {...props}>
<span class="text-base">{item.title}</span>
{item.title}
</a>
{/snippet}
</Sidebar.MenuButton>
</Sidebar.MenuItem>
{/each}
</Sidebar.Group>
</Sidebar.Content>
</Sidebar.Inset>
</Sidebar.Provider>
</div>
<Separator orientation="vertical" class="self-stretch" />
<div class="mx-2 mt-2 flex-1 overflow-auto">{@render children()}</div>
</nav>
<div class="flex-1 overflow-auto">{@render children()}</div>
</div>
</div>

View File

@@ -8,33 +8,39 @@
const libraryState = getLibraryState();
</script>
<h1 class="text-lg font-semibold">Library Settings</h1>
<div class="mb-4 flex items-center justify-between">
<div>
<h2 class="text-lg font-semibold">Libraries</h2>
<p class="text-sm text-muted-foreground">Manage your libraries</p>
<Card.Root class="mt-6">
<Card.Content>
<Card.Header class="mb-2 flex items-center">
<Card.Title>Libraries</Card.Title>
<Button
variant="outline"
class="ml-auto"
onclick={() => libraryState.openLibraryCreateDialog()}
>
</div>
<Button variant="outline" onclick={() => libraryState.openLibraryCreateDialog()}>
<Plus />
Add Library
</Button>
</Card.Header>
</div>
<Card.Root>
<Card.Content class="p-0">
<Table.Root>
<Table.Header>
<Table.Row>
<Table.Head class="w-16 pl-4"></Table.Head>
<Table.Head>Name</Table.Head>
<Table.Head class="w-16"></Table.Head>
</Table.Row>
</Table.Header>
<Table.Body>
{#each libraryState.libraries as library}
<Table.Row class="h-16">
<Table.Cell class="w-16 text-center text-lg font-semibold">{library.name[0]}</Table.Cell
<Table.Row class="h-14">
<Table.Cell class="w-16 pl-4 text-center text-lg font-semibold"
>{library.name[0]}</Table.Cell
>
<Table.Cell class="font-medium"
><a href={`/library/${library.id}`} class="hover:underline">{library.name}</a
></Table.Cell
>
<Table.Cell class="w-16 text-center"><EllipsisVertical class="scale-75" /></Table.Cell>
<Table.Cell class="font-medium">
<a href={`/library/${library.id}`} class="hover:underline">{library.name}</a>
</Table.Cell>
<Table.Cell class="w-16 text-center">
<EllipsisVertical class="scale-75" />
</Table.Cell>
</Table.Row>
{/each}
</Table.Body>