dssoca 0.5.0 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Accordion.svelte +281 -0
- package/dist/components/Accordion.svelte.d.ts +47 -0
- package/dist/components/Badge.svelte +115 -18
- package/dist/components/Badge.svelte.d.ts +28 -2
- package/dist/components/BottomNav.svelte +216 -0
- package/dist/components/BottomNav.svelte.d.ts +30 -0
- package/dist/components/Button.svelte +147 -10
- package/dist/components/Button.svelte.d.ts +21 -4
- package/dist/components/Card.svelte +167 -8
- package/dist/components/Card.svelte.d.ts +16 -1
- package/dist/components/EmptyState.svelte +85 -9
- package/dist/components/EmptyState.svelte.d.ts +14 -3
- package/dist/components/Icon.svelte +179 -13
- package/dist/components/Icon.svelte.d.ts +63 -2
- package/dist/components/Image.svelte +430 -0
- package/dist/components/Image.svelte.d.ts +49 -0
- package/dist/components/Input.svelte +174 -39
- package/dist/components/Input.svelte.d.ts +22 -0
- package/dist/components/Link.svelte +148 -0
- package/dist/components/Link.svelte.d.ts +22 -0
- package/dist/components/LogStream.svelte +378 -37
- package/dist/components/LogStream.svelte.d.ts +35 -7
- package/dist/components/Menu.svelte +355 -0
- package/dist/components/Menu.svelte.d.ts +46 -0
- package/dist/components/MetricTile.svelte +124 -12
- package/dist/components/MetricTile.svelte.d.ts +20 -0
- package/dist/components/SegmentedControl.svelte +208 -0
- package/dist/components/SegmentedControl.svelte.d.ts +30 -0
- package/dist/components/ServiceCard.svelte +222 -26
- package/dist/components/ServiceCard.svelte.d.ts +13 -1
- package/dist/components/Sidebar.svelte +340 -29
- package/dist/components/Sidebar.svelte.d.ts +18 -7
- package/dist/components/Sparkline.svelte +196 -13
- package/dist/components/Sparkline.svelte.d.ts +20 -1
- package/dist/components/Toaster.svelte +193 -12
- package/dist/components/Toaster.svelte.d.ts +3 -0
- package/dist/components/Topbar.svelte +152 -21
- package/dist/components/Topbar.svelte.d.ts +20 -0
- package/dist/dssoca.config.d.ts +1 -1
- package/dist/dssoca.config.js +6 -0
- package/dist/index.d.ts +10 -3
- package/dist/index.js +12 -2
- package/dist/theme.css +242 -0
- package/dist/toast.svelte.d.ts +49 -5
- package/dist/toast.svelte.js +165 -9
- package/package.json +1 -1
|
@@ -1,19 +1,50 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte'
|
|
2
3
|
import { resolveComponentSize, type Size } from '../config.js'
|
|
3
4
|
|
|
5
|
+
interface Stat { key: string; value: string; title?: string }
|
|
6
|
+
|
|
4
7
|
interface Props {
|
|
5
8
|
active?: string
|
|
6
9
|
user?: string
|
|
7
10
|
tabs?: string[]
|
|
8
11
|
onTab?: (tab: string) => void
|
|
12
|
+
/** Fired when the command menu is opened (chip click or Cmd/Ctrl+K). */
|
|
13
|
+
onCommand?: () => void
|
|
14
|
+
/** Fired when the user chip is activated (when no `userMenu` snippet given). */
|
|
15
|
+
onUser?: () => void
|
|
16
|
+
/** Custom user/avatar control rendered on the right; overrides the default user button. */
|
|
17
|
+
userMenu?: Snippet
|
|
18
|
+
/** Custom brand mark + name; defaults to the built-in logo. */
|
|
19
|
+
brand?: Snippet
|
|
20
|
+
/** Right-aligned stat segments; defaults to the built-in homelab stats. */
|
|
21
|
+
stats?: Stat[]
|
|
22
|
+
/** Anchor the skip link jumps to. */
|
|
23
|
+
skipTarget?: string
|
|
24
|
+
/** When true, the header sticks to the top of the viewport. */
|
|
25
|
+
sticky?: boolean
|
|
9
26
|
/** Token size (sm|md|lg); inherits the global size when unset. */
|
|
10
27
|
size?: Size
|
|
11
28
|
}
|
|
29
|
+
|
|
30
|
+
const DEFAULT_STATS: Stat[] = [
|
|
31
|
+
{ key: 'cpu', value: '62%', title: 'cpu' },
|
|
32
|
+
{ key: 'mem', value: '3.8G', title: 'memory' },
|
|
33
|
+
{ key: 'net', value: '↓1.2 ↑0.3', title: 'network' },
|
|
34
|
+
]
|
|
35
|
+
|
|
12
36
|
let {
|
|
13
37
|
active = 'overview',
|
|
14
|
-
user = '
|
|
38
|
+
user = 'admin@hub.home',
|
|
15
39
|
tabs = ['overview', 'services', 'logs', 'shell'],
|
|
16
40
|
onTab,
|
|
41
|
+
onCommand,
|
|
42
|
+
onUser,
|
|
43
|
+
userMenu,
|
|
44
|
+
brand,
|
|
45
|
+
stats = DEFAULT_STATS,
|
|
46
|
+
skipTarget = '#main',
|
|
47
|
+
sticky = true,
|
|
17
48
|
size,
|
|
18
49
|
}: Props = $props()
|
|
19
50
|
|
|
@@ -24,50 +55,108 @@
|
|
|
24
55
|
}
|
|
25
56
|
|
|
26
57
|
let clock = $state(nowStr())
|
|
58
|
+
|
|
27
59
|
$effect(() => {
|
|
28
60
|
const t = setInterval(() => { clock = nowStr() }, 1000)
|
|
29
|
-
|
|
61
|
+
const onKey = (e: KeyboardEvent) => {
|
|
62
|
+
if ((e.metaKey || e.ctrlKey) && (e.key === 'k' || e.key === 'K')) {
|
|
63
|
+
e.preventDefault()
|
|
64
|
+
onCommand?.()
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
window.addEventListener('keydown', onKey)
|
|
68
|
+
return () => {
|
|
69
|
+
clearInterval(t)
|
|
70
|
+
window.removeEventListener('keydown', onKey)
|
|
71
|
+
}
|
|
30
72
|
})
|
|
31
73
|
|
|
32
74
|
const [h, m, s] = $derived(clock.split(':'))
|
|
75
|
+
|
|
76
|
+
// Roving tabindex: arrow keys move focus across the tab strip (wrapping),
|
|
77
|
+
// Home/End jump to the ends. The active tab is the single tab stop.
|
|
78
|
+
let tabEls: HTMLButtonElement[] = $state([])
|
|
79
|
+
function focusTab(i: number) {
|
|
80
|
+
const n = tabs.length
|
|
81
|
+
if (!n) return
|
|
82
|
+
const idx = ((i % n) + n) % n
|
|
83
|
+
tabEls[idx]?.focus()
|
|
84
|
+
}
|
|
85
|
+
function onTabKeydown(e: KeyboardEvent, i: number) {
|
|
86
|
+
switch (e.key) {
|
|
87
|
+
case 'ArrowRight': case 'ArrowDown': e.preventDefault(); focusTab(i + 1); break
|
|
88
|
+
case 'ArrowLeft': case 'ArrowUp': e.preventDefault(); focusTab(i - 1); break
|
|
89
|
+
case 'Home': e.preventDefault(); focusTab(0); break
|
|
90
|
+
case 'End': e.preventDefault(); focusTab(tabs.length - 1); break
|
|
91
|
+
}
|
|
92
|
+
}
|
|
33
93
|
</script>
|
|
34
94
|
|
|
35
|
-
<
|
|
95
|
+
<header class="ss-topbar" class:sticky data-size-variant={resolveComponentSize('Topbar', size)}>
|
|
96
|
+
<a class="skip" href={skipTarget}>Skip to content</a>
|
|
97
|
+
|
|
36
98
|
<div class="seg logo">
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
99
|
+
{#if brand}
|
|
100
|
+
{@render brand()}
|
|
101
|
+
{:else}
|
|
102
|
+
<svg class="mark" viewBox="0 0 103 89" fill="var(--ss-primary)" width="14" height="14" aria-hidden="true">
|
|
103
|
+
<path
|
|
104
|
+
fill-rule="evenodd"
|
|
105
|
+
clip-rule="evenodd"
|
|
106
|
+
d="M51.5 0L0 89H103L51.5 0ZM23.8643 80.151H87.6468L71.6884 52.5724L23.8643 80.151ZM65.5911 42.0354L60.7383 33.649L46.1956 42.0354H65.5911ZM56.14 25.7024L51.5 17.6837L42.2125 33.7339L56.14 25.7024ZM32.0977 51.2138L20.2949 71.6111L55.6656 51.2138H32.0977Z"
|
|
107
|
+
/>
|
|
108
|
+
</svg>
|
|
109
|
+
<span class="nm">hubssoca</span>
|
|
110
|
+
{/if}
|
|
45
111
|
</div>
|
|
46
|
-
|
|
47
|
-
|
|
112
|
+
|
|
113
|
+
<nav class="ws" aria-label="Primary">
|
|
114
|
+
{#each tabs as tab, i (tab)}
|
|
48
115
|
<button
|
|
116
|
+
bind:this={tabEls[i]}
|
|
49
117
|
class="tab {tab === active ? 'active' : ''}"
|
|
50
118
|
aria-current={tab === active ? 'page' : undefined}
|
|
119
|
+
tabindex={tab === active ? 0 : -1}
|
|
51
120
|
onclick={() => onTab?.(tab)}
|
|
121
|
+
onkeydown={(e) => onTabKeydown(e, i)}
|
|
52
122
|
>
|
|
53
123
|
<span class="n" aria-hidden="true">{i + 1}</span>{tab}
|
|
54
124
|
</button>
|
|
55
125
|
{/each}
|
|
56
|
-
</
|
|
126
|
+
</nav>
|
|
127
|
+
|
|
57
128
|
<div class="grow"></div>
|
|
129
|
+
|
|
58
130
|
<div class="seg right" title="services">
|
|
59
131
|
<span class="dot" aria-hidden="true"></span>
|
|
60
132
|
<span class="stat"><span class="v">6</span><span class="k">/7 up</span></span>
|
|
61
133
|
</div>
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
134
|
+
|
|
135
|
+
{#each stats as st (st.key)}
|
|
136
|
+
<div class="seg right stat collapsible" title={st.title ?? st.key}>
|
|
137
|
+
<span class="k">{st.key}</span><span class="v">{st.value}</span>
|
|
138
|
+
</div>
|
|
139
|
+
{/each}
|
|
140
|
+
|
|
141
|
+
<button
|
|
142
|
+
class="seg right click cmd"
|
|
143
|
+
aria-keyshortcuts="Meta+K Control+K"
|
|
144
|
+
aria-label="Open command menu"
|
|
145
|
+
onclick={() => onCommand?.()}
|
|
146
|
+
>
|
|
147
|
+
<span class="kbd" aria-hidden="true">⌘K</span>
|
|
148
|
+
</button>
|
|
149
|
+
|
|
150
|
+
{#if userMenu}
|
|
151
|
+
<div class="seg right user-slot">{@render userMenu()}</div>
|
|
152
|
+
{:else}
|
|
153
|
+
<button class="seg right click user-btn" onclick={() => onUser?.()}>{user}</button>
|
|
154
|
+
{/if}
|
|
155
|
+
|
|
67
156
|
<div class="seg right clock">
|
|
68
157
|
<span>{h}</span><span class="sep">:</span><span>{m}</span><span class="sep">:</span><span>{s}</span>
|
|
69
158
|
</div>
|
|
70
|
-
</
|
|
159
|
+
</header>
|
|
71
160
|
|
|
72
161
|
<style>.ss-topbar {
|
|
73
162
|
grid-column: 1/-1;
|
|
@@ -79,10 +168,29 @@
|
|
|
79
168
|
font-size: var(--ss-ui-md);
|
|
80
169
|
color: var(--ss-fg-muted);
|
|
81
170
|
user-select: none;
|
|
82
|
-
position:
|
|
171
|
+
position: relative;
|
|
83
172
|
top: 0;
|
|
84
173
|
z-index: 10;
|
|
85
174
|
}
|
|
175
|
+
.ss-topbar.sticky {
|
|
176
|
+
position: sticky;
|
|
177
|
+
}
|
|
178
|
+
.ss-topbar .skip {
|
|
179
|
+
position: absolute;
|
|
180
|
+
left: var(--ss-s-1);
|
|
181
|
+
top: var(--ss-s-1);
|
|
182
|
+
z-index: 20;
|
|
183
|
+
padding: var(--ss-badge-py) var(--ss-badge-px);
|
|
184
|
+
background: var(--ss-primary);
|
|
185
|
+
color: var(--ss-fg-on-primary);
|
|
186
|
+
font: 500 var(--ss-ui-md) var(--ss-font-mono);
|
|
187
|
+
text-decoration: none;
|
|
188
|
+
transform: translateY(-200%);
|
|
189
|
+
transition: transform var(--ss-dur-fast) var(--ss-ease);
|
|
190
|
+
}
|
|
191
|
+
.ss-topbar .skip:focus-visible, .ss-topbar .skip:focus {
|
|
192
|
+
transform: translateY(0);
|
|
193
|
+
}
|
|
86
194
|
.ss-topbar .seg {
|
|
87
195
|
display: flex;
|
|
88
196
|
align-items: center;
|
|
@@ -102,6 +210,18 @@
|
|
|
102
210
|
background: var(--ss-hover);
|
|
103
211
|
color: var(--ss-fg);
|
|
104
212
|
}
|
|
213
|
+
.ss-topbar button.seg {
|
|
214
|
+
background: transparent;
|
|
215
|
+
border-top: 0;
|
|
216
|
+
border-bottom: 0;
|
|
217
|
+
border-right: 0;
|
|
218
|
+
color: inherit;
|
|
219
|
+
font: inherit;
|
|
220
|
+
min-height: var(--ss-s-6);
|
|
221
|
+
}
|
|
222
|
+
.ss-topbar button.seg.right {
|
|
223
|
+
border-left: 1px solid var(--ss-line);
|
|
224
|
+
}
|
|
105
225
|
.ss-topbar .logo {
|
|
106
226
|
color: var(--ss-fg);
|
|
107
227
|
}
|
|
@@ -122,6 +242,7 @@
|
|
|
122
242
|
display: flex;
|
|
123
243
|
align-items: center;
|
|
124
244
|
padding: 0 var(--ss-row-px);
|
|
245
|
+
min-height: var(--ss-s-6);
|
|
125
246
|
color: var(--ss-fg-faint);
|
|
126
247
|
border-right: 1px solid var(--ss-line);
|
|
127
248
|
cursor: pointer;
|
|
@@ -182,4 +303,14 @@
|
|
|
182
303
|
border: 1px solid var(--ss-line);
|
|
183
304
|
padding: 2px 5px;
|
|
184
305
|
line-height: 1;
|
|
306
|
+
}
|
|
307
|
+
@media (max-width: 720px) {
|
|
308
|
+
.ss-topbar .collapsible {
|
|
309
|
+
display: none;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
@media (max-width: 520px) {
|
|
313
|
+
.ss-topbar .ws {
|
|
314
|
+
display: none;
|
|
315
|
+
}
|
|
185
316
|
}</style>
|
|
@@ -1,9 +1,29 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
1
2
|
import { type Size } from '../config.js';
|
|
3
|
+
interface Stat {
|
|
4
|
+
key: string;
|
|
5
|
+
value: string;
|
|
6
|
+
title?: string;
|
|
7
|
+
}
|
|
2
8
|
interface Props {
|
|
3
9
|
active?: string;
|
|
4
10
|
user?: string;
|
|
5
11
|
tabs?: string[];
|
|
6
12
|
onTab?: (tab: string) => void;
|
|
13
|
+
/** Fired when the command menu is opened (chip click or Cmd/Ctrl+K). */
|
|
14
|
+
onCommand?: () => void;
|
|
15
|
+
/** Fired when the user chip is activated (when no `userMenu` snippet given). */
|
|
16
|
+
onUser?: () => void;
|
|
17
|
+
/** Custom user/avatar control rendered on the right; overrides the default user button. */
|
|
18
|
+
userMenu?: Snippet;
|
|
19
|
+
/** Custom brand mark + name; defaults to the built-in logo. */
|
|
20
|
+
brand?: Snippet;
|
|
21
|
+
/** Right-aligned stat segments; defaults to the built-in homelab stats. */
|
|
22
|
+
stats?: Stat[];
|
|
23
|
+
/** Anchor the skip link jumps to. */
|
|
24
|
+
skipTarget?: string;
|
|
25
|
+
/** When true, the header sticks to the top of the viewport. */
|
|
26
|
+
sticky?: boolean;
|
|
7
27
|
/** Token size (sm|md|lg); inherits the global size when unset. */
|
|
8
28
|
size?: Size;
|
|
9
29
|
}
|
package/dist/dssoca.config.d.ts
CHANGED
|
@@ -44,7 +44,7 @@ export type ColorTheme = (typeof dssocaConfig)['theme']['values'][number];
|
|
|
44
44
|
/** Size axis values — derived from the manifest (`'sm' | 'md' | 'lg'`). */
|
|
45
45
|
export type Size = (typeof dssocaConfig)['size']['values'][number];
|
|
46
46
|
/** Names of the components that accept a `size` prop / `componentsSize` entry. */
|
|
47
|
-
export declare const COMPONENT_NAMES: readonly ["Badge", "Button", "Card", "EmptyState", "Icon", "Input", "LogStream", "MetricTile", "ServiceCard", "Sidebar", "Sparkline", "Toaster", "Topbar"];
|
|
47
|
+
export declare const COMPONENT_NAMES: readonly ["Accordion", "Badge", "BottomNav", "Button", "Card", "EmptyState", "Icon", "Image", "Input", "Link", "LogStream", "Menu", "MetricTile", "SegmentedControl", "ServiceCard", "Sidebar", "Sparkline", "Toaster", "Topbar"];
|
|
48
48
|
export type ComponentName = (typeof COMPONENT_NAMES)[number];
|
|
49
49
|
/** Per-component default sizes; any omitted component inherits `sizeVariant`. */
|
|
50
50
|
export type ComponentsSize = Partial<Record<ComponentName, Size>>;
|
package/dist/dssoca.config.js
CHANGED
|
@@ -23,14 +23,20 @@ export const dssocaConfig = {
|
|
|
23
23
|
};
|
|
24
24
|
/** Names of the components that accept a `size` prop / `componentsSize` entry. */
|
|
25
25
|
export const COMPONENT_NAMES = [
|
|
26
|
+
'Accordion',
|
|
26
27
|
'Badge',
|
|
28
|
+
'BottomNav',
|
|
27
29
|
'Button',
|
|
28
30
|
'Card',
|
|
29
31
|
'EmptyState',
|
|
30
32
|
'Icon',
|
|
33
|
+
'Image',
|
|
31
34
|
'Input',
|
|
35
|
+
'Link',
|
|
32
36
|
'LogStream',
|
|
37
|
+
'Menu',
|
|
33
38
|
'MetricTile',
|
|
39
|
+
'SegmentedControl',
|
|
34
40
|
'ServiceCard',
|
|
35
41
|
'Sidebar',
|
|
36
42
|
'Sparkline',
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { type ColorTheme, type Size, type DesignConfig, defaultDesignConfig, getDesignConfig, designAttributes, applyDesignConfig, resolveComponentSize, } from './config.js';
|
|
2
2
|
export { dssocaConfig, type DssocaConfig, type DesignAxis, type ComponentName, type ComponentsSize, } from './dssoca.config.js';
|
|
3
|
-
export { default as Icon } from './components/Icon.svelte';
|
|
3
|
+
export { default as Icon, registerIcon, type IconName } from './components/Icon.svelte';
|
|
4
4
|
export { default as Badge } from './components/Badge.svelte';
|
|
5
5
|
export { default as Button } from './components/Button.svelte';
|
|
6
6
|
export { default as Input } from './components/Input.svelte';
|
|
@@ -10,7 +10,14 @@ export { default as ServiceCard } from './components/ServiceCard.svelte';
|
|
|
10
10
|
export { default as MetricTile } from './components/MetricTile.svelte';
|
|
11
11
|
export { default as Topbar } from './components/Topbar.svelte';
|
|
12
12
|
export { default as Sidebar } from './components/Sidebar.svelte';
|
|
13
|
-
export {
|
|
13
|
+
export { type SideItem, type SideGroup, type SideStatus } from './components/Sidebar.svelte';
|
|
14
|
+
export { default as LogStream, type LogLevel, type LogLine } from './components/LogStream.svelte';
|
|
14
15
|
export { default as Toaster } from './components/Toaster.svelte';
|
|
15
16
|
export { default as EmptyState } from './components/EmptyState.svelte';
|
|
16
|
-
export {
|
|
17
|
+
export { default as Menu, type MenuItem } from './components/Menu.svelte';
|
|
18
|
+
export { default as Accordion, type AccordionItem } from './components/Accordion.svelte';
|
|
19
|
+
export { default as Link } from './components/Link.svelte';
|
|
20
|
+
export { default as SegmentedControl, type SegmentOption } from './components/SegmentedControl.svelte';
|
|
21
|
+
export { default as BottomNav, type BottomNavItem } from './components/BottomNav.svelte';
|
|
22
|
+
export { default as Image, type ImageSource } from './components/Image.svelte';
|
|
23
|
+
export { toast, toasts, type Toast, type ToastKind, type ToastAction, type ToastOptions, type ToastPatch, type PromiseMessages, } from './toast.svelte.js';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { defaultDesignConfig, getDesignConfig, designAttributes, applyDesignConfig, resolveComponentSize, } from './config.js';
|
|
2
2
|
export { dssocaConfig, } from './dssoca.config.js';
|
|
3
|
-
export { default as Icon } from './components/Icon.svelte';
|
|
3
|
+
export { default as Icon, registerIcon } from './components/Icon.svelte';
|
|
4
4
|
export { default as Badge } from './components/Badge.svelte';
|
|
5
5
|
export { default as Button } from './components/Button.svelte';
|
|
6
6
|
export { default as Input } from './components/Input.svelte';
|
|
@@ -10,7 +10,17 @@ export { default as ServiceCard } from './components/ServiceCard.svelte';
|
|
|
10
10
|
export { default as MetricTile } from './components/MetricTile.svelte';
|
|
11
11
|
export { default as Topbar } from './components/Topbar.svelte';
|
|
12
12
|
export { default as Sidebar } from './components/Sidebar.svelte';
|
|
13
|
+
export {} from './components/Sidebar.svelte';
|
|
13
14
|
export { default as LogStream } from './components/LogStream.svelte';
|
|
14
15
|
export { default as Toaster } from './components/Toaster.svelte';
|
|
15
16
|
export { default as EmptyState } from './components/EmptyState.svelte';
|
|
16
|
-
|
|
17
|
+
// New components ported from the source website (DS-0043). Each line is the
|
|
18
|
+
// single, complete public surface for that component, so the per-component
|
|
19
|
+
// implementation PRs (DS-0050…0055) need not edit this barrel.
|
|
20
|
+
export { default as Menu } from './components/Menu.svelte';
|
|
21
|
+
export { default as Accordion } from './components/Accordion.svelte';
|
|
22
|
+
export { default as Link } from './components/Link.svelte';
|
|
23
|
+
export { default as SegmentedControl } from './components/SegmentedControl.svelte';
|
|
24
|
+
export { default as BottomNav } from './components/BottomNav.svelte';
|
|
25
|
+
export { default as Image } from './components/Image.svelte';
|
|
26
|
+
export { toast, toasts, } from './toast.svelte.js';
|