Enhance web-ui components and styles with new features and dependencies
- Added @lucide/svelte as a dependency for icon support in various components. - Updated AboutDialog, AppShell, AuthPage, Header, SettingsDialog, and styles for improved functionality and UI consistency. - Introduced new props and state management for better user experience. - Refactored CSS for cleaner styling and improved layout.
This commit is contained in:
1 parent
ce6db8a457
commit
e3544617e1
9 files changed
+260
-43
No files matched your search
Generated
+11
-21
@@ -776,7 +776,6 @@
|
||||
"version": "0.3.13",
|
||||
"resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.13.tgz",
|
||||
"integrity": "sha512-2kkt/7niJ6MgEPxF0bYdQ6etZaA+fQvDcLKckhy1yIQOzaoKjBBjSj63/aLVjYE3qhRt5dvM+uUyfCg6UKCBbA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@jridgewell/sourcemap-codec": "^1.5.0",
|
||||
@@ -787,7 +786,6 @@
|
||||
"version": "2.3.5",
|
||||
"resolved": "https://registry.npmjs.org/@jridgewell/remapping/-/remapping-2.3.5.tgz",
|
||||
"integrity": "sha512-LI9u/+laYG4Ds1TDKSJW2YPrIlcVYOwi2fUC6xB43lueCjgxV4lffOCZCtYFiH6TNOX+tQKXx97T4IKHbhyHEQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@jridgewell/gen-mapping": "^0.3.5",
|
||||
@@ -798,7 +796,6 @@
|
||||
"version": "3.1.2",
|
||||
"resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz",
|
||||
"integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=6.0.0"
|
||||
@@ -808,20 +805,27 @@
|
||||
"version": "1.5.5",
|
||||
"resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz",
|
||||
"integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@jridgewell/trace-mapping": {
|
||||
"version": "0.3.31",
|
||||
"resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz",
|
||||
"integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@jridgewell/resolve-uri": "^3.1.0",
|
||||
"@jridgewell/sourcemap-codec": "^1.4.14"
|
||||
}
|
||||
},
|
||||
"node_modules/@lucide/svelte": {
|
||||
"version": "1.28.0",
|
||||
"resolved": "https://registry.npmjs.org/@lucide/svelte/-/svelte-1.28.0.tgz",
|
||||
"integrity": "sha512-C1Ge84KW2z4q44/WDIEo/2KC2jby5u6mSlta7q+p6g7u0ld8sC/w1fMBiSswF+4bxAl9jlzzaVTpp79qqkiy5g==",
|
||||
"license": "ISC",
|
||||
"peerDependencies": {
|
||||
"svelte": "^5"
|
||||
}
|
||||
},
|
||||
"node_modules/@manypkg/find-root": {
|
||||
"version": "1.1.0",
|
||||
"resolved": "https://registry.npmjs.org/@manypkg/find-root/-/find-root-1.1.0.tgz",
|
||||
@@ -1371,7 +1375,6 @@
|
||||
"version": "1.0.11",
|
||||
"resolved": "https://registry.npmjs.org/@sveltejs/acorn-typescript/-/acorn-typescript-1.0.11.tgz",
|
||||
"integrity": "sha512-LFuZUkjJ9iF7JZye/aG5XM0SFcQ5VyL0oVX4WJ9dc0Va3R3s0OauX1BESVCb+YN/ol8TAfqGDDAQsTG627Y5kw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"peerDependencies": {
|
||||
"acorn": "^8.9.0"
|
||||
@@ -1453,21 +1456,18 @@
|
||||
"version": "1.0.9",
|
||||
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.9.tgz",
|
||||
"integrity": "sha512-GhdPgy1el4/ImP05X05Uw4cw2/M93BCUmnEvWZNStlCzEKME4Fkk+YpoA5OiHNQmoS7Cafb8Xa3Pya8m1Qrzeg==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@types/trusted-types": {
|
||||
"version": "2.0.7",
|
||||
"resolved": "https://registry.npmjs.org/@types/trusted-types/-/trusted-types-2.0.7.tgz",
|
||||
"integrity": "sha512-ScaPdn1dQczgbl0QFTeTOmVHFULt394XJgOQNoyVhZ6r2vLnMLJfBPd53SB52T/3G36VI1/g2MZaX0cwDuXsfw==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/acorn": {
|
||||
"version": "8.18.0",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.18.0.tgz",
|
||||
"integrity": "sha512-lGq+9yr1/GuAWaVYIHRjvvySG5/4VfKIvC8EWxStPdcDh/Ka7FG3twP6v4d5BkravUilhIAsG4Qj83t02LWUPQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"acorn": "bin/acorn"
|
||||
@@ -1507,7 +1507,6 @@
|
||||
"version": "5.3.1",
|
||||
"resolved": "https://registry.npmjs.org/aria-query/-/aria-query-5.3.1.tgz",
|
||||
"integrity": "sha512-Z/ZeOgVl7bcSYZ/u/rh0fOpvEpq//LZmdbkXyc7syVzjPAhfOa9ebsdTSjEBDU4vs5nC98Kfduj1uFo0qyET3g==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
@@ -1527,7 +1526,6 @@
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-4.1.0.tgz",
|
||||
"integrity": "sha512-qIj0G9wZbMGNLjLmg1PT6v2mE9AH2zlnADJD/2tC6E00hgmhUOfEB6greHPAfLRSufHqROIUTkw6E+M3lH0PTQ==",
|
||||
"dev": true,
|
||||
"license": "Apache-2.0",
|
||||
"engines": {
|
||||
"node": ">= 0.4"
|
||||
@@ -1586,7 +1584,6 @@
|
||||
"version": "2.1.1",
|
||||
"resolved": "https://registry.npmjs.org/clsx/-/clsx-2.1.1.tgz",
|
||||
"integrity": "sha512-eYm0QWBtUrBWZWG0d386OGAw16Z995PiOVo2B7bjWSbHedGl5e0ZWaq65kOGgUSNesEIDkB9ISbTg/JK9dhCZA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=6"
|
||||
@@ -1638,7 +1635,6 @@
|
||||
"version": "5.9.0",
|
||||
"resolved": "https://registry.npmjs.org/devalue/-/devalue-5.9.0.tgz",
|
||||
"integrity": "sha512-RWrqdArjvPbsATEhOPUo6Wndc/iWnkWKlhIrdlF3zMMYo/c3CVtoaVAyLtWxz5h8nSlkHzxnzV2uLydPXmtF+A==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/dir-glob": {
|
||||
@@ -1715,7 +1711,6 @@
|
||||
"version": "1.2.2",
|
||||
"resolved": "https://registry.npmjs.org/esm-env/-/esm-env-1.2.2.tgz",
|
||||
"integrity": "sha512-Epxrv+Nr/CaL4ZcFGPJIYLWFom+YeV1DqMLHJoEd9SYRxNbaFruBwfEX/kkHUJf55j2+TUbmDcmuilbP1TmXHA==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/esprima": {
|
||||
@@ -1736,7 +1731,6 @@
|
||||
"version": "2.3.0",
|
||||
"resolved": "https://registry.npmjs.org/esrap/-/esrap-2.3.0.tgz",
|
||||
"integrity": "sha512-GQ/7RN8uOtEfNpzZzBMTzW9JBcX42oaSVtPzdF+6cEL8pqIL094iUpr9jzYGn4O4P/1S60dJ6izyT8F4LYARng==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@jridgewell/sourcemap-codec": "^1.4.15"
|
||||
@@ -1975,7 +1969,6 @@
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/is-reference/-/is-reference-3.0.3.tgz",
|
||||
"integrity": "sha512-ixkJoqQvAP88E6wLydLGGqCJsrFUnqoH6HnaczB8XmDH1oaWU+xxdptvikTgaEhtZ53Ky6YXiBuUI2WXLMCwjw==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@types/estree": "^1.0.6"
|
||||
@@ -2058,7 +2051,6 @@
|
||||
"version": "3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/locate-character/-/locate-character-3.0.0.tgz",
|
||||
"integrity": "sha512-SW13ws7BjaeJ6p7Q6CO2nchbYEc3X3J6WrmTTDto7yMPqVSZTUyY5Tjbid+Ab8gLnATtygYtiDIJGQRRn2ZOiA==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/locate-path": {
|
||||
@@ -2085,7 +2077,6 @@
|
||||
"version": "0.30.21",
|
||||
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz",
|
||||
"integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@jridgewell/sourcemap-codec": "^1.5.5"
|
||||
@@ -2821,7 +2812,6 @@
|
||||
"version": "5.56.8",
|
||||
"resolved": "https://registry.npmjs.org/svelte/-/svelte-5.56.8.tgz",
|
||||
"integrity": "sha512-PY8LOw7xP6c8IOiVqdo0sbbZVYhXRSfklOQLAUyGBKqjTX0wx/z4l/9J+PmBpmlLnxzEb1NqltxQ5/wZme/Cmg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@jridgewell/remapping": "^2.3.4",
|
||||
@@ -3108,7 +3098,6 @@
|
||||
"version": "1.1.4",
|
||||
"resolved": "https://registry.npmjs.org/zimmerframe/-/zimmerframe-1.1.4.tgz",
|
||||
"integrity": "sha512-B58NGBEoc8Y9MWWCQGl/gq9xBCe4IiKM0a2x7GZdQKOW5Exr8S1W24J6OgM1njK8xCRGvAJIL/MxXHf6SkmQKQ==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"packages/design-tokens": {
|
||||
@@ -3132,7 +3121,8 @@
|
||||
"version": "0.1.1",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@gabriel20xx/design-tokens": "0.1.1"
|
||||
"@gabriel20xx/design-tokens": "0.1.1",
|
||||
"@lucide/svelte": "1.28.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sveltejs/package": "^2.5.0",
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
"svelte": "^5.0.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@gabriel20xx/design-tokens": "0.1.1"
|
||||
"@gabriel20xx/design-tokens": "0.1.1",
|
||||
"@lucide/svelte": "1.28.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@sveltejs/package": "^2.5.0",
|
||||
|
||||
@@ -7,22 +7,37 @@
|
||||
brand = 'Application',
|
||||
children,
|
||||
description = '',
|
||||
icon,
|
||||
links = [],
|
||||
onClose,
|
||||
open = $bindable(false),
|
||||
version = ''
|
||||
}: {
|
||||
brand?: string;
|
||||
children?: Snippet;
|
||||
description?: string;
|
||||
icon?: Snippet;
|
||||
links?: AboutLink[];
|
||||
onClose?: () => void | Promise<void>;
|
||||
open?: boolean;
|
||||
version?: string;
|
||||
} = $props();
|
||||
|
||||
let wasOpen = false;
|
||||
|
||||
$effect(() => {
|
||||
if (wasOpen && !open) void onClose?.();
|
||||
wasOpen = open;
|
||||
});
|
||||
</script>
|
||||
|
||||
<Dialog bind:open title={`About ${brand}`}>
|
||||
<div class="sc-auth-brand">
|
||||
<span aria-hidden="true" class="sc-brand-mark">{brand.slice(0, 1).toUpperCase()}</span>
|
||||
{#if icon}
|
||||
{@render icon()}
|
||||
{:else}
|
||||
<span aria-hidden="true" class="sc-brand-mark">{brand.slice(0, 1).toUpperCase()}</span>
|
||||
{/if}
|
||||
<strong>{brand}</strong>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import type { Snippet } from 'svelte';
|
||||
import type { NavItem } from '../types';
|
||||
import Header from './Header.svelte';
|
||||
import PageHeader from './PageHeader.svelte';
|
||||
|
||||
let {
|
||||
brand = 'Application',
|
||||
@@ -15,9 +16,10 @@
|
||||
onNavigate,
|
||||
onProfile,
|
||||
onSettings,
|
||||
showPageHeader = true,
|
||||
showSettings = true,
|
||||
theme = 'dark',
|
||||
username = ''
|
||||
username = '',
|
||||
}: {
|
||||
brand?: string;
|
||||
brandHref?: string;
|
||||
@@ -30,10 +32,17 @@
|
||||
onNavigate?: (item: NavItem) => void;
|
||||
onProfile?: () => void;
|
||||
onSettings?: () => void;
|
||||
showPageHeader?: boolean;
|
||||
showSettings?: boolean;
|
||||
theme?: 'dark' | 'light' | 'system';
|
||||
username?: string;
|
||||
} = $props();
|
||||
|
||||
const activeNavItem = $derived(
|
||||
navItems.find((item) =>
|
||||
item.href === '/' ? currentPath === '/' : currentPath === item.href || currentPath.startsWith(`${item.href}/`),
|
||||
),
|
||||
);
|
||||
</script>
|
||||
|
||||
<div class={`sc-root sc-app-shell ${className}`} data-theme={theme === 'system' ? undefined : theme}>
|
||||
@@ -52,6 +61,13 @@
|
||||
/>
|
||||
|
||||
<main class="sc-main">
|
||||
{#if showPageHeader && activeNavItem?.href !== '/about'}
|
||||
<PageHeader
|
||||
title={activeNavItem?.label ?? brand}
|
||||
description={activeNavItem?.description ??
|
||||
`Explore the ${activeNavItem?.label?.toLowerCase() ?? 'application'} section.`}
|
||||
/>
|
||||
{/if}
|
||||
{@render children?.()}
|
||||
</main>
|
||||
</div>
|
||||
@@ -39,6 +39,7 @@
|
||||
let identifier = $state('');
|
||||
let password = $state('');
|
||||
let totpToken = $state('');
|
||||
let totpRequired = $state(false);
|
||||
let confirmPassword = $state('');
|
||||
let submitError = $state('');
|
||||
let submitting = $state(false);
|
||||
@@ -47,6 +48,17 @@
|
||||
let resetOpen = $state(false);
|
||||
let resetting = $state(false);
|
||||
|
||||
function isTotpChallenge(caught: unknown): boolean {
|
||||
if (!(caught instanceof Error)) return false;
|
||||
const message = caught.message.toLowerCase();
|
||||
return (
|
||||
message.includes('two-factor authentication code required') ||
|
||||
message.includes('multi-factor authentication code required') ||
|
||||
(message.includes('totp') && message.includes('required')) ||
|
||||
(message.includes('mfa') && message.includes('required'))
|
||||
);
|
||||
}
|
||||
|
||||
async function submit(event: SubmitEvent): Promise<void> {
|
||||
event.preventDefault();
|
||||
submitError = '';
|
||||
@@ -64,10 +76,23 @@
|
||||
await onSetup({ username, email, password });
|
||||
} else {
|
||||
if (!onLogin) throw new Error('The application has not configured its login handler.');
|
||||
if (totpRequired && !totpToken.trim()) {
|
||||
submitError = 'Enter the six-digit authenticator code to continue.';
|
||||
return;
|
||||
}
|
||||
await onLogin({ identifier, password, totpToken: totpToken.trim() });
|
||||
}
|
||||
} catch (caught) {
|
||||
submitError = caught instanceof Error ? caught.message : 'Authentication failed.';
|
||||
if (!setupRequired && showTotp && isTotpChallenge(caught)) {
|
||||
totpRequired = true;
|
||||
submitError = 'Enter the six-digit authenticator code to continue.';
|
||||
} else {
|
||||
if (!setupRequired) {
|
||||
totpRequired = false;
|
||||
totpToken = '';
|
||||
}
|
||||
submitError = caught instanceof Error ? caught.message : 'Authentication failed.';
|
||||
}
|
||||
} finally {
|
||||
submitting = false;
|
||||
}
|
||||
@@ -170,9 +195,9 @@
|
||||
/>
|
||||
</label>
|
||||
|
||||
{#if showTotp && !setupRequired}
|
||||
{#if showTotp && !setupRequired && totpRequired}
|
||||
<label class="sc-field">
|
||||
<span class="sc-label">Authenticator code <span class="sc-label-optional">(if enabled)</span></span>
|
||||
<span class="sc-label">Authenticator code</span>
|
||||
<input
|
||||
autocomplete="one-time-code"
|
||||
class="sc-input"
|
||||
|
||||
@@ -1,7 +1,95 @@
|
||||
<script lang="ts">
|
||||
import {
|
||||
Activity,
|
||||
Archive,
|
||||
BarChart3,
|
||||
Bot,
|
||||
Box,
|
||||
CircleAlert,
|
||||
CircleHelp,
|
||||
CircleUserRound,
|
||||
CloudDownload,
|
||||
Database,
|
||||
FileCog,
|
||||
FolderOpen,
|
||||
Gamepad2,
|
||||
GalleryHorizontalEnd,
|
||||
HardDrive,
|
||||
Image,
|
||||
Info,
|
||||
LayoutDashboard,
|
||||
ListVideo,
|
||||
Logs,
|
||||
Magnet,
|
||||
Map,
|
||||
MapPinned,
|
||||
MessageCircle,
|
||||
MonitorPlay,
|
||||
Play,
|
||||
Plug,
|
||||
RefreshCw,
|
||||
ScanSearch,
|
||||
ScrollText,
|
||||
Send,
|
||||
Server,
|
||||
Settings2,
|
||||
ShieldCheck,
|
||||
SlidersHorizontal,
|
||||
Sparkles,
|
||||
Tags,
|
||||
Upload,
|
||||
Users,
|
||||
WandSparkles,
|
||||
Workflow,
|
||||
Wrench,
|
||||
} from '@lucide/svelte';
|
||||
import type { Snippet } from 'svelte';
|
||||
import type { NavItem } from '../types';
|
||||
|
||||
const icons: Record<string, typeof LayoutDashboard> = {
|
||||
activity: Activity,
|
||||
archive: Archive,
|
||||
'bar-chart-3': BarChart3,
|
||||
bot: Bot,
|
||||
box: Box,
|
||||
'circle-alert': CircleAlert,
|
||||
'circle-help': CircleHelp,
|
||||
'cloud-download': CloudDownload,
|
||||
database: Database,
|
||||
'file-cog': FileCog,
|
||||
'folder-open': FolderOpen,
|
||||
gamepad: Gamepad2,
|
||||
'gallery-horizontal-end': GalleryHorizontalEnd,
|
||||
'hard-drive': HardDrive,
|
||||
image: Image,
|
||||
info: Info,
|
||||
'layout-dashboard': LayoutDashboard,
|
||||
'list-video': ListVideo,
|
||||
logs: Logs,
|
||||
magnet: Magnet,
|
||||
map: Map,
|
||||
'map-pinned': MapPinned,
|
||||
'message-circle': MessageCircle,
|
||||
'monitor-play': MonitorPlay,
|
||||
play: Play,
|
||||
plug: Plug,
|
||||
'refresh-cw': RefreshCw,
|
||||
'scan-search': ScanSearch,
|
||||
'scroll-text': ScrollText,
|
||||
send: Send,
|
||||
server: Server,
|
||||
'settings-2': Settings2,
|
||||
'shield-check': ShieldCheck,
|
||||
'sliders-horizontal': SlidersHorizontal,
|
||||
sparkles: Sparkles,
|
||||
tags: Tags,
|
||||
upload: Upload,
|
||||
users: Users,
|
||||
'wand-sparkles': WandSparkles,
|
||||
workflow: Workflow,
|
||||
wrench: Wrench,
|
||||
};
|
||||
|
||||
let {
|
||||
brand = 'Application',
|
||||
brandHref = '/',
|
||||
@@ -30,6 +118,10 @@
|
||||
|
||||
let navOpen = $state(false);
|
||||
|
||||
function iconFor(item: NavItem) {
|
||||
return icons[item.icon ?? 'layout-dashboard'] ?? LayoutDashboard;
|
||||
}
|
||||
|
||||
function isActive(item: NavItem): boolean {
|
||||
return item.href === '/'
|
||||
? currentPath === '/'
|
||||
@@ -45,6 +137,7 @@
|
||||
|
||||
<nav aria-label="Primary navigation" class="sc-nav" data-open={navOpen}>
|
||||
{#each navItems as item}
|
||||
{@const Icon = iconFor(item)}
|
||||
<a
|
||||
aria-current={isActive(item) ? 'page' : undefined}
|
||||
class="sc-nav-link"
|
||||
@@ -58,6 +151,7 @@
|
||||
navOpen = false;
|
||||
}}
|
||||
>
|
||||
<Icon aria-hidden="true" class="sc-nav-icon" size={16} strokeWidth={2} />
|
||||
{item.label}
|
||||
</a>
|
||||
{/each}
|
||||
@@ -71,7 +165,10 @@
|
||||
{/if}
|
||||
|
||||
{#if username && onProfile}
|
||||
<button class="sc-profile-button" type="button" onclick={onProfile}>{username}</button>
|
||||
<button class="sc-profile-button" type="button" onclick={onProfile}>
|
||||
<CircleUserRound aria-hidden="true" class="sc-profile-icon" size={16} strokeWidth={2} />
|
||||
<span>{username}</span>
|
||||
</button>
|
||||
{/if}
|
||||
|
||||
{#if onLogout}
|
||||
|
||||
@@ -16,8 +16,10 @@
|
||||
description = '',
|
||||
currentRole = 'user',
|
||||
currentUserId,
|
||||
loginRequired = true,
|
||||
onCreateUser,
|
||||
onDeleteUser,
|
||||
onLoginRequiredChange,
|
||||
onListUsers,
|
||||
onUpdateUser,
|
||||
open = $bindable(false),
|
||||
@@ -27,16 +29,54 @@
|
||||
description?: string;
|
||||
currentRole?: UserRole;
|
||||
currentUserId?: UserId;
|
||||
loginRequired?: boolean;
|
||||
onCreateUser?: UserCreateRequest;
|
||||
onDeleteUser?: UserDeleteRequest;
|
||||
onLoginRequiredChange?: (required: boolean) => void | Promise<void>;
|
||||
onListUsers?: UserListRequest;
|
||||
onUpdateUser?: UserUpdateRequest;
|
||||
open?: boolean;
|
||||
title?: string;
|
||||
} = $props();
|
||||
|
||||
let loginRequiredValue = $state<boolean>(true);
|
||||
let loginSettingError = $state('');
|
||||
|
||||
$effect(() => {
|
||||
loginRequiredValue = loginRequired;
|
||||
});
|
||||
|
||||
async function updateLoginRequired(required: boolean) {
|
||||
const previous = loginRequiredValue;
|
||||
loginRequiredValue = required;
|
||||
loginSettingError = '';
|
||||
try {
|
||||
await onLoginRequiredChange?.(required);
|
||||
} catch (error) {
|
||||
loginRequiredValue = previous;
|
||||
loginSettingError = error instanceof Error ? error.message : 'The setting could not be saved.';
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<Dialog bind:open {description} {title}>
|
||||
{#if currentRole === 'admin' || currentRole === 'superadmin'}
|
||||
<div class="sc-field">
|
||||
<label class="flex items-center gap-3">
|
||||
<input
|
||||
class="size-4 accent-primary"
|
||||
type="checkbox"
|
||||
checked={loginRequiredValue}
|
||||
onchange={(event) => updateLoginRequired((event.currentTarget as HTMLInputElement).checked)}
|
||||
/>
|
||||
<span>
|
||||
<span class="block font-medium">Require login to access app</span>
|
||||
<span class="sc-muted">Admins and superadmins can change this setting.</span>
|
||||
</span>
|
||||
</label>
|
||||
{#if loginSettingError}<p class="sc-error" role="alert">{loginSettingError}</p>{/if}
|
||||
</div>
|
||||
{/if}
|
||||
{#if children}
|
||||
{@render children()}
|
||||
{:else}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
@import '@gabriel20xx/design-tokens/theme.css';
|
||||
@import "@gabriel20xx/design-tokens/theme.css";
|
||||
|
||||
:where(.sc-root, .sc-root *) {
|
||||
box-sizing: border-box;
|
||||
@@ -85,7 +85,17 @@
|
||||
.sc-icon-button {
|
||||
border: 1px solid transparent;
|
||||
border-radius: var(--sc-radius-md);
|
||||
transition: color 140ms ease, background 140ms ease, border-color 140ms ease;
|
||||
transition:
|
||||
color 140ms ease,
|
||||
background 140ms ease,
|
||||
border-color 140ms ease;
|
||||
}
|
||||
|
||||
.sc-nav-link,
|
||||
.sc-profile-button {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 0.4rem;
|
||||
}
|
||||
|
||||
.sc-nav-link {
|
||||
@@ -96,7 +106,7 @@
|
||||
}
|
||||
|
||||
.sc-nav-link:hover,
|
||||
.sc-nav-link[data-active='true'] {
|
||||
.sc-nav-link[data-active="true"] {
|
||||
color: var(--sc-fg);
|
||||
background: var(--sc-surface-hover);
|
||||
border-color: var(--sc-border);
|
||||
@@ -146,6 +156,11 @@
|
||||
justify-content: space-between;
|
||||
gap: 1rem;
|
||||
margin-bottom: 1.5rem;
|
||||
padding: 1rem 1.25rem;
|
||||
background: var(--sc-surface);
|
||||
border: 1px solid var(--sc-border);
|
||||
border-radius: var(--sc-radius-lg);
|
||||
box-shadow: var(--sc-shadow-sm);
|
||||
}
|
||||
|
||||
.sc-page-header h1,
|
||||
@@ -209,19 +224,19 @@
|
||||
font-weight: 650;
|
||||
}
|
||||
|
||||
.sc-badge[data-variant='success'] {
|
||||
.sc-badge[data-variant="success"] {
|
||||
color: var(--sc-success-fg);
|
||||
background: var(--sc-success);
|
||||
border-color: transparent;
|
||||
}
|
||||
|
||||
.sc-badge[data-variant='warning'] {
|
||||
.sc-badge[data-variant="warning"] {
|
||||
color: var(--sc-warning-fg);
|
||||
background: var(--sc-warning);
|
||||
border-color: transparent;
|
||||
}
|
||||
|
||||
.sc-badge[data-variant='danger'] {
|
||||
.sc-badge[data-variant="danger"] {
|
||||
color: var(--sc-danger-fg);
|
||||
background: var(--sc-danger);
|
||||
border-color: transparent;
|
||||
@@ -240,7 +255,11 @@
|
||||
font-weight: 650;
|
||||
line-height: 1;
|
||||
cursor: pointer;
|
||||
transition: color 140ms ease, background 140ms ease, border-color 140ms ease, opacity 140ms ease;
|
||||
transition:
|
||||
color 140ms ease,
|
||||
background 140ms ease,
|
||||
border-color 140ms ease,
|
||||
opacity 140ms ease;
|
||||
}
|
||||
|
||||
.sc-button:hover:not(:disabled) {
|
||||
@@ -406,7 +425,9 @@
|
||||
border: 1px solid var(--sc-border);
|
||||
border-radius: var(--sc-radius-md);
|
||||
outline: none;
|
||||
transition: border-color 140ms ease, box-shadow 140ms ease;
|
||||
transition:
|
||||
border-color 140ms ease,
|
||||
box-shadow 140ms ease;
|
||||
}
|
||||
|
||||
.sc-textarea {
|
||||
@@ -558,7 +579,11 @@
|
||||
padding: 1.5rem;
|
||||
color: var(--sc-fg);
|
||||
background:
|
||||
radial-gradient(circle at 15% 10%, color-mix(in srgb, var(--sc-primary) 18%, transparent), transparent 35%),
|
||||
radial-gradient(
|
||||
circle at 15% 10%,
|
||||
color-mix(in srgb, var(--sc-primary) 18%, transparent),
|
||||
transparent 35%
|
||||
),
|
||||
var(--sc-bg);
|
||||
}
|
||||
|
||||
@@ -744,7 +769,7 @@
|
||||
padding-bottom: 0.25rem;
|
||||
}
|
||||
|
||||
.sc-nav[data-open='true'] {
|
||||
.sc-nav[data-open="true"] {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,10 +1,12 @@
|
||||
import type { Snippet } from 'svelte';
|
||||
import type { Snippet } from "svelte";
|
||||
|
||||
export type AsyncAction<T = void> = (value: T) => void | Promise<void>;
|
||||
|
||||
export interface NavItem {
|
||||
href: string;
|
||||
label: string;
|
||||
icon?: string;
|
||||
description?: string;
|
||||
}
|
||||
|
||||
export interface AuthSetupInput {
|
||||
@@ -27,7 +29,8 @@ export interface TotpSetupResponse {
|
||||
|
||||
export type TotpStatusRequest = () => boolean | Promise<boolean>;
|
||||
|
||||
export type TotpSetupRequest = () => TotpSetupResponse | Promise<TotpSetupResponse>;
|
||||
export type TotpSetupRequest = () =>
|
||||
TotpSetupResponse | Promise<TotpSetupResponse>;
|
||||
|
||||
export type TotpTokenAction = (token: string) => void | Promise<void>;
|
||||
|
||||
@@ -41,7 +44,7 @@ export interface ProfileUpdateInput {
|
||||
password?: string;
|
||||
}
|
||||
|
||||
export type UserRole = 'superadmin' | 'admin' | 'user';
|
||||
export type UserRole = "superadmin" | "admin" | "user";
|
||||
|
||||
export type UserId = string | number;
|
||||
|
||||
@@ -71,9 +74,14 @@ export interface UserUpdateInput {
|
||||
|
||||
export type UserListRequest = () => ManagedUser[] | Promise<ManagedUser[]>;
|
||||
|
||||
export type UserCreateRequest = (input: UserCreateInput) => void | Promise<void | ManagedUser>;
|
||||
export type UserCreateRequest = (
|
||||
input: UserCreateInput,
|
||||
) => void | Promise<void | ManagedUser>;
|
||||
|
||||
export type UserUpdateRequest = (id: UserId, input: UserUpdateInput) => void | Promise<void | ManagedUser>;
|
||||
export type UserUpdateRequest = (
|
||||
id: UserId,
|
||||
input: UserUpdateInput,
|
||||
) => void | Promise<void | ManagedUser>;
|
||||
|
||||
export type UserDeleteRequest = (id: UserId) => void | Promise<void>;
|
||||
|
||||
|
||||
Reference in new issue
Block a user