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
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
import type { IconName } from './Icon.svelte'
|
|
3
|
+
|
|
4
|
+
/** One option in a {@link SegmentedControl}. */
|
|
5
|
+
export interface SegmentOption {
|
|
6
|
+
value: string
|
|
7
|
+
label: string
|
|
8
|
+
/** Optional leading glyph. */
|
|
9
|
+
icon?: IconName
|
|
10
|
+
disabled?: boolean
|
|
11
|
+
}
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<script lang="ts">
|
|
15
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
16
|
+
// SegmentedControl — DS-0053. A compact row of mutually-exclusive options
|
|
17
|
+
// (view / mode / locale). Generalizes the website's LanguageSwitcher to N
|
|
18
|
+
// options. Highlighted selection (token fill, zero radius), bindable `value`,
|
|
19
|
+
// `role="radiogroup"` with `role="radio"` segments, roving tabindex + arrow
|
|
20
|
+
// / Home / End keyboard nav (skips disabled), size-token density.
|
|
21
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
22
|
+
import Icon from './Icon.svelte'
|
|
23
|
+
import { resolveComponentSize, type Size } from '../config.js'
|
|
24
|
+
|
|
25
|
+
interface Props {
|
|
26
|
+
/** Mutually-exclusive options: { value, label, icon?, disabled? }. */
|
|
27
|
+
options?: SegmentOption[]
|
|
28
|
+
/** Selected option value (bindable). */
|
|
29
|
+
value?: string
|
|
30
|
+
/** Fired when the selection changes (after `value` updates). */
|
|
31
|
+
onChange?: (value: string) => void
|
|
32
|
+
/** Stretch segments to equal widths and fill the container. */
|
|
33
|
+
fullWidth?: boolean
|
|
34
|
+
/** Token size (sm|md|lg); inherits the global size when unset. */
|
|
35
|
+
size?: Size
|
|
36
|
+
/**
|
|
37
|
+
* Accessible name for the group. Required (WCAG 2.2 AA): a radiogroup with
|
|
38
|
+
* no name leaves AT users without context for the choice.
|
|
39
|
+
*/
|
|
40
|
+
label: string
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
let {
|
|
44
|
+
options = [],
|
|
45
|
+
value = $bindable(),
|
|
46
|
+
onChange,
|
|
47
|
+
fullWidth = false,
|
|
48
|
+
size,
|
|
49
|
+
label,
|
|
50
|
+
}: Props = $props()
|
|
51
|
+
|
|
52
|
+
// Bound references to each segment, indexed by option position, so keyboard
|
|
53
|
+
// navigation can move focus across the roving-tabindex group.
|
|
54
|
+
let segments = $state<(HTMLButtonElement | undefined)[]>([])
|
|
55
|
+
|
|
56
|
+
const enabledIndexes = $derived(
|
|
57
|
+
options.map((o, i) => (o.disabled ? -1 : i)).filter((i) => i >= 0),
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
/** Index that owns the single tab stop (roving tabindex). The selected option
|
|
61
|
+
* when it's enabled; otherwise the first enabled option; -1 when none. */
|
|
62
|
+
const tabbableIndex = $derived.by(() => {
|
|
63
|
+
const sel = options.findIndex((o) => o.value === value && !o.disabled)
|
|
64
|
+
if (sel >= 0) return sel
|
|
65
|
+
return enabledIndexes[0] ?? -1
|
|
66
|
+
})
|
|
67
|
+
|
|
68
|
+
function select(index: number) {
|
|
69
|
+
const opt = options[index]
|
|
70
|
+
if (!opt || opt.disabled) return
|
|
71
|
+
if (opt.value !== value) {
|
|
72
|
+
value = opt.value
|
|
73
|
+
onChange?.(opt.value)
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
function focusIndex(index: number) {
|
|
78
|
+
segments[index]?.focus()
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Next/previous enabled option index, wrapping around the row. */
|
|
82
|
+
function step(from: number, dir: 1 | -1): number {
|
|
83
|
+
if (enabledIndexes.length === 0) return from
|
|
84
|
+
const pos = enabledIndexes.indexOf(from)
|
|
85
|
+
// `from` might be disabled (shouldn't be focusable) — fall back to an edge.
|
|
86
|
+
const base = pos === -1 ? (dir === 1 ? -1 : 0) : pos
|
|
87
|
+
const next = (base + dir + enabledIndexes.length) % enabledIndexes.length
|
|
88
|
+
return enabledIndexes[next]
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function onKeydown(e: KeyboardEvent, index: number) {
|
|
92
|
+
let target = -1
|
|
93
|
+
switch (e.key) {
|
|
94
|
+
case 'ArrowRight':
|
|
95
|
+
case 'ArrowDown':
|
|
96
|
+
target = step(index, 1)
|
|
97
|
+
break
|
|
98
|
+
case 'ArrowLeft':
|
|
99
|
+
case 'ArrowUp':
|
|
100
|
+
target = step(index, -1)
|
|
101
|
+
break
|
|
102
|
+
case 'Home':
|
|
103
|
+
target = enabledIndexes[0] ?? -1
|
|
104
|
+
break
|
|
105
|
+
case 'End':
|
|
106
|
+
target = enabledIndexes[enabledIndexes.length - 1] ?? -1
|
|
107
|
+
break
|
|
108
|
+
default:
|
|
109
|
+
return
|
|
110
|
+
}
|
|
111
|
+
if (target < 0) return
|
|
112
|
+
e.preventDefault()
|
|
113
|
+
// radiogroup semantics: moving focus also moves the selection.
|
|
114
|
+
select(target)
|
|
115
|
+
focusIndex(target)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
const sizeAttr = $derived(resolveComponentSize('SegmentedControl', size))
|
|
119
|
+
</script>
|
|
120
|
+
|
|
121
|
+
<div
|
|
122
|
+
class="ss-segmented"
|
|
123
|
+
class:full={fullWidth}
|
|
124
|
+
role="radiogroup"
|
|
125
|
+
aria-label={label}
|
|
126
|
+
data-size-variant={sizeAttr}
|
|
127
|
+
>
|
|
128
|
+
{#each options as opt, i (opt.value)}
|
|
129
|
+
{@const selected = opt.value === value}
|
|
130
|
+
<button
|
|
131
|
+
bind:this={segments[i]}
|
|
132
|
+
type="button"
|
|
133
|
+
class="segment"
|
|
134
|
+
class:selected
|
|
135
|
+
role="radio"
|
|
136
|
+
aria-checked={selected}
|
|
137
|
+
tabindex={i === tabbableIndex ? 0 : -1}
|
|
138
|
+
disabled={opt.disabled}
|
|
139
|
+
onclick={() => select(i)}
|
|
140
|
+
onkeydown={(e) => onKeydown(e, i)}
|
|
141
|
+
>
|
|
142
|
+
{#if opt.icon}<Icon name={opt.icon} class="ic" />{/if}
|
|
143
|
+
<span class="label">{opt.label}</span>
|
|
144
|
+
</button>
|
|
145
|
+
{/each}
|
|
146
|
+
</div>
|
|
147
|
+
|
|
148
|
+
<style>.ss-segmented {
|
|
149
|
+
display: inline-flex;
|
|
150
|
+
gap: 0;
|
|
151
|
+
border: 1px solid var(--ss-line);
|
|
152
|
+
background: var(--ss-bg);
|
|
153
|
+
width: max-content;
|
|
154
|
+
max-width: 100%;
|
|
155
|
+
}
|
|
156
|
+
.ss-segmented.full {
|
|
157
|
+
display: flex;
|
|
158
|
+
width: 100%;
|
|
159
|
+
}
|
|
160
|
+
.ss-segmented .segment {
|
|
161
|
+
display: inline-flex;
|
|
162
|
+
align-items: center;
|
|
163
|
+
justify-content: center;
|
|
164
|
+
gap: var(--ss-seg-gap);
|
|
165
|
+
font: 500 var(--ss-seg-font)/1 var(--ss-font-body);
|
|
166
|
+
color: var(--ss-fg-muted);
|
|
167
|
+
background: transparent;
|
|
168
|
+
border: 0;
|
|
169
|
+
border-left: 1px solid var(--ss-line);
|
|
170
|
+
padding: var(--ss-seg-py) var(--ss-seg-px);
|
|
171
|
+
cursor: pointer;
|
|
172
|
+
white-space: nowrap;
|
|
173
|
+
text-align: center;
|
|
174
|
+
transition: color var(--ss-dur-fast) var(--ss-ease), background var(--ss-dur-fast) var(--ss-ease);
|
|
175
|
+
}
|
|
176
|
+
.ss-segmented .segment:first-child {
|
|
177
|
+
border-left: 0;
|
|
178
|
+
}
|
|
179
|
+
.ss-segmented .segment:hover:not(.selected):not(:disabled) {
|
|
180
|
+
color: var(--ss-fg);
|
|
181
|
+
background: var(--ss-hover);
|
|
182
|
+
}
|
|
183
|
+
.ss-segmented .segment.selected {
|
|
184
|
+
color: var(--ss-fg-on-primary);
|
|
185
|
+
background: var(--ss-primary);
|
|
186
|
+
}
|
|
187
|
+
.ss-segmented .segment:focus-visible {
|
|
188
|
+
outline: none;
|
|
189
|
+
box-shadow: inset 0 0 0 2px var(--ss-primary-soft);
|
|
190
|
+
z-index: 1;
|
|
191
|
+
}
|
|
192
|
+
.ss-segmented .segment.selected:focus-visible {
|
|
193
|
+
box-shadow: inset 0 0 0 2px var(--ss-bg);
|
|
194
|
+
}
|
|
195
|
+
.ss-segmented .segment:disabled {
|
|
196
|
+
cursor: not-allowed;
|
|
197
|
+
opacity: 0.45;
|
|
198
|
+
}
|
|
199
|
+
.ss-segmented .segment .label {
|
|
200
|
+
display: inline-block;
|
|
201
|
+
}
|
|
202
|
+
.ss-segmented.full .segment {
|
|
203
|
+
flex: 1 1 0;
|
|
204
|
+
min-width: 0;
|
|
205
|
+
}
|
|
206
|
+
.ss-segmented :global(.segment .ic) {
|
|
207
|
+
flex: 0 0 auto;
|
|
208
|
+
}</style>
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { IconName } from './Icon.svelte';
|
|
2
|
+
/** One option in a {@link SegmentedControl}. */
|
|
3
|
+
export interface SegmentOption {
|
|
4
|
+
value: string;
|
|
5
|
+
label: string;
|
|
6
|
+
/** Optional leading glyph. */
|
|
7
|
+
icon?: IconName;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
}
|
|
10
|
+
import { type Size } from '../config.js';
|
|
11
|
+
interface Props {
|
|
12
|
+
/** Mutually-exclusive options: { value, label, icon?, disabled? }. */
|
|
13
|
+
options?: SegmentOption[];
|
|
14
|
+
/** Selected option value (bindable). */
|
|
15
|
+
value?: string;
|
|
16
|
+
/** Fired when the selection changes (after `value` updates). */
|
|
17
|
+
onChange?: (value: string) => void;
|
|
18
|
+
/** Stretch segments to equal widths and fill the container. */
|
|
19
|
+
fullWidth?: boolean;
|
|
20
|
+
/** Token size (sm|md|lg); inherits the global size when unset. */
|
|
21
|
+
size?: Size;
|
|
22
|
+
/**
|
|
23
|
+
* Accessible name for the group. Required (WCAG 2.2 AA): a radiogroup with
|
|
24
|
+
* no name leaves AT users without context for the choice.
|
|
25
|
+
*/
|
|
26
|
+
label: string;
|
|
27
|
+
}
|
|
28
|
+
declare const SegmentedControl: import("svelte").Component<Props, {}, "value">;
|
|
29
|
+
type SegmentedControl = ReturnType<typeof SegmentedControl>;
|
|
30
|
+
export default SegmentedControl;
|
|
@@ -1,15 +1,28 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte'
|
|
2
3
|
import Badge from './Badge.svelte'
|
|
3
4
|
import Sparkline from './Sparkline.svelte'
|
|
4
5
|
import { resolveComponentSize, type Size } from '../config.js'
|
|
5
6
|
|
|
7
|
+
type Status = 'up' | 'deg' | 'down' | 'maint'
|
|
8
|
+
|
|
6
9
|
interface Props {
|
|
7
10
|
name: string
|
|
8
11
|
host: string
|
|
9
|
-
status?:
|
|
12
|
+
status?: Status
|
|
10
13
|
latency?: string
|
|
11
14
|
spark?: number[]
|
|
12
15
|
onclick?: () => void
|
|
16
|
+
/** When set, the card renders as a real `<a>` and navigates here (native Enter). */
|
|
17
|
+
href?: string
|
|
18
|
+
/** Render skeleton placeholders and mark the card `aria-busy`; suppresses interaction. */
|
|
19
|
+
loading?: boolean
|
|
20
|
+
/** Non-interactive variant: `aria-disabled`, no focus/pointer, no onclick. */
|
|
21
|
+
disabled?: boolean
|
|
22
|
+
/** "Last checked" instant; rendered as relative time in a `<time datetime>` footer slot. */
|
|
23
|
+
updatedAt?: Date | string
|
|
24
|
+
/** Optional extra metadata rows (version, IP, tags…) below the head. */
|
|
25
|
+
meta?: Snippet
|
|
13
26
|
/** Token size (sm|md|lg); inherits the global size when unset. */
|
|
14
27
|
size?: Size
|
|
15
28
|
}
|
|
@@ -20,45 +33,138 @@
|
|
|
20
33
|
latency = '',
|
|
21
34
|
spark = [4, 8, 6, 10, 7, 12, 9, 14, 11, 16, 13, 10, 12],
|
|
22
35
|
onclick,
|
|
36
|
+
href,
|
|
37
|
+
loading = false,
|
|
38
|
+
disabled = false,
|
|
39
|
+
updatedAt,
|
|
40
|
+
meta,
|
|
23
41
|
size,
|
|
24
42
|
}: Props = $props()
|
|
25
43
|
|
|
26
44
|
const sparkColor = $derived(
|
|
27
45
|
status === 'deg' ? 'var(--ss-yellow)'
|
|
28
46
|
: status === 'down' ? 'var(--ss-red)'
|
|
47
|
+
: status === 'maint' ? 'var(--ss-blue)'
|
|
29
48
|
: 'var(--ss-primary)'
|
|
30
49
|
)
|
|
31
50
|
|
|
32
|
-
// Spell the status out for assistive tech (
|
|
33
|
-
const statusLabel = $derived(
|
|
51
|
+
// Spell the status out for assistive tech (the abbreviations are opaque).
|
|
52
|
+
const statusLabel = $derived(
|
|
53
|
+
status === 'deg' ? 'degraded'
|
|
54
|
+
: status === 'maint' ? 'maintenance'
|
|
55
|
+
: status
|
|
56
|
+
)
|
|
57
|
+
|
|
58
|
+
// Status is decorative on the dot/badge, but meaningful — fold it into the label.
|
|
59
|
+
const cardLabel = $derived(`${name}, ${statusLabel}`)
|
|
60
|
+
|
|
61
|
+
// The card is interactive (focusable, activatable) unless explicitly inert.
|
|
62
|
+
// This preserves the original default (a bare card was a role=button); `href`,
|
|
63
|
+
// `loading`, and `disabled` are the only things that change the element.
|
|
64
|
+
const interactive = $derived(!loading && !disabled)
|
|
65
|
+
|
|
66
|
+
// --- relative "last checked" timestamp -------------------------------------
|
|
67
|
+
const updatedDate = $derived(
|
|
68
|
+
updatedAt == null ? undefined
|
|
69
|
+
: updatedAt instanceof Date ? updatedAt
|
|
70
|
+
: new Date(updatedAt)
|
|
71
|
+
)
|
|
72
|
+
const updatedValid = $derived(
|
|
73
|
+
!!updatedDate && !Number.isNaN(updatedDate.getTime())
|
|
74
|
+
)
|
|
75
|
+
const updatedISO = $derived(updatedValid ? updatedDate!.toISOString() : undefined)
|
|
76
|
+
|
|
77
|
+
function relativeTime(d: Date): string {
|
|
78
|
+
const secs = Math.round((d.getTime() - Date.now()) / 1000)
|
|
79
|
+
const abs = Math.abs(secs)
|
|
80
|
+
const rtf = new Intl.RelativeTimeFormat(undefined, { numeric: 'auto', style: 'narrow' })
|
|
81
|
+
if (abs < 60) return rtf.format(Math.round(secs), 'second')
|
|
82
|
+
if (abs < 3600) return rtf.format(Math.round(secs / 60), 'minute')
|
|
83
|
+
if (abs < 86400) return rtf.format(Math.round(secs / 3600), 'hour')
|
|
84
|
+
return rtf.format(Math.round(secs / 86400), 'day')
|
|
85
|
+
}
|
|
86
|
+
const updatedLabel = $derived(updatedValid ? relativeTime(updatedDate!) : '')
|
|
34
87
|
</script>
|
|
35
88
|
|
|
36
|
-
|
|
37
|
-
class="ss-svc"
|
|
38
|
-
role="button"
|
|
39
|
-
tabindex="0"
|
|
40
|
-
aria-label={name}
|
|
41
|
-
data-size-variant={resolveComponentSize('ServiceCard', size)}
|
|
42
|
-
{onclick}
|
|
43
|
-
onkeydown={(e) => {
|
|
44
|
-
if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); onclick?.() }
|
|
45
|
-
}}
|
|
46
|
-
>
|
|
89
|
+
{#snippet body()}
|
|
47
90
|
<div class="head">
|
|
48
91
|
<div>
|
|
49
|
-
|
|
50
|
-
|
|
92
|
+
{#if loading}
|
|
93
|
+
<div class="sk sk-name" aria-hidden="true"></div>
|
|
94
|
+
<div class="sk sk-host" aria-hidden="true"></div>
|
|
95
|
+
{:else}
|
|
96
|
+
<div class="name">{name}</div>
|
|
97
|
+
<div class="host">{host}</div>
|
|
98
|
+
{/if}
|
|
51
99
|
</div>
|
|
52
100
|
</div>
|
|
53
101
|
<div class="status">
|
|
54
|
-
|
|
55
|
-
|
|
102
|
+
{#if loading}
|
|
103
|
+
<div class="sk sk-badge" aria-hidden="true"></div>
|
|
104
|
+
{:else}
|
|
105
|
+
<Badge tone={status}>{statusLabel}</Badge>
|
|
106
|
+
<div class="latency">{latency}</div>
|
|
107
|
+
{/if}
|
|
56
108
|
</div>
|
|
109
|
+
{#if meta && !loading}
|
|
110
|
+
<div class="meta">{@render meta()}</div>
|
|
111
|
+
{/if}
|
|
57
112
|
<div class="footer">
|
|
58
|
-
|
|
59
|
-
|
|
113
|
+
{#if loading}
|
|
114
|
+
<div class="sk sk-spark" aria-hidden="true"></div>
|
|
115
|
+
{:else}
|
|
116
|
+
<Sparkline data={spark} color={sparkColor} />
|
|
117
|
+
<div class="foot-meta">
|
|
118
|
+
{#if updatedValid}
|
|
119
|
+
<time class="updated" datetime={updatedISO}>{updatedLabel}</time>
|
|
120
|
+
{/if}
|
|
121
|
+
{#if interactive}
|
|
122
|
+
<span class="latency open"><span aria-hidden="true">▸</span> open</span>
|
|
123
|
+
{/if}
|
|
124
|
+
</div>
|
|
125
|
+
{/if}
|
|
60
126
|
</div>
|
|
61
|
-
|
|
127
|
+
{/snippet}
|
|
128
|
+
|
|
129
|
+
{#if href && interactive}
|
|
130
|
+
<a
|
|
131
|
+
class="ss-svc"
|
|
132
|
+
class:loading
|
|
133
|
+
{href}
|
|
134
|
+
aria-label={cardLabel}
|
|
135
|
+
data-size-variant={resolveComponentSize('ServiceCard', size)}
|
|
136
|
+
{onclick}
|
|
137
|
+
>
|
|
138
|
+
{@render body()}
|
|
139
|
+
</a>
|
|
140
|
+
{:else if interactive}
|
|
141
|
+
<div
|
|
142
|
+
class="ss-svc"
|
|
143
|
+
role="button"
|
|
144
|
+
tabindex="0"
|
|
145
|
+
aria-label={cardLabel}
|
|
146
|
+
data-size-variant={resolveComponentSize('ServiceCard', size)}
|
|
147
|
+
{onclick}
|
|
148
|
+
onkeydown={(e) => {
|
|
149
|
+
if (e.key === 'Enter' || e.key === ' ') { e.preventDefault(); onclick?.() }
|
|
150
|
+
}}
|
|
151
|
+
>
|
|
152
|
+
{@render body()}
|
|
153
|
+
</div>
|
|
154
|
+
{:else}
|
|
155
|
+
<div
|
|
156
|
+
class="ss-svc"
|
|
157
|
+
class:loading
|
|
158
|
+
class:disabled
|
|
159
|
+
role="group"
|
|
160
|
+
aria-label={cardLabel}
|
|
161
|
+
aria-busy={loading ? 'true' : undefined}
|
|
162
|
+
aria-disabled={disabled ? 'true' : undefined}
|
|
163
|
+
data-size-variant={resolveComponentSize('ServiceCard', size)}
|
|
164
|
+
>
|
|
165
|
+
{@render body()}
|
|
166
|
+
</div>
|
|
167
|
+
{/if}
|
|
62
168
|
|
|
63
169
|
<style>.ss-svc {
|
|
64
170
|
display: grid;
|
|
@@ -67,13 +173,10 @@
|
|
|
67
173
|
padding: var(--ss-card-py) var(--ss-card-px);
|
|
68
174
|
border: 1px solid var(--ss-line);
|
|
69
175
|
background: var(--ss-bg-elev);
|
|
70
|
-
|
|
176
|
+
color: var(--ss-fg);
|
|
177
|
+
text-decoration: none;
|
|
71
178
|
transition: all var(--ss-dur-fast) var(--ss-ease);
|
|
72
179
|
}
|
|
73
|
-
.ss-svc:hover {
|
|
74
|
-
border-color: var(--ss-line-strong);
|
|
75
|
-
background: #232323;
|
|
76
|
-
}
|
|
77
180
|
.ss-svc .head {
|
|
78
181
|
display: flex;
|
|
79
182
|
align-items: center;
|
|
@@ -95,15 +198,108 @@
|
|
|
95
198
|
align-items: flex-end;
|
|
96
199
|
gap: 2px;
|
|
97
200
|
}
|
|
201
|
+
.ss-svc .meta {
|
|
202
|
+
grid-column: 1/-1;
|
|
203
|
+
font-family: var(--ss-font-mono);
|
|
204
|
+
font-size: var(--ss-ui-sm);
|
|
205
|
+
color: var(--ss-fg-muted);
|
|
206
|
+
display: flex;
|
|
207
|
+
flex-direction: column;
|
|
208
|
+
gap: var(--ss-s-1);
|
|
209
|
+
}
|
|
98
210
|
.ss-svc .footer {
|
|
99
211
|
grid-column: 1/-1;
|
|
100
212
|
display: flex;
|
|
101
213
|
align-items: center;
|
|
102
214
|
justify-content: space-between;
|
|
215
|
+
gap: var(--ss-gap-sm);
|
|
103
216
|
margin-top: 2px;
|
|
104
217
|
}
|
|
218
|
+
.ss-svc .foot-meta {
|
|
219
|
+
display: flex;
|
|
220
|
+
align-items: center;
|
|
221
|
+
gap: var(--ss-gap-sm);
|
|
222
|
+
}
|
|
105
223
|
.ss-svc .latency {
|
|
106
224
|
font-family: var(--ss-font-mono);
|
|
107
225
|
font-size: var(--ss-ui-sm);
|
|
108
226
|
color: var(--ss-fg-muted);
|
|
227
|
+
}
|
|
228
|
+
.ss-svc .updated {
|
|
229
|
+
font-family: var(--ss-font-mono);
|
|
230
|
+
font-size: var(--ss-ui-sm);
|
|
231
|
+
color: var(--ss-fg-muted);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
/* Interactive variants (anchor + role=button div) get the affordance. */
|
|
235
|
+
a.ss-svc,
|
|
236
|
+
[role=button].ss-svc {
|
|
237
|
+
cursor: pointer;
|
|
238
|
+
}
|
|
239
|
+
a.ss-svc:hover,
|
|
240
|
+
[role=button].ss-svc:hover {
|
|
241
|
+
border-color: var(--ss-line-strong);
|
|
242
|
+
background: var(--ss-bg-elev-hover);
|
|
243
|
+
}
|
|
244
|
+
a.ss-svc:focus-visible,
|
|
245
|
+
[role=button].ss-svc:focus-visible {
|
|
246
|
+
outline: 2px solid var(--ss-primary);
|
|
247
|
+
outline-offset: 2px;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/* Disabled: inert, no affordance. */
|
|
251
|
+
.ss-svc.disabled {
|
|
252
|
+
cursor: default;
|
|
253
|
+
opacity: 0.55;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/* Loading: no affordance, shimmer placeholders. */
|
|
257
|
+
.ss-svc.loading {
|
|
258
|
+
cursor: default;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
.sk {
|
|
262
|
+
background: var(--ss-bg-elev-hover);
|
|
263
|
+
position: relative;
|
|
264
|
+
overflow: hidden;
|
|
265
|
+
}
|
|
266
|
+
.sk::after {
|
|
267
|
+
content: "";
|
|
268
|
+
position: absolute;
|
|
269
|
+
inset: 0;
|
|
270
|
+
transform: translateX(-100%);
|
|
271
|
+
background: linear-gradient(90deg, transparent, var(--ss-hover), transparent);
|
|
272
|
+
animation: sk-shimmer var(--ss-dur-xslow) var(--ss-ease) infinite;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
.sk-name {
|
|
276
|
+
width: 120px;
|
|
277
|
+
height: var(--ss-ui-lg);
|
|
278
|
+
margin-bottom: var(--ss-s-1);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
.sk-host {
|
|
282
|
+
width: 90px;
|
|
283
|
+
height: var(--ss-ui-sm);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
.sk-badge {
|
|
287
|
+
width: 64px;
|
|
288
|
+
height: calc(var(--ss-ui-xs) + var(--ss-badge-py) * 2);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
.sk-spark {
|
|
292
|
+
width: 100%;
|
|
293
|
+
height: var(--ss-icon);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
@keyframes sk-shimmer {
|
|
297
|
+
100% {
|
|
298
|
+
transform: translateX(100%);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
@media (prefers-reduced-motion: reduce) {
|
|
302
|
+
.sk::after {
|
|
303
|
+
animation: none;
|
|
304
|
+
}
|
|
109
305
|
}</style>
|
|
@@ -1,11 +1,23 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
1
2
|
import { type Size } from '../config.js';
|
|
3
|
+
type Status = 'up' | 'deg' | 'down' | 'maint';
|
|
2
4
|
interface Props {
|
|
3
5
|
name: string;
|
|
4
6
|
host: string;
|
|
5
|
-
status?:
|
|
7
|
+
status?: Status;
|
|
6
8
|
latency?: string;
|
|
7
9
|
spark?: number[];
|
|
8
10
|
onclick?: () => void;
|
|
11
|
+
/** When set, the card renders as a real `<a>` and navigates here (native Enter). */
|
|
12
|
+
href?: string;
|
|
13
|
+
/** Render skeleton placeholders and mark the card `aria-busy`; suppresses interaction. */
|
|
14
|
+
loading?: boolean;
|
|
15
|
+
/** Non-interactive variant: `aria-disabled`, no focus/pointer, no onclick. */
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
/** "Last checked" instant; rendered as relative time in a `<time datetime>` footer slot. */
|
|
18
|
+
updatedAt?: Date | string;
|
|
19
|
+
/** Optional extra metadata rows (version, IP, tags…) below the head. */
|
|
20
|
+
meta?: Snippet;
|
|
9
21
|
/** Token size (sm|md|lg); inherits the global size when unset. */
|
|
10
22
|
size?: Size;
|
|
11
23
|
}
|