dssoca 0.2.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/README.md +54 -18
- package/dist/components/Accordion.svelte +281 -0
- package/dist/components/Accordion.svelte.d.ts +47 -0
- package/dist/components/Badge.svelte +144 -7
- package/dist/components/Badge.svelte.d.ts +31 -2
- package/dist/components/BottomNav.svelte +216 -0
- package/dist/components/BottomNav.svelte.d.ts +30 -0
- package/dist/components/Button.svelte +187 -6
- package/dist/components/Button.svelte.d.ts +24 -4
- package/dist/components/Card.svelte +203 -8
- package/dist/components/Card.svelte.d.ts +21 -1
- package/dist/components/EmptyState.svelte +123 -36
- package/dist/components/EmptyState.svelte.d.ts +17 -1
- package/dist/components/Icon.svelte +191 -12
- package/dist/components/Icon.svelte.d.ts +69 -2
- package/dist/components/Image.svelte +430 -0
- package/dist/components/Image.svelte.d.ts +49 -0
- package/dist/components/Input.svelte +206 -18
- package/dist/components/Input.svelte.d.ts +29 -0
- package/dist/components/Link.svelte +148 -0
- package/dist/components/Link.svelte.d.ts +22 -0
- package/dist/components/LogStream.svelte +403 -21
- package/dist/components/LogStream.svelte.d.ts +37 -6
- package/dist/components/Menu.svelte +355 -0
- package/dist/components/Menu.svelte.d.ts +46 -0
- package/dist/components/MetricTile.svelte +161 -7
- package/dist/components/MetricTile.svelte.d.ts +23 -0
- package/dist/components/SegmentedControl.svelte +208 -0
- package/dist/components/SegmentedControl.svelte.d.ts +30 -0
- package/dist/components/ServiceCard.svelte +270 -9
- package/dist/components/ServiceCard.svelte.d.ts +16 -1
- package/dist/components/Sidebar.svelte +391 -25
- package/dist/components/Sidebar.svelte.d.ts +20 -6
- package/dist/components/Sparkline.svelte +213 -6
- package/dist/components/Sparkline.svelte.d.ts +24 -0
- package/dist/components/Toaster.svelte +273 -60
- package/dist/components/Toaster.svelte.d.ts +9 -16
- package/dist/components/Topbar.svelte +273 -17
- package/dist/components/Topbar.svelte.d.ts +23 -0
- package/dist/config.d.ts +32 -14
- package/dist/config.js +43 -17
- package/dist/dssoca.config.d.ts +50 -0
- package/dist/dssoca.config.js +45 -0
- package/dist/index.d.ts +12 -5
- package/dist/index.js +14 -4
- package/dist/theme.css +587 -382
- package/dist/toast.svelte.d.ts +49 -5
- package/dist/toast.svelte.js +165 -9
- package/package.json +17 -3
- package/dist/components/PassocaMark.svelte +0 -15
- package/dist/components/PassocaMark.svelte.d.ts +0 -7
|
@@ -1,17 +1,51 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import
|
|
2
|
+
import type { Snippet } from 'svelte'
|
|
3
|
+
import { resolveComponentSize, type Size } from '../config.js'
|
|
4
|
+
|
|
5
|
+
interface Stat { key: string; value: string; title?: string }
|
|
3
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
|
|
26
|
+
/** Token size (sm|md|lg); inherits the global size when unset. */
|
|
27
|
+
size?: Size
|
|
9
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
|
+
|
|
10
36
|
let {
|
|
11
37
|
active = 'overview',
|
|
12
|
-
user = '
|
|
38
|
+
user = 'admin@hub.home',
|
|
13
39
|
tabs = ['overview', 'services', 'logs', 'shell'],
|
|
14
40
|
onTab,
|
|
41
|
+
onCommand,
|
|
42
|
+
onUser,
|
|
43
|
+
userMenu,
|
|
44
|
+
brand,
|
|
45
|
+
stats = DEFAULT_STATS,
|
|
46
|
+
skipTarget = '#main',
|
|
47
|
+
sticky = true,
|
|
48
|
+
size,
|
|
15
49
|
}: Props = $props()
|
|
16
50
|
|
|
17
51
|
function pad(n: number) { return String(n).padStart(2, '0') }
|
|
@@ -21,40 +55,262 @@
|
|
|
21
55
|
}
|
|
22
56
|
|
|
23
57
|
let clock = $state(nowStr())
|
|
58
|
+
|
|
24
59
|
$effect(() => {
|
|
25
60
|
const t = setInterval(() => { clock = nowStr() }, 1000)
|
|
26
|
-
|
|
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
|
+
}
|
|
27
72
|
})
|
|
28
73
|
|
|
29
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
|
+
}
|
|
30
93
|
</script>
|
|
31
94
|
|
|
32
|
-
<
|
|
95
|
+
<header class="ss-topbar" class:sticky data-size-variant={resolveComponentSize('Topbar', size)}>
|
|
96
|
+
<a class="skip" href={skipTarget}>Skip to content</a>
|
|
97
|
+
|
|
33
98
|
<div class="seg logo">
|
|
34
|
-
|
|
35
|
-
|
|
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}
|
|
36
111
|
</div>
|
|
37
|
-
|
|
38
|
-
|
|
112
|
+
|
|
113
|
+
<nav class="ws" aria-label="Primary">
|
|
114
|
+
{#each tabs as tab, i (tab)}
|
|
39
115
|
<button
|
|
116
|
+
bind:this={tabEls[i]}
|
|
40
117
|
class="tab {tab === active ? 'active' : ''}"
|
|
118
|
+
aria-current={tab === active ? 'page' : undefined}
|
|
119
|
+
tabindex={tab === active ? 0 : -1}
|
|
41
120
|
onclick={() => onTab?.(tab)}
|
|
121
|
+
onkeydown={(e) => onTabKeydown(e, i)}
|
|
42
122
|
>
|
|
43
|
-
<span class="n">{i + 1}</span>{tab}
|
|
123
|
+
<span class="n" aria-hidden="true">{i + 1}</span>{tab}
|
|
44
124
|
</button>
|
|
45
125
|
{/each}
|
|
46
|
-
</
|
|
126
|
+
</nav>
|
|
127
|
+
|
|
47
128
|
<div class="grow"></div>
|
|
129
|
+
|
|
48
130
|
<div class="seg right" title="services">
|
|
49
|
-
<span class="dot"></span>
|
|
131
|
+
<span class="dot" aria-hidden="true"></span>
|
|
50
132
|
<span class="stat"><span class="v">6</span><span class="k">/7 up</span></span>
|
|
51
133
|
</div>
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
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
|
+
|
|
57
156
|
<div class="seg right clock">
|
|
58
157
|
<span>{h}</span><span class="sep">:</span><span>{m}</span><span class="sep">:</span><span>{s}</span>
|
|
59
158
|
</div>
|
|
60
|
-
</
|
|
159
|
+
</header>
|
|
160
|
+
|
|
161
|
+
<style>.ss-topbar {
|
|
162
|
+
grid-column: 1/-1;
|
|
163
|
+
display: flex;
|
|
164
|
+
align-items: stretch;
|
|
165
|
+
background: var(--ss-bg);
|
|
166
|
+
border-bottom: 1px solid var(--ss-line);
|
|
167
|
+
font-family: var(--ss-font-mono);
|
|
168
|
+
font-size: var(--ss-ui-md);
|
|
169
|
+
color: var(--ss-fg-muted);
|
|
170
|
+
user-select: none;
|
|
171
|
+
position: relative;
|
|
172
|
+
top: 0;
|
|
173
|
+
z-index: 10;
|
|
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
|
+
}
|
|
194
|
+
.ss-topbar .seg {
|
|
195
|
+
display: flex;
|
|
196
|
+
align-items: center;
|
|
197
|
+
gap: 8px;
|
|
198
|
+
padding: 0 var(--ss-panel-head-px);
|
|
199
|
+
border-right: 1px solid var(--ss-line);
|
|
200
|
+
cursor: default;
|
|
201
|
+
}
|
|
202
|
+
.ss-topbar .seg.right {
|
|
203
|
+
border-right: none;
|
|
204
|
+
border-left: 1px solid var(--ss-line);
|
|
205
|
+
}
|
|
206
|
+
.ss-topbar .seg.click {
|
|
207
|
+
cursor: pointer;
|
|
208
|
+
}
|
|
209
|
+
.ss-topbar .seg.click:hover {
|
|
210
|
+
background: var(--ss-hover);
|
|
211
|
+
color: var(--ss-fg);
|
|
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
|
+
}
|
|
225
|
+
.ss-topbar .logo {
|
|
226
|
+
color: var(--ss-fg);
|
|
227
|
+
}
|
|
228
|
+
.ss-topbar .logo .mark {
|
|
229
|
+
display: block;
|
|
230
|
+
}
|
|
231
|
+
.ss-topbar .logo .nm {
|
|
232
|
+
font-family: var(--ss-font-display);
|
|
233
|
+
font-size: var(--ss-ui-lg);
|
|
234
|
+
letter-spacing: 0.02em;
|
|
235
|
+
line-height: 1;
|
|
236
|
+
}
|
|
237
|
+
.ss-topbar .ws {
|
|
238
|
+
display: flex;
|
|
239
|
+
align-items: stretch;
|
|
240
|
+
}
|
|
241
|
+
.ss-topbar .ws .tab {
|
|
242
|
+
display: flex;
|
|
243
|
+
align-items: center;
|
|
244
|
+
padding: 0 var(--ss-row-px);
|
|
245
|
+
min-height: var(--ss-s-6);
|
|
246
|
+
color: var(--ss-fg-faint);
|
|
247
|
+
border-right: 1px solid var(--ss-line);
|
|
248
|
+
cursor: pointer;
|
|
249
|
+
font: 500 var(--ss-ui-md) var(--ss-font-mono);
|
|
250
|
+
background: transparent;
|
|
251
|
+
border-top: 0;
|
|
252
|
+
border-bottom: 0;
|
|
253
|
+
border-left: 0;
|
|
254
|
+
transition: all var(--ss-dur-fast) var(--ss-ease);
|
|
255
|
+
}
|
|
256
|
+
.ss-topbar .ws .tab:hover {
|
|
257
|
+
color: var(--ss-fg);
|
|
258
|
+
background: var(--ss-hover);
|
|
259
|
+
}
|
|
260
|
+
.ss-topbar .ws .tab .n {
|
|
261
|
+
color: var(--ss-fg-faint);
|
|
262
|
+
margin-right: 6px;
|
|
263
|
+
}
|
|
264
|
+
.ss-topbar .ws .tab.active {
|
|
265
|
+
color: var(--ss-fg);
|
|
266
|
+
background: rgba(102, 239, 115, 0.06);
|
|
267
|
+
box-shadow: inset 0 -2px 0 var(--ss-primary);
|
|
268
|
+
}
|
|
269
|
+
.ss-topbar .ws .tab.active .n {
|
|
270
|
+
color: var(--ss-primary);
|
|
271
|
+
}
|
|
272
|
+
.ss-topbar .grow {
|
|
273
|
+
flex: 1;
|
|
274
|
+
}
|
|
275
|
+
.ss-topbar .dot {
|
|
276
|
+
width: 6px;
|
|
277
|
+
height: 6px;
|
|
278
|
+
background: var(--ss-primary);
|
|
279
|
+
display: inline-block;
|
|
280
|
+
}
|
|
281
|
+
.ss-topbar .stat {
|
|
282
|
+
font-variant-numeric: tabular-nums;
|
|
283
|
+
}
|
|
284
|
+
.ss-topbar .stat .k {
|
|
285
|
+
color: var(--ss-fg-faint);
|
|
286
|
+
margin-right: 4px;
|
|
287
|
+
}
|
|
288
|
+
.ss-topbar .stat .v {
|
|
289
|
+
color: var(--ss-fg);
|
|
290
|
+
}
|
|
291
|
+
.ss-topbar .clock {
|
|
292
|
+
color: var(--ss-fg);
|
|
293
|
+
font-variant-numeric: tabular-nums;
|
|
294
|
+
}
|
|
295
|
+
.ss-topbar .clock .sep {
|
|
296
|
+
color: var(--ss-fg-faint);
|
|
297
|
+
margin: 0 2px;
|
|
298
|
+
}
|
|
299
|
+
.ss-topbar .kbd {
|
|
300
|
+
font-family: var(--ss-font-mono);
|
|
301
|
+
font-size: var(--ss-ui-sm);
|
|
302
|
+
color: var(--ss-fg-muted);
|
|
303
|
+
border: 1px solid var(--ss-line);
|
|
304
|
+
padding: 2px 5px;
|
|
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
|
+
}
|
|
316
|
+
}</style>
|
|
@@ -1,8 +1,31 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
import { type Size } from '../config.js';
|
|
3
|
+
interface Stat {
|
|
4
|
+
key: string;
|
|
5
|
+
value: string;
|
|
6
|
+
title?: string;
|
|
7
|
+
}
|
|
1
8
|
interface Props {
|
|
2
9
|
active?: string;
|
|
3
10
|
user?: string;
|
|
4
11
|
tabs?: string[];
|
|
5
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;
|
|
27
|
+
/** Token size (sm|md|lg); inherits the global size when unset. */
|
|
28
|
+
size?: Size;
|
|
6
29
|
}
|
|
7
30
|
declare const Topbar: import("svelte").Component<Props, {}, "">;
|
|
8
31
|
type Topbar = ReturnType<typeof Topbar>;
|
package/dist/config.d.ts
CHANGED
|
@@ -1,34 +1,52 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Design system runtime config.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* The available axes, their values, and the defaults are declared once in
|
|
5
|
+
* `dssoca.config.ts`; this module derives its types + defaults from that
|
|
6
|
+
* manifest and provides the runtime helpers (see DESIGN.md):
|
|
7
|
+
* • color — written as [data-theme]
|
|
8
|
+
* • size — written as [data-size-variant] (renamed from `density` in 0.4.0)
|
|
7
9
|
*
|
|
8
|
-
*
|
|
10
|
+
* Sizing has three layers (highest priority first):
|
|
11
|
+
* 1. a component's `size` prop (per instance)
|
|
12
|
+
* 2. `componentsSize[Name]` (per-component default)
|
|
13
|
+
* 3. `sizeVariant` on an ancestor (global default; `md` out of the box)
|
|
9
14
|
*/
|
|
10
|
-
|
|
11
|
-
export
|
|
15
|
+
import { dssocaConfig, type ColorTheme, type Size, type ComponentName, type ComponentsSize } from './dssoca.config.js';
|
|
16
|
+
export { dssocaConfig };
|
|
17
|
+
export type { ColorTheme, Size, ComponentName, ComponentsSize };
|
|
18
|
+
export type { DssocaConfig, DesignAxis } from './dssoca.config.js';
|
|
12
19
|
export interface DesignConfig {
|
|
13
20
|
theme: ColorTheme;
|
|
14
|
-
|
|
21
|
+
/** Global default size for every component — written as [data-size-variant]. */
|
|
22
|
+
sizeVariant: Size;
|
|
23
|
+
/** Per-component default sizes; components not listed inherit `sizeVariant`. */
|
|
24
|
+
componentsSize: ComponentsSize;
|
|
15
25
|
}
|
|
26
|
+
/** Defaults derived from the manifest — change them in `dssoca.config.ts`. */
|
|
16
27
|
export declare const defaultDesignConfig: DesignConfig;
|
|
17
28
|
/** Current resolved config (last applied, or defaults). */
|
|
18
29
|
export declare function getDesignConfig(): DesignConfig;
|
|
19
30
|
/**
|
|
20
|
-
* Build the `data-*` attribute map for a config — handy for SSR / markup
|
|
21
|
-
*
|
|
31
|
+
* Build the `data-*` attribute map for a config — handy for SSR / markup so the
|
|
32
|
+
* correct theme + size paint on the first frame with no flash.
|
|
22
33
|
*
|
|
23
|
-
* <
|
|
34
|
+
* <html {...designAttributes({ sizeVariant: 'sm' })}> … </html>
|
|
24
35
|
*/
|
|
25
36
|
export declare function designAttributes(config?: Partial<DesignConfig>): {
|
|
26
37
|
'data-theme': ColorTheme;
|
|
27
|
-
'data-
|
|
38
|
+
'data-size-variant': Size;
|
|
28
39
|
};
|
|
29
40
|
/**
|
|
30
|
-
* Apply theme +
|
|
31
|
-
*
|
|
32
|
-
* SSR-safe: no-op when no document and no explicit target.
|
|
41
|
+
* Apply theme + size to a DOM element (defaults to <html>). Merges over the
|
|
42
|
+
* current config so callers can flip one axis at a time (`componentsSize` is
|
|
43
|
+
* merged key-by-key). SSR-safe: no-op when no document and no explicit target.
|
|
33
44
|
*/
|
|
34
45
|
export declare function applyDesignConfig(config?: Partial<DesignConfig>, target?: HTMLElement): DesignConfig;
|
|
46
|
+
/**
|
|
47
|
+
* Resolve the size a component should APPLY on its own root (as
|
|
48
|
+
* `data-size-variant`), or `undefined` to inherit the global `sizeVariant`
|
|
49
|
+
* through the cascade. Resolution order: explicit `size` prop →
|
|
50
|
+
* `componentsSize[name]` → inherit.
|
|
51
|
+
*/
|
|
52
|
+
export declare function resolveComponentSize(name: ComponentName, size?: Size): Size | undefined;
|
package/dist/config.js
CHANGED
|
@@ -1,42 +1,68 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Design system runtime config.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* The available axes, their values, and the defaults are declared once in
|
|
5
|
+
* `dssoca.config.ts`; this module derives its types + defaults from that
|
|
6
|
+
* manifest and provides the runtime helpers (see DESIGN.md):
|
|
7
|
+
* • color — written as [data-theme]
|
|
8
|
+
* • size — written as [data-size-variant] (renamed from `density` in 0.4.0)
|
|
7
9
|
*
|
|
8
|
-
*
|
|
10
|
+
* Sizing has three layers (highest priority first):
|
|
11
|
+
* 1. a component's `size` prop (per instance)
|
|
12
|
+
* 2. `componentsSize[Name]` (per-component default)
|
|
13
|
+
* 3. `sizeVariant` on an ancestor (global default; `md` out of the box)
|
|
9
14
|
*/
|
|
15
|
+
import { dssocaConfig, } from './dssoca.config.js';
|
|
16
|
+
// Re-exported so the `dssoca` / `./config` import paths expose the config vocab.
|
|
17
|
+
export { dssocaConfig };
|
|
18
|
+
/** Defaults derived from the manifest — change them in `dssoca.config.ts`. */
|
|
10
19
|
export const defaultDesignConfig = {
|
|
11
|
-
theme:
|
|
12
|
-
|
|
20
|
+
theme: dssocaConfig.theme.default,
|
|
21
|
+
sizeVariant: dssocaConfig.size.default,
|
|
22
|
+
componentsSize: {},
|
|
23
|
+
};
|
|
24
|
+
let current = {
|
|
25
|
+
...defaultDesignConfig,
|
|
26
|
+
componentsSize: { ...defaultDesignConfig.componentsSize },
|
|
13
27
|
};
|
|
14
|
-
let current = { ...defaultDesignConfig };
|
|
15
28
|
/** Current resolved config (last applied, or defaults). */
|
|
16
29
|
export function getDesignConfig() {
|
|
17
|
-
return { ...current };
|
|
30
|
+
return { ...current, componentsSize: { ...current.componentsSize } };
|
|
18
31
|
}
|
|
19
32
|
/**
|
|
20
|
-
* Build the `data-*` attribute map for a config — handy for SSR / markup
|
|
21
|
-
*
|
|
33
|
+
* Build the `data-*` attribute map for a config — handy for SSR / markup so the
|
|
34
|
+
* correct theme + size paint on the first frame with no flash.
|
|
22
35
|
*
|
|
23
|
-
* <
|
|
36
|
+
* <html {...designAttributes({ sizeVariant: 'sm' })}> … </html>
|
|
24
37
|
*/
|
|
25
38
|
export function designAttributes(config = {}) {
|
|
26
39
|
const merged = { ...defaultDesignConfig, ...config };
|
|
27
|
-
return { 'data-theme': merged.theme, 'data-
|
|
40
|
+
return { 'data-theme': merged.theme, 'data-size-variant': merged.sizeVariant };
|
|
28
41
|
}
|
|
29
42
|
/**
|
|
30
|
-
* Apply theme +
|
|
31
|
-
*
|
|
32
|
-
* SSR-safe: no-op when no document and no explicit target.
|
|
43
|
+
* Apply theme + size to a DOM element (defaults to <html>). Merges over the
|
|
44
|
+
* current config so callers can flip one axis at a time (`componentsSize` is
|
|
45
|
+
* merged key-by-key). SSR-safe: no-op when no document and no explicit target.
|
|
33
46
|
*/
|
|
34
47
|
export function applyDesignConfig(config = {}, target) {
|
|
35
|
-
current = {
|
|
48
|
+
current = {
|
|
49
|
+
...current,
|
|
50
|
+
...config,
|
|
51
|
+
componentsSize: { ...current.componentsSize, ...(config.componentsSize ?? {}) },
|
|
52
|
+
};
|
|
36
53
|
const el = target ?? (typeof document !== 'undefined' ? document.documentElement : undefined);
|
|
37
54
|
if (el) {
|
|
38
55
|
el.setAttribute('data-theme', current.theme);
|
|
39
|
-
el.setAttribute('data-
|
|
56
|
+
el.setAttribute('data-size-variant', current.sizeVariant);
|
|
40
57
|
}
|
|
41
58
|
return getDesignConfig();
|
|
42
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Resolve the size a component should APPLY on its own root (as
|
|
62
|
+
* `data-size-variant`), or `undefined` to inherit the global `sizeVariant`
|
|
63
|
+
* through the cascade. Resolution order: explicit `size` prop →
|
|
64
|
+
* `componentsSize[name]` → inherit.
|
|
65
|
+
*/
|
|
66
|
+
export function resolveComponentSize(name, size) {
|
|
67
|
+
return size ?? current.componentsSize[name];
|
|
68
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dssoca configuration manifest — the single source of truth for *how the
|
|
3
|
+
* design system is configured*: which axes exist, the values each one allows,
|
|
4
|
+
* and the system defaults. `config.ts` derives its types and defaults from
|
|
5
|
+
* here, so adding a value (or a whole new axis) is a one-place change.
|
|
6
|
+
*
|
|
7
|
+
* Two axes today (see DESIGN.md):
|
|
8
|
+
* • theme — color, written as [data-theme]
|
|
9
|
+
* • size — chrome scale (sm | md | lg), written as [data-size-variant]
|
|
10
|
+
*
|
|
11
|
+
* The `size` axis replaced the former `density` axis in 0.4.0 (DS-0012):
|
|
12
|
+
* compact → `sm`, comfy → `md`, plus a new `lg`. The global default is set by
|
|
13
|
+
* `sizeVariant`; per-component defaults by `componentsSize`; per instance by a
|
|
14
|
+
* component's `size` prop.
|
|
15
|
+
*/
|
|
16
|
+
/** One configurable axis: its allowed values + the default applied when unset. */
|
|
17
|
+
export interface DesignAxis<Values extends readonly string[] = readonly string[]> {
|
|
18
|
+
/** Allowed values for the axis (by convention the default appears here too). */
|
|
19
|
+
readonly values: Values;
|
|
20
|
+
/** The value applied when a consumer sets nothing. */
|
|
21
|
+
readonly default: Values[number];
|
|
22
|
+
}
|
|
23
|
+
/** Shape of the manifest — one entry per axis the design system understands. */
|
|
24
|
+
export interface DssocaConfig {
|
|
25
|
+
readonly theme: DesignAxis;
|
|
26
|
+
readonly size: DesignAxis;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The manifest. `as const` preserves the value/default literals so the unions
|
|
30
|
+
* below can be derived from it; `satisfies` validates the shape without widening.
|
|
31
|
+
*/
|
|
32
|
+
export declare const dssocaConfig: {
|
|
33
|
+
readonly theme: {
|
|
34
|
+
readonly values: readonly ["dark", "light"];
|
|
35
|
+
readonly default: "dark";
|
|
36
|
+
};
|
|
37
|
+
readonly size: {
|
|
38
|
+
readonly values: readonly ["sm", "md", "lg"];
|
|
39
|
+
readonly default: "md";
|
|
40
|
+
};
|
|
41
|
+
};
|
|
42
|
+
/** Color axis values — derived from the manifest (`'dark' | 'light'`). */
|
|
43
|
+
export type ColorTheme = (typeof dssocaConfig)['theme']['values'][number];
|
|
44
|
+
/** Size axis values — derived from the manifest (`'sm' | 'md' | 'lg'`). */
|
|
45
|
+
export type Size = (typeof dssocaConfig)['size']['values'][number];
|
|
46
|
+
/** Names of the components that accept a `size` prop / `componentsSize` entry. */
|
|
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
|
+
export type ComponentName = (typeof COMPONENT_NAMES)[number];
|
|
49
|
+
/** Per-component default sizes; any omitted component inherits `sizeVariant`. */
|
|
50
|
+
export type ComponentsSize = Partial<Record<ComponentName, Size>>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* dssoca configuration manifest — the single source of truth for *how the
|
|
3
|
+
* design system is configured*: which axes exist, the values each one allows,
|
|
4
|
+
* and the system defaults. `config.ts` derives its types and defaults from
|
|
5
|
+
* here, so adding a value (or a whole new axis) is a one-place change.
|
|
6
|
+
*
|
|
7
|
+
* Two axes today (see DESIGN.md):
|
|
8
|
+
* • theme — color, written as [data-theme]
|
|
9
|
+
* • size — chrome scale (sm | md | lg), written as [data-size-variant]
|
|
10
|
+
*
|
|
11
|
+
* The `size` axis replaced the former `density` axis in 0.4.0 (DS-0012):
|
|
12
|
+
* compact → `sm`, comfy → `md`, plus a new `lg`. The global default is set by
|
|
13
|
+
* `sizeVariant`; per-component defaults by `componentsSize`; per instance by a
|
|
14
|
+
* component's `size` prop.
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* The manifest. `as const` preserves the value/default literals so the unions
|
|
18
|
+
* below can be derived from it; `satisfies` validates the shape without widening.
|
|
19
|
+
*/
|
|
20
|
+
export const dssocaConfig = {
|
|
21
|
+
theme: { values: ['dark', 'light'], default: 'dark' },
|
|
22
|
+
size: { values: ['sm', 'md', 'lg'], default: 'md' },
|
|
23
|
+
};
|
|
24
|
+
/** Names of the components that accept a `size` prop / `componentsSize` entry. */
|
|
25
|
+
export const COMPONENT_NAMES = [
|
|
26
|
+
'Accordion',
|
|
27
|
+
'Badge',
|
|
28
|
+
'BottomNav',
|
|
29
|
+
'Button',
|
|
30
|
+
'Card',
|
|
31
|
+
'EmptyState',
|
|
32
|
+
'Icon',
|
|
33
|
+
'Image',
|
|
34
|
+
'Input',
|
|
35
|
+
'Link',
|
|
36
|
+
'LogStream',
|
|
37
|
+
'Menu',
|
|
38
|
+
'MetricTile',
|
|
39
|
+
'SegmentedControl',
|
|
40
|
+
'ServiceCard',
|
|
41
|
+
'Sidebar',
|
|
42
|
+
'Sparkline',
|
|
43
|
+
'Toaster',
|
|
44
|
+
'Topbar',
|
|
45
|
+
];
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { type ColorTheme, type
|
|
2
|
-
export {
|
|
3
|
-
export { default as Icon } from './components/Icon.svelte';
|
|
1
|
+
export { type ColorTheme, type Size, type DesignConfig, defaultDesignConfig, getDesignConfig, designAttributes, applyDesignConfig, resolveComponentSize, } from './config.js';
|
|
2
|
+
export { dssocaConfig, type DssocaConfig, type DesignAxis, type ComponentName, type ComponentsSize, } from './dssoca.config.js';
|
|
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';
|