feat: add user credentials management and health monitoring features
- Implemented CredentialsDialog for updating user credentials. - Created auth store with functions for managing authentication state. - Added HealthWidget to display server health status. - Introduced health monitoring functionality with polling. - Developed AppShell layout to manage authentication and loading states. - Added SettingsDialog for user preferences including theme and language. - Created utility functions for list management and data fetching. - Implemented dashboard view mode preferences. - Integrated search functionality for filtering lists. - Established theme management with local storage support. - Added utility functions for class name management. - Configured SvelteKit for static site generation with fallback. - Set up Vite for development with proxy support for API calls. - Created About and List detail pages with data fetching and display. - Added favicon and updated project configuration files.
This commit is contained in:
1 parent
a4a3eeb5cc
commit
6c1ea2da47
80 files changed
No files matched your search
@@ -0,0 +1,39 @@
|
||||
<script module>
|
||||
import { cva } from 'class-variance-authority';
|
||||
|
||||
export const buttonVariants = cva(
|
||||
'inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 [&_svg]:size-4 [&_svg]:shrink-0',
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
default: 'bg-primary text-primary-fg hover:opacity-90',
|
||||
secondary: 'bg-surface text-fg hover:bg-surface-hover border border-border',
|
||||
ghost: 'hover:bg-surface-hover text-fg',
|
||||
outline: 'border border-border bg-transparent hover:bg-surface-hover text-fg',
|
||||
danger: 'bg-danger text-danger-fg hover:opacity-90',
|
||||
link: 'text-primary underline-offset-4 hover:underline',
|
||||
},
|
||||
size: {
|
||||
default: 'h-9 px-4 py-2',
|
||||
sm: 'h-8 rounded-md px-3 text-xs',
|
||||
lg: 'h-10 rounded-md px-6',
|
||||
icon: 'h-9 w-9',
|
||||
},
|
||||
},
|
||||
defaultVariants: {
|
||||
variant: 'default',
|
||||
size: 'default',
|
||||
},
|
||||
},
|
||||
);
|
||||
</script>
|
||||
|
||||
<script>
|
||||
import { cn } from '$lib/utils/cn.js';
|
||||
|
||||
let { class: className, variant, size, type = 'button', ref = $bindable(null), children, ...restProps } = $props();
|
||||
</script>
|
||||
|
||||
<button bind:this={ref} {type} class={cn(buttonVariants({ variant, size }), className)} {...restProps}>
|
||||
{@render children?.()}
|
||||
</button>
|
||||
@@ -0,0 +1,27 @@
|
||||
<script>
|
||||
import { Dialog } from 'bits-ui';
|
||||
import { X } from '@lucide/svelte';
|
||||
import { cn } from '$lib/utils/cn.js';
|
||||
|
||||
let { ref = $bindable(null), class: className, children, ...restProps } = $props();
|
||||
</script>
|
||||
|
||||
<Dialog.Portal>
|
||||
<Dialog.Overlay class="fixed inset-0 z-50 bg-black/50 animate-in fade-in-0" />
|
||||
<Dialog.Content
|
||||
bind:ref
|
||||
class={cn(
|
||||
'fixed left-1/2 top-1/2 z-50 max-h-[calc(100dvh-2rem)] w-[calc(100%-2rem)] max-w-lg -translate-x-1/2 -translate-y-1/2 overflow-y-auto rounded-lg border border-border bg-bg p-6 shadow-lg animate-in fade-in-0 zoom-in-95',
|
||||
className,
|
||||
)}
|
||||
{...restProps}
|
||||
>
|
||||
{@render children?.()}
|
||||
<Dialog.Close
|
||||
class="absolute right-4 top-4 rounded-sm opacity-70 transition-opacity hover:opacity-100 focus-visible:outline-none"
|
||||
>
|
||||
<X class="size-4" />
|
||||
<span class="sr-only">Close</span>
|
||||
</Dialog.Close>
|
||||
</Dialog.Content>
|
||||
</Dialog.Portal>
|
||||
@@ -0,0 +1,9 @@
|
||||
<script>
|
||||
import { cn } from '$lib/utils/cn.js';
|
||||
|
||||
let { class: className, children, ...restProps } = $props();
|
||||
</script>
|
||||
|
||||
<div class={cn('mt-6 flex flex-col-reverse gap-2 sm:flex-row sm:justify-end', className)} {...restProps}>
|
||||
{@render children?.()}
|
||||
</div>
|
||||
@@ -0,0 +1,9 @@
|
||||
<script>
|
||||
import { cn } from '$lib/utils/cn.js';
|
||||
|
||||
let { class: className, children, ...restProps } = $props();
|
||||
</script>
|
||||
|
||||
<div class={cn('mb-4 flex flex-col gap-1', className)} {...restProps}>
|
||||
{@render children?.()}
|
||||
</div>
|
||||
@@ -0,0 +1,10 @@
|
||||
import { Dialog as DialogPrimitive } from 'bits-ui';
|
||||
|
||||
export const Dialog = DialogPrimitive.Root;
|
||||
export const DialogTrigger = DialogPrimitive.Trigger;
|
||||
export const DialogClose = DialogPrimitive.Close;
|
||||
|
||||
export { default as DialogContent } from './content.svelte';
|
||||
export { default as DialogHeader } from './header.svelte';
|
||||
export { default as DialogTitle } from './title.svelte';
|
||||
export { default as DialogFooter } from './footer.svelte';
|
||||
@@ -0,0 +1,10 @@
|
||||
<script>
|
||||
import { Dialog } from 'bits-ui';
|
||||
import { cn } from '$lib/utils/cn.js';
|
||||
|
||||
let { ref = $bindable(null), class: className, children, ...restProps } = $props();
|
||||
</script>
|
||||
|
||||
<Dialog.Title bind:ref class={cn('text-lg font-semibold', className)} {...restProps}>
|
||||
{@render children?.()}
|
||||
</Dialog.Title>
|
||||
@@ -0,0 +1,28 @@
|
||||
<script>
|
||||
import { DropdownMenu } from 'bits-ui';
|
||||
import { cn } from '$lib/utils/cn.js';
|
||||
|
||||
let {
|
||||
ref = $bindable(null),
|
||||
class: className,
|
||||
sideOffset = 6,
|
||||
align = 'end',
|
||||
children,
|
||||
...restProps
|
||||
} = $props();
|
||||
</script>
|
||||
|
||||
<DropdownMenu.Portal>
|
||||
<DropdownMenu.Content
|
||||
bind:ref
|
||||
{sideOffset}
|
||||
{align}
|
||||
class={cn(
|
||||
'z-50 min-w-[10rem] overflow-hidden rounded-md border border-border bg-surface p-1 text-fg shadow-lg animate-in fade-in-0 zoom-in-95',
|
||||
className,
|
||||
)}
|
||||
{...restProps}
|
||||
>
|
||||
{@render children?.()}
|
||||
</DropdownMenu.Content>
|
||||
</DropdownMenu.Portal>
|
||||
@@ -0,0 +1,8 @@
|
||||
import { DropdownMenu as DropdownMenuPrimitive } from 'bits-ui';
|
||||
|
||||
export const DropdownMenu = DropdownMenuPrimitive.Root;
|
||||
export const DropdownMenuTrigger = DropdownMenuPrimitive.Trigger;
|
||||
|
||||
export { default as DropdownMenuContent } from './content.svelte';
|
||||
export { default as DropdownMenuItem } from './item.svelte';
|
||||
export { default as DropdownMenuSeparator } from './separator.svelte';
|
||||
@@ -0,0 +1,18 @@
|
||||
<script>
|
||||
import { DropdownMenu } from 'bits-ui';
|
||||
import { cn } from '$lib/utils/cn.js';
|
||||
|
||||
let { ref = $bindable(null), class: className, active = false, children, ...restProps } = $props();
|
||||
</script>
|
||||
|
||||
<DropdownMenu.Item
|
||||
bind:ref
|
||||
class={cn(
|
||||
'flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none data-highlighted:bg-surface-hover',
|
||||
active && 'text-primary font-medium',
|
||||
className,
|
||||
)}
|
||||
{...restProps}
|
||||
>
|
||||
{@render children?.()}
|
||||
</DropdownMenu.Item>
|
||||
@@ -0,0 +1,8 @@
|
||||
<script>
|
||||
import { DropdownMenu } from 'bits-ui';
|
||||
import { cn } from '$lib/utils/cn.js';
|
||||
|
||||
let { ref = $bindable(null), class: className, ...restProps } = $props();
|
||||
</script>
|
||||
|
||||
<DropdownMenu.Separator bind:ref class={cn('-mx-1 my-1 h-px bg-border', className)} {...restProps} />
|
||||
@@ -0,0 +1,93 @@
|
||||
<script>
|
||||
import { ChevronFirst, ChevronLast, ChevronLeft, ChevronRight } from '@lucide/svelte';
|
||||
import Button from './button.svelte';
|
||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from './select';
|
||||
import { SimpleTooltip } from './tooltip';
|
||||
|
||||
let { page, pageSize, pageSizes = [12, 24, 48, 96], pageLength = 0, totalLength = 0, onPaging } = $props();
|
||||
|
||||
const hasPreviousPage = $derived(page > 1);
|
||||
const firstItemIndex = $derived((page - 1) * pageSize + 1);
|
||||
const lastItemIndex = $derived((page - 1) * pageSize + pageLength);
|
||||
const hasNextPage = $derived(page * pageSize < totalLength);
|
||||
|
||||
// Passed as `Select`'s `items` prop so the trigger shows the right label immediately, even
|
||||
// before the dropdown has ever been opened - bits-ui can't rely on `Select.Item` having
|
||||
// mounted to the DOM yet to read its label back off of it.
|
||||
const pageSizeItems = $derived(pageSizes.map((size) => ({ value: String(size), label: String(size) })));
|
||||
</script>
|
||||
|
||||
<div class="flex flex-wrap items-center justify-end gap-4 px-2 py-3 text-sm">
|
||||
<Select
|
||||
type="single"
|
||||
value={String(pageSize)}
|
||||
items={pageSizeItems}
|
||||
onValueChange={(value) => onPaging({ page: 1, pageSize: Number(value) })}
|
||||
>
|
||||
<SelectTrigger class="w-24">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{#each pageSizeItems as item (item.value)}
|
||||
<SelectItem value={item.value} label={item.label}>{item.label}</SelectItem>
|
||||
{/each}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<p class="text-muted-fg">
|
||||
{firstItemIndex.toLocaleString()}–{lastItemIndex.toLocaleString()} of {totalLength.toLocaleString()}
|
||||
</p>
|
||||
<div class="flex items-center gap-1">
|
||||
<SimpleTooltip label="First page">
|
||||
{#snippet children({ props })}
|
||||
<Button
|
||||
{...props}
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
disabled={!hasPreviousPage}
|
||||
onclick={() => onPaging({ page: 1, pageSize })}
|
||||
>
|
||||
<ChevronFirst class="size-4" />
|
||||
</Button>
|
||||
{/snippet}
|
||||
</SimpleTooltip>
|
||||
<SimpleTooltip label="Previous page">
|
||||
{#snippet children({ props })}
|
||||
<Button
|
||||
{...props}
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
disabled={!hasPreviousPage}
|
||||
onclick={() => onPaging({ page: page - 1, pageSize })}
|
||||
>
|
||||
<ChevronLeft class="size-4" />
|
||||
</Button>
|
||||
{/snippet}
|
||||
</SimpleTooltip>
|
||||
<SimpleTooltip label="Next page">
|
||||
{#snippet children({ props })}
|
||||
<Button
|
||||
{...props}
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
disabled={!hasNextPage}
|
||||
onclick={() => onPaging({ page: page + 1, pageSize })}
|
||||
>
|
||||
<ChevronRight class="size-4" />
|
||||
</Button>
|
||||
{/snippet}
|
||||
</SimpleTooltip>
|
||||
<SimpleTooltip label="Last page">
|
||||
{#snippet children({ props })}
|
||||
<Button
|
||||
{...props}
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
disabled={!hasNextPage}
|
||||
onclick={() => onPaging({ page: Math.max(1, Math.ceil(totalLength / pageSize)), pageSize })}
|
||||
>
|
||||
<ChevronLast class="size-4" />
|
||||
</Button>
|
||||
{/snippet}
|
||||
</SimpleTooltip>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,20 @@
|
||||
<script>
|
||||
import { Select } from 'bits-ui';
|
||||
import { cn } from '$lib/utils/cn.js';
|
||||
|
||||
let { ref = $bindable(null), class: className, sideOffset = 4, children, ...restProps } = $props();
|
||||
</script>
|
||||
|
||||
<Select.Portal>
|
||||
<Select.Content
|
||||
bind:ref
|
||||
{sideOffset}
|
||||
class={cn(
|
||||
'z-50 max-h-72 w-[var(--bits-select-anchor-width)] overflow-y-auto rounded-md border border-border bg-surface p-1 shadow-lg',
|
||||
className,
|
||||
)}
|
||||
{...restProps}
|
||||
>
|
||||
{@render children?.()}
|
||||
</Select.Content>
|
||||
</Select.Portal>
|
||||
@@ -0,0 +1,8 @@
|
||||
import { Select as SelectPrimitive } from 'bits-ui';
|
||||
|
||||
export const Select = SelectPrimitive.Root;
|
||||
export const SelectValue = SelectPrimitive.Value;
|
||||
|
||||
export { default as SelectTrigger } from './trigger.svelte';
|
||||
export { default as SelectContent } from './content.svelte';
|
||||
export { default as SelectItem } from './item.svelte';
|
||||
@@ -0,0 +1,25 @@
|
||||
<script>
|
||||
import { Select } from 'bits-ui';
|
||||
import { Check } from '@lucide/svelte';
|
||||
import { cn } from '$lib/utils/cn.js';
|
||||
|
||||
let { ref = $bindable(null), class: className, value, label, children: itemLabel, ...restProps } = $props();
|
||||
</script>
|
||||
|
||||
<Select.Item
|
||||
bind:ref
|
||||
{value}
|
||||
{label}
|
||||
class={cn(
|
||||
'flex cursor-pointer select-none items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-none data-highlighted:bg-surface-hover',
|
||||
className,
|
||||
)}
|
||||
{...restProps}
|
||||
>
|
||||
{#snippet children({ selected })}
|
||||
{@render itemLabel?.()}
|
||||
{#if selected}
|
||||
<Check class="ml-auto size-4" />
|
||||
{/if}
|
||||
{/snippet}
|
||||
</Select.Item>
|
||||
@@ -0,0 +1,19 @@
|
||||
<script>
|
||||
import { Select } from 'bits-ui';
|
||||
import { ChevronDown } from '@lucide/svelte';
|
||||
import { cn } from '$lib/utils/cn.js';
|
||||
|
||||
let { ref = $bindable(null), class: className, children, ...restProps } = $props();
|
||||
</script>
|
||||
|
||||
<Select.Trigger
|
||||
bind:ref
|
||||
class={cn(
|
||||
'flex h-9 items-center justify-between gap-2 rounded-md border border-border bg-bg px-3 text-sm outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50',
|
||||
className,
|
||||
)}
|
||||
{...restProps}
|
||||
>
|
||||
{@render children?.()}
|
||||
<ChevronDown class="size-4 opacity-60" />
|
||||
</Select.Trigger>
|
||||
@@ -0,0 +1,20 @@
|
||||
<script>
|
||||
import { Tooltip } from 'bits-ui';
|
||||
import { cn } from '$lib/utils/cn.js';
|
||||
|
||||
let { ref = $bindable(null), class: className, sideOffset = 6, children, ...restProps } = $props();
|
||||
</script>
|
||||
|
||||
<Tooltip.Portal>
|
||||
<Tooltip.Content
|
||||
bind:ref
|
||||
{sideOffset}
|
||||
class={cn(
|
||||
'z-50 overflow-hidden rounded-md border border-border bg-surface px-3 py-1.5 text-xs text-fg shadow-md animate-in fade-in-0 zoom-in-95',
|
||||
className,
|
||||
)}
|
||||
{...restProps}
|
||||
>
|
||||
{@render children?.()}
|
||||
</Tooltip.Content>
|
||||
</Tooltip.Portal>
|
||||
@@ -0,0 +1,5 @@
|
||||
import { Tooltip as TooltipPrimitive } from 'bits-ui';
|
||||
|
||||
export const TooltipProvider = TooltipPrimitive.Provider;
|
||||
|
||||
export { default as SimpleTooltip } from './simple-tooltip.svelte';
|
||||
@@ -0,0 +1,15 @@
|
||||
<script>
|
||||
import { Tooltip } from 'bits-ui';
|
||||
import TooltipContent from './content.svelte';
|
||||
|
||||
let { label, children } = $props();
|
||||
</script>
|
||||
|
||||
<Tooltip.Root>
|
||||
<Tooltip.Trigger>
|
||||
{#snippet child({ props })}
|
||||
{@render children({ props })}
|
||||
{/snippet}
|
||||
</Tooltip.Trigger>
|
||||
<TooltipContent>{label}</TooltipContent>
|
||||
</Tooltip.Root>
|
||||
Reference in new issue
Block a user