Sync shared snapshot from 7b5a4e6
This commit is contained in:
1 parent
695ff742d6
commit
68f6dd5a87
47 files changed
+587
-726
No files matched your search
@@ -1,11 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte'
|
||||
import { get } from '$lib/api'
|
||||
import EmptyState from '$lib/components/EmptyState.svelte'
|
||||
import SectionTitle from '$lib/components/SectionTitle.svelte'
|
||||
import Badge from '$lib/components/ui/badge.svelte'
|
||||
import Button from '$lib/components/ui/button.svelte'
|
||||
import Card from '$lib/components/ui/card.svelte'
|
||||
import { Badge, Button, Card, EmptyState, SectionTitle } from '@gabriel20xx/web-ui'
|
||||
|
||||
type Json = Record<string, unknown>
|
||||
type MediaType = 'image' | 'video' | 'audio' | 'funscript'
|
||||
@@ -63,14 +59,14 @@
|
||||
return fallback
|
||||
}
|
||||
|
||||
function statusTone(status: string): 'neutral' | 'primary' | 'success' | 'warning' | 'danger' {
|
||||
function statusTone(status: string): 'default' | 'primary' | 'success' | 'warning' | 'danger' {
|
||||
const normalized = status.toLowerCase()
|
||||
if (normalized.includes('error') || normalized.includes('fail')) return 'danger'
|
||||
if (normalized.includes('process') || normalized.includes('running')) return 'primary'
|
||||
if (normalized.includes('queue') || normalized.includes('pending')) return 'warning'
|
||||
if (normalized.includes('done') || normalized.includes('complete') || normalized.includes('success'))
|
||||
return 'success'
|
||||
return 'neutral'
|
||||
return 'default'
|
||||
}
|
||||
|
||||
async function load({ background = false } = {}) {
|
||||
@@ -183,7 +179,7 @@
|
||||
<p class="truncate text-sm font-medium text-fg">{name}</p>
|
||||
{#if path}<p class="mt-1 truncate text-xs text-muted-fg">{path}</p>{/if}
|
||||
</div>
|
||||
<Badge tone={statusTone(status)}>{status}</Badge>
|
||||
<Badge variant={statusTone(status)}>{status}</Badge>
|
||||
</div>
|
||||
<div class="mt-2 flex flex-wrap gap-x-3 gap-y-1 text-xs text-muted-fg">
|
||||
{#if entryMediaType}<span>{entryMediaType}</span>{/if}
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
<script lang="ts">
|
||||
import { notify } from '@gabriel20xx/web-ui'
|
||||
import { Badge, Button, Card, notify, SectionTitle } from '@gabriel20xx/web-ui'
|
||||
import { post } from '$lib/api'
|
||||
import SectionTitle from '$lib/components/SectionTitle.svelte'
|
||||
import Badge from '$lib/components/ui/badge.svelte'
|
||||
import Button from '$lib/components/ui/button.svelte'
|
||||
import Card from '$lib/components/ui/card.svelte'
|
||||
|
||||
type Json = Record<string, unknown>
|
||||
type StatusTone = 'neutral' | 'primary' | 'success' | 'warning' | 'danger'
|
||||
type StatusTone = 'default' | 'primary' | 'success' | 'warning' | 'danger'
|
||||
|
||||
let {
|
||||
status = {},
|
||||
@@ -74,7 +70,7 @@
|
||||
if (running) return paused ? 'warning' : 'primary'
|
||||
if (label.includes('error') || label.includes('failed')) return 'danger'
|
||||
if (['idle', 'completed', 'complete', 'done'].includes(label)) return 'success'
|
||||
return 'neutral'
|
||||
return 'default'
|
||||
}
|
||||
|
||||
const extractionProgress = $derived(asRecord(status.extractionProgress))
|
||||
@@ -155,7 +151,7 @@
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<span class="text-sm text-muted-fg">State</span>
|
||||
<div class="flex items-center gap-2">
|
||||
<Badge {tone}>{stateLabel}</Badge>
|
||||
<Badge variant={tone}>{stateLabel}</Badge>
|
||||
{#if canStop}
|
||||
<Button variant="danger" size="sm" disabled={stopping} onclick={() => void stopAction()}>
|
||||
{stopping ? 'Stopping…' : 'Stop'}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<script lang="ts">
|
||||
import SectionTitle from '$lib/components/SectionTitle.svelte'
|
||||
import Card from '$lib/components/ui/card.svelte'
|
||||
import { Card, SectionTitle } from '@gabriel20xx/web-ui'
|
||||
|
||||
type Json = Record<string, unknown>
|
||||
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { Inbox } from '@lucide/svelte'
|
||||
let { title, message }: { title: string; message: string } = $props()
|
||||
</script>
|
||||
|
||||
<div
|
||||
class="flex min-h-40 flex-col items-center justify-center gap-3 rounded-lg border border-dashed border-border bg-surface/50 px-5 py-8 text-center"
|
||||
>
|
||||
<Inbox class="size-8 text-muted-fg" />
|
||||
<div>
|
||||
<p class="text-sm font-medium text-fg">{title}</p>
|
||||
<p class="mt-1 max-w-sm text-xs text-muted-fg">{message}</p>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { ArrowDown, ArrowRight, ChevronDown, FileCog, Image as ImageIcon, Search, Sparkles } from '@lucide/svelte'
|
||||
import Badge from '$lib/components/ui/badge.svelte'
|
||||
import { Badge } from '@gabriel20xx/web-ui'
|
||||
import { cn } from '$lib/utils/cn'
|
||||
|
||||
type StageStatus = { pending: number; processing: number; processed: number; errors: number; active: boolean }
|
||||
@@ -220,9 +220,9 @@
|
||||
<span class="text-sm font-semibold text-fg">Metadata</span>
|
||||
</div>
|
||||
{#if metadataStatus.active}
|
||||
<Badge tone="primary" class="animate-pulse">Active</Badge>
|
||||
<Badge variant="primary" class="animate-pulse">Active</Badge>
|
||||
{:else}
|
||||
<Badge tone="neutral">Idle</Badge>
|
||||
<Badge>Idle</Badge>
|
||||
{/if}
|
||||
</div>
|
||||
<p class="text-xs text-muted-fg">{metadataDescription}</p>
|
||||
@@ -249,9 +249,9 @@
|
||||
<span class="text-sm font-semibold text-fg">Thumbnails</span>
|
||||
</div>
|
||||
{#if thumbnailsStatus.active}
|
||||
<Badge tone="primary" class="animate-pulse">Active</Badge>
|
||||
<Badge variant="primary" class="animate-pulse">Active</Badge>
|
||||
{:else}
|
||||
<Badge tone="neutral">Idle</Badge>
|
||||
<Badge>Idle</Badge>
|
||||
{/if}
|
||||
</div>
|
||||
<p class="text-xs text-muted-fg">{thumbnailsDescription}</p>
|
||||
@@ -279,9 +279,9 @@
|
||||
<span class="text-sm font-semibold text-fg">AI analysis</span>
|
||||
</div>
|
||||
{#if analysisStatus.active}
|
||||
<Badge tone="primary" class="animate-pulse">Active</Badge>
|
||||
<Badge variant="primary" class="animate-pulse">Active</Badge>
|
||||
{:else}
|
||||
<Badge tone="neutral">Idle</Badge>
|
||||
<Badge>Idle</Badge>
|
||||
{/if}
|
||||
</div>
|
||||
<p class="text-xs text-muted-fg">
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
<script lang="ts">
|
||||
let { title, description = '' }: { title: string; description?: string } = $props()
|
||||
</script>
|
||||
|
||||
<div class="flex items-start justify-between gap-3">
|
||||
<div>
|
||||
<h2 class="text-sm font-semibold text-fg">{title}</h2>
|
||||
{#if description}<p class="mt-1 text-xs text-muted-fg">{description}</p>{/if}
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,6 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { Moon, Sun, SunMoon } from '@lucide/svelte'
|
||||
import Button from '$lib/components/ui/button.svelte'
|
||||
import { Button, SettingsDialog as SharedSettingsDialog } from '@gabriel20xx/web-ui'
|
||||
import { currentLanguage, languages, setLanguage } from '$lib/language.svelte'
|
||||
import { themeState } from '$lib/theme.svelte'
|
||||
|
||||
@@ -21,77 +21,62 @@
|
||||
})
|
||||
</script>
|
||||
|
||||
{#if open}
|
||||
<div
|
||||
class="fixed inset-0 z-50 grid place-items-center bg-black/70 p-4 backdrop-blur-sm"
|
||||
role="presentation"
|
||||
onclick={(event) => {
|
||||
if (event.target === event.currentTarget) open = false
|
||||
}}
|
||||
>
|
||||
<div
|
||||
class="w-full max-w-lg rounded-xl border border-border bg-surface p-6 shadow-xl"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-label="Settings"
|
||||
tabindex="-1"
|
||||
>
|
||||
<div class="flex items-start justify-between gap-4">
|
||||
<h2 class="text-xl font-semibold">Settings</h2>
|
||||
<button
|
||||
class="rounded-md px-2 py-1 text-2xl leading-none text-muted-fg hover:bg-surface-hover hover:text-fg"
|
||||
<SharedSettingsDialog bind:open title="Settings">
|
||||
<div class="sc-form">
|
||||
<div>
|
||||
<span class="sc-label">Theme</span>
|
||||
<div class="mediacollection-settings-theme-row">
|
||||
<Button
|
||||
type="button"
|
||||
aria-label="Close"
|
||||
onclick={() => (open = false)}>×</button
|
||||
variant={themeState.mode === 'light' ? 'secondary' : 'ghost'}
|
||||
size="sm"
|
||||
fullWidth
|
||||
onclick={() => themeState.setMode('light')}
|
||||
>
|
||||
</div>
|
||||
|
||||
<div class="mt-6 space-y-5">
|
||||
<div>
|
||||
<span class="mb-2 block text-sm font-medium">Theme</span>
|
||||
<div class="flex w-full rounded-md border border-border p-1">
|
||||
<Button
|
||||
type="button"
|
||||
variant={themeState.mode === 'light' ? 'secondary' : 'ghost'}
|
||||
size="sm"
|
||||
class="flex-1 gap-1.5"
|
||||
onclick={() => themeState.setMode('light')}
|
||||
>
|
||||
<Sun class="size-4" />
|
||||
Light
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
variant={themeState.mode === 'dark' ? 'secondary' : 'ghost'}
|
||||
size="sm"
|
||||
class="flex-1 gap-1.5"
|
||||
onclick={() => themeState.setMode('dark')}
|
||||
>
|
||||
<Moon class="size-4" />
|
||||
Dark
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
variant={themeState.mode === 'system' ? 'secondary' : 'ghost'}
|
||||
size="sm"
|
||||
class="flex-1 gap-1.5"
|
||||
onclick={() => themeState.setMode('system')}
|
||||
>
|
||||
<SunMoon class="size-4" />
|
||||
System
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<label class="block">
|
||||
<span class="mb-2 block text-sm font-medium">Language</span>
|
||||
<select class="field" value={currentLanguage()} onchange={(event) => setLanguage(event.currentTarget.value)}>
|
||||
{#each languageItems as item (item.value)}
|
||||
<option value={item.value}>{item.label}</option>
|
||||
{/each}
|
||||
</select>
|
||||
</label>
|
||||
<Sun size={16} />
|
||||
Light
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
variant={themeState.mode === 'dark' ? 'secondary' : 'ghost'}
|
||||
size="sm"
|
||||
fullWidth
|
||||
onclick={() => themeState.setMode('dark')}
|
||||
>
|
||||
<Moon size={16} />
|
||||
Dark
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
variant={themeState.mode === 'system' ? 'secondary' : 'ghost'}
|
||||
size="sm"
|
||||
fullWidth
|
||||
onclick={() => themeState.setMode('system')}
|
||||
>
|
||||
<SunMoon size={16} />
|
||||
System
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<label class="sc-field">
|
||||
<span class="sc-label">Language</span>
|
||||
<select class="sc-input" value={currentLanguage()} onchange={(event) => setLanguage(event.currentTarget.value)}>
|
||||
{#each languageItems as item (item.value)}
|
||||
<option value={item.value}>{item.label}</option>
|
||||
{/each}
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
{/if}
|
||||
</SharedSettingsDialog>
|
||||
|
||||
<style>
|
||||
.mediacollection-settings-theme-row {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
gap: 0.25rem;
|
||||
padding: 0.25rem;
|
||||
border: 1px solid var(--sc-border);
|
||||
border-radius: var(--sc-radius-md);
|
||||
}
|
||||
</style>
|
||||
@@ -1,102 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { AlertCircle, AlertTriangle, CheckCircle2, CircleHelp, LoaderCircle, RefreshCw, X } from '@lucide/svelte'
|
||||
import Button from '$lib/components/ui/button.svelte'
|
||||
import type { StatusProbe, StatusSnapshot } from '$lib/status'
|
||||
|
||||
let {
|
||||
open = $bindable(false),
|
||||
status,
|
||||
onRefresh,
|
||||
}: {
|
||||
open?: boolean
|
||||
status: StatusSnapshot
|
||||
onRefresh: () => Promise<void>
|
||||
} = $props()
|
||||
|
||||
const levelLabel = {
|
||||
checking: 'Checking',
|
||||
healthy: 'Healthy',
|
||||
degraded: 'Degraded',
|
||||
offline: 'Offline',
|
||||
}
|
||||
|
||||
const levelClass = {
|
||||
checking: 'text-muted-fg',
|
||||
healthy: 'text-success',
|
||||
degraded: 'text-warning',
|
||||
offline: 'text-danger',
|
||||
}
|
||||
|
||||
function probeLabel(probe: StatusProbe | null) {
|
||||
if (!probe) return 'Not checked'
|
||||
if (probe.ok) return 'OK'
|
||||
if (probe.error) return probe.error
|
||||
return probe.httpStatus ? `HTTP ${probe.httpStatus}` : 'Unavailable'
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if open}
|
||||
<div
|
||||
class="fixed inset-0 z-50 grid place-items-center bg-black/70 px-4"
|
||||
role="presentation"
|
||||
onclick={(event) => event.target === event.currentTarget && (open = false)}
|
||||
>
|
||||
<div
|
||||
class="w-full max-w-lg rounded-xl border border-border bg-bg p-6 text-fg shadow-2xl"
|
||||
role="dialog"
|
||||
aria-modal="true"
|
||||
aria-labelledby="status-dialog-title"
|
||||
>
|
||||
<div class="mb-5 flex items-start justify-between gap-3">
|
||||
<div>
|
||||
<h2 id="status-dialog-title" class="text-xl font-semibold">Service status</h2>
|
||||
<p class="mt-1 text-sm text-muted-fg">Live liveness and database readiness checks.</p>
|
||||
</div>
|
||||
<Button variant="ghost" size="icon" aria-label="Close" onclick={() => (open = false)}>
|
||||
<X class="size-4" />
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div class="mb-5 flex items-center gap-3 rounded-lg border border-border bg-surface p-3" aria-live="polite">
|
||||
{#if status.loading && status.level === 'checking'}
|
||||
<LoaderCircle class="size-5 animate-spin text-muted-fg" />
|
||||
{:else if status.level === 'healthy'}
|
||||
<CheckCircle2 class="size-5 text-success" />
|
||||
{:else if status.level === 'degraded'}
|
||||
<AlertTriangle class="size-5 text-warning" />
|
||||
{:else if status.level === 'offline'}
|
||||
<AlertCircle class="size-5 text-danger" />
|
||||
{:else}
|
||||
<CircleHelp class="size-5 text-muted-fg" />
|
||||
{/if}
|
||||
<span class={`font-medium ${levelClass[status.level]}`}>{levelLabel[status.level]}</span>
|
||||
{#if status.checkedAt}
|
||||
<span class="ml-auto text-xs text-muted-fg">{new Date(status.checkedAt).toLocaleTimeString()}</span>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<div class="space-y-2 text-sm">
|
||||
{#each [{ label: 'Liveness', probe: status.health }, { label: 'Readiness / database', probe: status.readiness }] as item (item.label)}
|
||||
<div class="flex items-center justify-between gap-4 rounded-md border border-border px-3 py-2">
|
||||
<span>{item.label}</span>
|
||||
<span class={item.probe?.ok ? 'text-success' : 'text-danger'}>{probeLabel(item.probe)}</span>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
{#if status.health?.service || status.readiness?.service}
|
||||
<p class="mt-4 text-xs text-muted-fg">
|
||||
Service: {status.health?.service || status.readiness?.service}
|
||||
</p>
|
||||
{/if}
|
||||
|
||||
<div class="mt-6 flex justify-end gap-2">
|
||||
<Button variant="outline" disabled={status.loading} onclick={() => void onRefresh()}>
|
||||
<RefreshCw class={status.loading ? 'animate-spin' : ''} />
|
||||
Refresh
|
||||
</Button>
|
||||
<Button variant="secondary" onclick={() => (open = false)}>Dismiss</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{/if}
|
||||
@@ -1,97 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { AlertCircle, AlertTriangle, CheckCircle2, CircleHelp, LoaderCircle } from '@lucide/svelte'
|
||||
import { onMount } from 'svelte'
|
||||
import Button from '$lib/components/ui/button.svelte'
|
||||
import StatusDialog from '$lib/components/StatusDialog.svelte'
|
||||
import type { StatusProbe, StatusSnapshot } from '$lib/status'
|
||||
|
||||
const initialStatus: StatusSnapshot = {
|
||||
level: 'checking',
|
||||
health: null,
|
||||
readiness: null,
|
||||
checkedAt: null,
|
||||
loading: false,
|
||||
}
|
||||
|
||||
let status = $state<StatusSnapshot>(initialStatus)
|
||||
let open = $state(false)
|
||||
let requestInFlight = false
|
||||
|
||||
async function probe(path: string): Promise<StatusProbe> {
|
||||
try {
|
||||
const response = await fetch(path, {
|
||||
credentials: 'include',
|
||||
headers: { Accept: 'application/json' },
|
||||
})
|
||||
const payload = (await response.json().catch(() => null)) as {
|
||||
ok?: boolean
|
||||
service?: string
|
||||
error?: string
|
||||
} | null
|
||||
return {
|
||||
path,
|
||||
ok: response.ok && payload?.ok !== false,
|
||||
httpStatus: response.status,
|
||||
service: payload?.service || null,
|
||||
error: response.ok ? null : payload?.error || response.statusText || `HTTP ${response.status}`,
|
||||
}
|
||||
} catch (error) {
|
||||
return {
|
||||
path,
|
||||
ok: false,
|
||||
httpStatus: null,
|
||||
service: null,
|
||||
error: error instanceof Error ? error.message : 'Unavailable',
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function refresh() {
|
||||
if (requestInFlight) return
|
||||
requestInFlight = true
|
||||
status = { ...status, loading: true, level: status.health || status.readiness ? status.level : 'checking' }
|
||||
|
||||
try {
|
||||
const [health, readiness] = await Promise.all([probe('/healthz'), probe('/ready')])
|
||||
const level = health.ok && readiness.ok ? 'healthy' : health.ok ? 'degraded' : 'offline'
|
||||
status = {
|
||||
level,
|
||||
health,
|
||||
readiness,
|
||||
checkedAt: new Date().toISOString(),
|
||||
loading: false,
|
||||
}
|
||||
} finally {
|
||||
requestInFlight = false
|
||||
if (status.loading) status = { ...status, loading: false }
|
||||
}
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
void refresh()
|
||||
const timer = window.setInterval(() => void refresh(), 15_000)
|
||||
return () => window.clearInterval(timer)
|
||||
})
|
||||
</script>
|
||||
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
aria-label="Service status"
|
||||
title={`Service status: ${status.level}`}
|
||||
onclick={() => (open = true)}
|
||||
>
|
||||
{#if status.loading && status.level === 'checking'}
|
||||
<LoaderCircle class="size-5 animate-spin text-muted-fg" />
|
||||
{:else if status.level === 'healthy'}
|
||||
<CheckCircle2 class="size-5 text-success" />
|
||||
{:else if status.level === 'degraded'}
|
||||
<AlertTriangle class="size-5 text-warning" />
|
||||
{:else if status.level === 'offline'}
|
||||
<AlertCircle class="size-5 text-danger" />
|
||||
{:else}
|
||||
<CircleHelp class="size-5 text-muted-fg" />
|
||||
{/if}
|
||||
</Button>
|
||||
|
||||
<StatusDialog bind:open {status} onRefresh={refresh} />
|
||||
@@ -3,7 +3,6 @@
|
||||
import { getAppConfig, getPanelForPath, getPathForPanel } from '$lib/app-config'
|
||||
import AnalyzerWorkspace from '$lib/features/AnalyzerWorkspace.svelte'
|
||||
import ConfigWorkspace from '$lib/features/ConfigWorkspace.svelte'
|
||||
import DesktopWorkspace from '$lib/features/DesktopWorkspace.svelte'
|
||||
import FeedWorkspace from '$lib/features/FeedWorkspace.svelte'
|
||||
import KioskWorkspace from '$lib/features/KioskWorkspace.svelte'
|
||||
import MediaTypePipeline from '$lib/features/MediaTypePipeline.svelte'
|
||||
@@ -82,6 +81,4 @@
|
||||
<KioskWorkspace {panel} />
|
||||
{:else if app.id === 'servant'}
|
||||
<ServantWorkspace {panel} />
|
||||
{:else}
|
||||
<DesktopWorkspace {panel} />
|
||||
{/if}
|
||||
@@ -1,32 +0,0 @@
|
||||
<script lang="ts">
|
||||
import type { HTMLAttributes } from 'svelte/elements'
|
||||
import { cn } from '$lib/utils/cn'
|
||||
|
||||
let {
|
||||
class: className,
|
||||
tone = 'neutral',
|
||||
children,
|
||||
...rest
|
||||
}: HTMLAttributes<HTMLSpanElement> & {
|
||||
tone?: 'neutral' | 'primary' | 'success' | 'warning' | 'danger'
|
||||
children?: import('svelte').Snippet
|
||||
} = $props()
|
||||
const toneClasses = {
|
||||
neutral: 'border-border bg-surface-hover text-muted-fg',
|
||||
primary: 'border-primary/30 bg-primary/15 text-primary',
|
||||
success: 'border-success/30 bg-success/15 text-success',
|
||||
warning: 'border-warning/30 bg-warning/15 text-warning',
|
||||
danger: 'border-danger/30 bg-danger/15 text-danger',
|
||||
}
|
||||
</script>
|
||||
|
||||
<span
|
||||
class={cn(
|
||||
'inline-flex items-center rounded-full border px-2 py-0.5 text-xs font-medium',
|
||||
toneClasses[tone],
|
||||
className,
|
||||
)}
|
||||
{...rest}
|
||||
>
|
||||
{@render children?.()}
|
||||
</span>
|
||||
@@ -1,43 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { cva, type VariantProps } from 'class-variance-authority'
|
||||
import type { HTMLButtonAttributes } from 'svelte/elements'
|
||||
import { cn } from '$lib/utils/cn'
|
||||
|
||||
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: 'border border-border bg-surface text-fg hover:bg-surface-hover',
|
||||
outline: 'border border-border bg-transparent text-fg hover:bg-surface-hover',
|
||||
ghost: 'text-fg hover:bg-surface-hover',
|
||||
danger: 'bg-danger text-danger-fg hover:opacity-90',
|
||||
success: 'bg-success text-success-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' },
|
||||
},
|
||||
)
|
||||
|
||||
type Variant = VariantProps<typeof buttonVariants>
|
||||
let {
|
||||
class: className,
|
||||
variant = 'default',
|
||||
size = 'default',
|
||||
type = 'button',
|
||||
children,
|
||||
...rest
|
||||
}: HTMLButtonAttributes & Variant & { children?: import('svelte').Snippet } = $props()
|
||||
</script>
|
||||
|
||||
<button {type} class={cn(buttonVariants({ variant, size }), className)} {...rest}>
|
||||
{@render children?.()}
|
||||
</button>
|
||||
@@ -1,14 +0,0 @@
|
||||
<script lang="ts">
|
||||
import type { HTMLAttributes } from 'svelte/elements'
|
||||
import { cn } from '$lib/utils/cn'
|
||||
|
||||
let {
|
||||
class: className,
|
||||
children,
|
||||
...rest
|
||||
}: HTMLAttributes<HTMLDivElement> & { children?: import('svelte').Snippet } = $props()
|
||||
</script>
|
||||
|
||||
<div class={cn('rounded-lg border border-border bg-surface p-4 shadow-sm', className)} {...rest}>
|
||||
{@render children?.()}
|
||||
</div>
|
||||
@@ -1,32 +0,0 @@
|
||||
<script lang="ts">
|
||||
import { cn } from '$lib/utils/cn'
|
||||
|
||||
let {
|
||||
label,
|
||||
value,
|
||||
detail = '',
|
||||
tone = 'default',
|
||||
}: {
|
||||
label: string
|
||||
value: string | number
|
||||
detail?: string
|
||||
tone?: 'default' | 'primary' | 'success' | 'warning' | 'danger'
|
||||
} = $props()
|
||||
</script>
|
||||
|
||||
<div class="rounded-lg border border-border bg-surface p-4">
|
||||
<p class="text-xs font-medium uppercase tracking-wider text-muted-fg">{label}</p>
|
||||
<p
|
||||
class={cn(
|
||||
'mt-2 text-2xl font-semibold tracking-tight',
|
||||
tone === 'primary' && 'text-primary',
|
||||
tone === 'success' && 'text-success',
|
||||
tone === 'warning' && 'text-warning',
|
||||
tone === 'danger' && 'text-danger',
|
||||
tone === 'default' && 'text-fg',
|
||||
)}
|
||||
>
|
||||
{value}
|
||||
</p>
|
||||
{#if detail}<p class="mt-1 text-xs text-muted-fg">{detail}</p>{/if}
|
||||
</div>
|
||||
Reference in new issue
Block a user