Migrate shared UI and backend components
This commit is contained in:
1 parent
64d22d0aac
commit
ac08be0248
16 files changed
+236
-395
No files matched your search
@@ -1,12 +1,27 @@
|
||||
<script>
|
||||
import { page } from '$app/state';
|
||||
import { AppShell as SharedAppShell, ProfileDialog } from '@gabriel20xx/shared-code/web-ui';
|
||||
import { Tooltip } from 'bits-ui';
|
||||
import Header from '$lib/components/Header.svelte';
|
||||
import AuthPage from '$lib/features/auth/AuthPage.svelte';
|
||||
import { createAuthStore } from '$lib/features/auth/auth.svelte.js';
|
||||
import SettingsDialog from './SettingsDialog.svelte';
|
||||
|
||||
let { children } = $props();
|
||||
|
||||
const auth = createAuthStore();
|
||||
const navItems = [
|
||||
{ href: '/', label: 'Overview' },
|
||||
{ href: '/about', label: 'About' },
|
||||
];
|
||||
let settingsOpen = $state(false);
|
||||
let credentialsOpen = $state(false);
|
||||
|
||||
async function saveProfile(input) {
|
||||
await auth.updateCredentials({
|
||||
newUsername: input.username.trim() || undefined,
|
||||
newEmail: input.email.trim() || undefined,
|
||||
newPassword: input.password || undefined,
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
<Tooltip.Provider delayDuration={300}>
|
||||
@@ -19,11 +34,27 @@
|
||||
{:else if !auth.status || auth.status.setupRequired || !auth.status.authenticated}
|
||||
<AuthPage setupRequired={auth.status?.setupRequired ?? true} />
|
||||
{:else}
|
||||
<div class="flex min-h-screen flex-col">
|
||||
<Header />
|
||||
<main class="flex min-w-0 flex-1 flex-col">
|
||||
<SharedAppShell
|
||||
brand="CollabTable"
|
||||
currentPath={page.url.pathname}
|
||||
{navItems}
|
||||
theme="system"
|
||||
username={auth.status.username ?? ''}
|
||||
onLogout={() => auth.logout()}
|
||||
onProfile={() => (credentialsOpen = true)}
|
||||
onSettings={() => (settingsOpen = true)}
|
||||
>
|
||||
{#snippet children()}
|
||||
{@render children?.()}
|
||||
</main>
|
||||
</div>
|
||||
{/snippet}
|
||||
</SharedAppShell>
|
||||
{/if}
|
||||
</Tooltip.Provider>
|
||||
|
||||
<SettingsDialog bind:open={settingsOpen} />
|
||||
<ProfileDialog
|
||||
bind:open={credentialsOpen}
|
||||
currentUsername={auth.status?.username ?? ''}
|
||||
currentEmail={auth.status?.email ?? ''}
|
||||
onSave={saveProfile}
|
||||
/>
|
||||
@@ -1,7 +1,7 @@
|
||||
<script>
|
||||
import { Moon, Sun, SunMoon } from '@lucide/svelte';
|
||||
import Button from '$lib/components/ui/button.svelte';
|
||||
import { Dialog, DialogContent, DialogFooter, DialogHeader, DialogTitle } from '$lib/components/ui/dialog';
|
||||
import { SettingsDialog as SharedSettingsDialog } from '@gabriel20xx/shared-code/web-ui';
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '$lib/components/ui/select';
|
||||
import { currentLanguage, languages, setLanguage } from '$lib/language.svelte.js';
|
||||
import { themeState } from '$lib/theme.svelte.js';
|
||||
@@ -11,11 +11,7 @@
|
||||
const languageItems = languages.map((language) => ({ value: language.id, label: language.label }));
|
||||
</script>
|
||||
|
||||
<Dialog bind:open>
|
||||
<DialogContent>
|
||||
<DialogHeader>
|
||||
<DialogTitle>Settings</DialogTitle>
|
||||
</DialogHeader>
|
||||
<SharedSettingsDialog bind:open title="Settings">
|
||||
<div>
|
||||
<span class="mb-2 block text-sm font-medium">Theme</span>
|
||||
<div class="flex w-full rounded-md border border-border p-1">
|
||||
@@ -69,8 +65,7 @@
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<DialogFooter>
|
||||
<Button type="button" variant="secondary" onclick={() => (open = false)}>Dismiss</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
<div class="sc-form-actions">
|
||||
<Button type="button" variant="secondary" onclick={() => (open = false)}>Dismiss</Button>
|
||||
</div>
|
||||
</SharedSettingsDialog>
|
||||
Reference in new issue
Block a user