Extend shared UI component customization
Lint / Lint (Node/Svelte) (push) Successful in 23s
Lint / Lint (Go) (push) Successful in 16s
Lint / Lint (Python) (push) Successful in 9s
Tests / Test (Node/Svelte) (push) Successful in 14s
Tests / Test (Go) (push) Successful in 17s
Tests / Test (Python) (push) Successful in 9s
Lint / Lint (Node/Svelte) (push) Successful in 23s
Lint / Lint (Go) (push) Successful in 16s
Lint / Lint (Python) (push) Successful in 9s
Tests / Test (Node/Svelte) (push) Successful in 14s
Tests / Test (Go) (push) Successful in 17s
Tests / Test (Python) (push) Successful in 9s
This commit is contained in:
1 parent
c95865dbe2
commit
2f57554154
6 files changed
+41
-3
No files matched your search
@@ -9,8 +9,10 @@
|
||||
children,
|
||||
class: className = '',
|
||||
currentPath = '',
|
||||
headerActions,
|
||||
navItems = [],
|
||||
onLogout,
|
||||
onNavigate,
|
||||
onProfile,
|
||||
onSettings,
|
||||
showSettings = true,
|
||||
@@ -22,8 +24,10 @@
|
||||
children?: Snippet;
|
||||
class?: string;
|
||||
currentPath?: string;
|
||||
headerActions?: Snippet;
|
||||
navItems?: NavItem[];
|
||||
onLogout?: () => void | Promise<void>;
|
||||
onNavigate?: (item: NavItem) => void;
|
||||
onProfile?: () => void;
|
||||
onSettings?: () => void;
|
||||
showSettings?: boolean;
|
||||
@@ -37,8 +41,10 @@
|
||||
{brand}
|
||||
{brandHref}
|
||||
{currentPath}
|
||||
actions={headerActions}
|
||||
{navItems}
|
||||
{onLogout}
|
||||
{onNavigate}
|
||||
{onProfile}
|
||||
{onSettings}
|
||||
{showSettings}
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
<script lang="ts">
|
||||
import type { Snippet } from 'svelte';
|
||||
import type { AuthLoginInput, AuthSetupInput } from '../types';
|
||||
import Button from './Button.svelte';
|
||||
|
||||
let {
|
||||
brand = 'Application',
|
||||
children,
|
||||
error = '',
|
||||
loading = false,
|
||||
onLogin,
|
||||
@@ -12,6 +14,7 @@
|
||||
tagline = ''
|
||||
}: {
|
||||
brand?: string;
|
||||
children?: Snippet;
|
||||
error?: string;
|
||||
loading?: boolean;
|
||||
onLogin?: (input: AuthLoginInput) => void | Promise<void>;
|
||||
@@ -142,5 +145,9 @@
|
||||
{loading || submitting ? 'Please wait…' : setupRequired ? 'Create account' : 'Log in'}
|
||||
</Button>
|
||||
</form>
|
||||
|
||||
{#if children}
|
||||
<div class="sc-auth-extra">{@render children()}</div>
|
||||
{/if}
|
||||
</section>
|
||||
</div>
|
||||
@@ -1,4 +1,5 @@
|
||||
<script lang="ts">
|
||||
import type { Snippet } from 'svelte';
|
||||
import type { NavItem } from '../types';
|
||||
|
||||
let {
|
||||
@@ -6,7 +7,9 @@
|
||||
brandHref = '/',
|
||||
currentPath = '',
|
||||
navItems = [],
|
||||
actions,
|
||||
onLogout,
|
||||
onNavigate,
|
||||
onProfile,
|
||||
onSettings,
|
||||
showSettings = true,
|
||||
@@ -16,7 +19,9 @@
|
||||
brandHref?: string;
|
||||
currentPath?: string;
|
||||
navItems?: NavItem[];
|
||||
actions?: Snippet;
|
||||
onLogout?: () => void | Promise<void>;
|
||||
onNavigate?: (item: NavItem) => void;
|
||||
onProfile?: () => void;
|
||||
onSettings?: () => void;
|
||||
showSettings?: boolean;
|
||||
@@ -45,7 +50,13 @@
|
||||
class="sc-nav-link"
|
||||
data-active={isActive(item)}
|
||||
href={item.href}
|
||||
onclick={() => (navOpen = false)}
|
||||
onclick={(event) => {
|
||||
if (onNavigate) {
|
||||
event.preventDefault();
|
||||
onNavigate(item);
|
||||
}
|
||||
navOpen = false;
|
||||
}}
|
||||
>
|
||||
{item.label}
|
||||
</a>
|
||||
@@ -53,6 +64,8 @@
|
||||
</nav>
|
||||
|
||||
<div class="sc-header-actions">
|
||||
{#if actions}{@render actions()}{/if}
|
||||
|
||||
{#if showSettings && onSettings}
|
||||
<button aria-label="Open settings" class="sc-icon-button" type="button" onclick={onSettings}>⚙</button>
|
||||
{/if}
|
||||
|
||||
@@ -5,20 +5,24 @@
|
||||
actions,
|
||||
children,
|
||||
description = '',
|
||||
subtitle = '',
|
||||
title
|
||||
}: {
|
||||
actions?: Snippet;
|
||||
children?: Snippet;
|
||||
description?: string;
|
||||
subtitle?: string;
|
||||
title: string;
|
||||
} = $props();
|
||||
|
||||
const supportingText = $derived(description || subtitle);
|
||||
</script>
|
||||
|
||||
<div class="sc-page-header">
|
||||
<div>
|
||||
<h1>{title}</h1>
|
||||
{#if description}
|
||||
<p>{description}</p>
|
||||
{#if supportingText}
|
||||
<p>{supportingText}</p>
|
||||
{/if}
|
||||
{@render children?.()}
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user