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,39 +1,222 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { resolveComponentSize, type Size } from '../config.js'
|
|
3
3
|
|
|
4
|
+
type Trend = 'auto' | 'up' | 'down' | 'flat' | 'none'
|
|
5
|
+
type Variant = 'bars' | 'line' | 'area'
|
|
6
|
+
|
|
4
7
|
interface Props {
|
|
5
8
|
data: number[]
|
|
9
|
+
/** Bar/line fill. Ignored when `trend` resolves to a non-`none` direction. */
|
|
6
10
|
color?: string
|
|
7
11
|
/** Token size (sm|md|lg); inherits the global size when unset. */
|
|
8
12
|
size?: Size
|
|
9
|
-
/** Accessible label;
|
|
13
|
+
/** Accessible label; overrides the auto-generated summary as the accessible name. */
|
|
10
14
|
label?: string
|
|
15
|
+
/** Lower bound of the scale. Defaults to the data min — set to fix the scale across rows. */
|
|
16
|
+
min?: number
|
|
17
|
+
/** Upper bound of the scale. Defaults to the data max — set to fix the scale across rows. */
|
|
18
|
+
max?: number
|
|
19
|
+
/** Colour by direction. `auto` derives first-vs-last → success/danger/muted. Default `none`. */
|
|
20
|
+
trend?: Trend
|
|
21
|
+
/** Rendering style. Default `bars`. */
|
|
22
|
+
variant?: Variant
|
|
23
|
+
/** Flex the chart to fill its container width (table-cell friendly). */
|
|
24
|
+
fluid?: boolean
|
|
25
|
+
/** Explicit CSS width (e.g. `'120px'`, `'100%'`). Overrides the intrinsic width. */
|
|
26
|
+
width?: string
|
|
27
|
+
/** Format a value for the screen-reader summary (e.g. `v => v + '%'`). */
|
|
28
|
+
valueFormat?: (v: number) => string
|
|
29
|
+
/** Replace the auto-generated screen-reader summary entirely. */
|
|
30
|
+
summary?: string
|
|
31
|
+
}
|
|
32
|
+
let {
|
|
33
|
+
data,
|
|
34
|
+
color = 'var(--ss-primary)',
|
|
35
|
+
size,
|
|
36
|
+
label,
|
|
37
|
+
min,
|
|
38
|
+
max,
|
|
39
|
+
trend = 'none',
|
|
40
|
+
variant = 'bars',
|
|
41
|
+
fluid = false,
|
|
42
|
+
width,
|
|
43
|
+
valueFormat,
|
|
44
|
+
summary
|
|
45
|
+
}: Props = $props()
|
|
46
|
+
|
|
47
|
+
const fmt = $derived(valueFormat ?? ((v: number) => String(v)))
|
|
48
|
+
|
|
49
|
+
// Scale bounds: explicit props win, else derive from the data's real range.
|
|
50
|
+
const lo = $derived(min ?? (data.length ? Math.min(...data) : 0))
|
|
51
|
+
const hi = $derived(max ?? (data.length ? Math.max(...data) : 1))
|
|
52
|
+
const range = $derived(hi - lo)
|
|
53
|
+
|
|
54
|
+
/** Normalise a value into 0..1 across [lo,hi]; flat range pins to the mid-line. */
|
|
55
|
+
function norm(v: number): number {
|
|
56
|
+
if (range <= 0) return 0.5
|
|
57
|
+
return Math.min(1, Math.max(0, (v - lo) / range))
|
|
11
58
|
}
|
|
12
|
-
let { data, color = 'var(--ss-primary)', size, label }: Props = $props()
|
|
13
59
|
|
|
14
|
-
|
|
60
|
+
// Resolved trend direction (auto derives from first-vs-last).
|
|
61
|
+
const direction = $derived.by<'up' | 'down' | 'flat' | 'none'>(() => {
|
|
62
|
+
if (trend === 'none') return 'none'
|
|
63
|
+
if (trend !== 'auto') return trend
|
|
64
|
+
if (data.length < 2) return 'flat'
|
|
65
|
+
const d = data[data.length - 1] - data[0]
|
|
66
|
+
if (d > 0) return 'up'
|
|
67
|
+
if (d < 0) return 'down'
|
|
68
|
+
return 'flat'
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
// Colour: a resolved direction overrides the `color` prop.
|
|
72
|
+
const fill = $derived.by(() => {
|
|
73
|
+
switch (direction) {
|
|
74
|
+
case 'up': return 'var(--ss-success)'
|
|
75
|
+
case 'down': return 'var(--ss-danger)'
|
|
76
|
+
case 'flat': return 'var(--ss-fg-muted)'
|
|
77
|
+
default: return color
|
|
78
|
+
}
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
// Screen-reader summary: first→last, direction, min/max, n points.
|
|
82
|
+
const autoSummary = $derived.by(() => {
|
|
83
|
+
if (!data.length) return 'No data'
|
|
84
|
+
if (data.length === 1) return `Single value ${fmt(data[0])}`
|
|
85
|
+
const first = data[0]
|
|
86
|
+
const last = data[data.length - 1]
|
|
87
|
+
const dmin = Math.min(...data)
|
|
88
|
+
const dmax = Math.max(...data)
|
|
89
|
+
const arrow = last > first ? 'rising' : last < first ? 'falling' : 'flat'
|
|
90
|
+
return `Trend ${arrow}: ${fmt(first)} to ${fmt(last)} over ${data.length} points, range ${fmt(dmin)} to ${fmt(dmax)}.`
|
|
91
|
+
})
|
|
92
|
+
const srText = $derived(summary ?? autoSummary)
|
|
93
|
+
const accName = $derived(label ?? srText)
|
|
94
|
+
|
|
95
|
+
// SVG geometry (line/area) on a fixed viewBox; width:100% + viewBox makes it fluid.
|
|
96
|
+
const VB_W = 100
|
|
97
|
+
const VB_H = 100
|
|
98
|
+
const points = $derived.by(() => {
|
|
99
|
+
if (data.length === 0) return []
|
|
100
|
+
if (data.length === 1) {
|
|
101
|
+
const y = VB_H - norm(data[0]) * VB_H
|
|
102
|
+
return [{ x: VB_W / 2, y }]
|
|
103
|
+
}
|
|
104
|
+
return data.map((v, i) => ({
|
|
105
|
+
x: (i / (data.length - 1)) * VB_W,
|
|
106
|
+
y: VB_H - norm(v) * VB_H
|
|
107
|
+
}))
|
|
108
|
+
})
|
|
109
|
+
const polyline = $derived(points.map((p) => `${p.x},${p.y}`).join(' '))
|
|
110
|
+
const areaPath = $derived(
|
|
111
|
+
points.length
|
|
112
|
+
? `M${points[0].x},${VB_H} L` +
|
|
113
|
+
points.map((p) => `${p.x},${p.y}`).join(' ') +
|
|
114
|
+
` L${points[points.length - 1].x},${VB_H} Z`
|
|
115
|
+
: ''
|
|
116
|
+
)
|
|
117
|
+
|
|
118
|
+
const isEmpty = $derived(data.length === 0)
|
|
119
|
+
const isSingle = $derived(data.length === 1)
|
|
120
|
+
|
|
121
|
+
const rootStyle = $derived(
|
|
122
|
+
[width ? `width:${width}` : '', fluid && !width ? 'width:100%' : '']
|
|
123
|
+
.filter(Boolean)
|
|
124
|
+
.join(';')
|
|
125
|
+
)
|
|
15
126
|
</script>
|
|
16
127
|
|
|
17
128
|
<div
|
|
18
129
|
class="ss-spark"
|
|
130
|
+
class:fluid
|
|
131
|
+
data-variant={variant}
|
|
19
132
|
data-size-variant={resolveComponentSize('Sparkline', size)}
|
|
20
|
-
role=
|
|
21
|
-
aria-label={
|
|
22
|
-
|
|
133
|
+
role="img"
|
|
134
|
+
aria-label={accName}
|
|
135
|
+
style={rootStyle || undefined}
|
|
23
136
|
>
|
|
24
|
-
{#
|
|
25
|
-
<
|
|
26
|
-
{
|
|
137
|
+
{#if isEmpty}
|
|
138
|
+
<span class="empty" aria-hidden="true">—</span>
|
|
139
|
+
{:else if variant === 'bars'}
|
|
140
|
+
{#if isSingle}
|
|
141
|
+
<i
|
|
142
|
+
class="single"
|
|
143
|
+
aria-hidden="true"
|
|
144
|
+
style="height:{Math.max(8, norm(data[0]) * 100)}%;background:{fill}"
|
|
145
|
+
></i>
|
|
146
|
+
{:else}
|
|
147
|
+
{#each data as v}
|
|
148
|
+
<i aria-hidden="true" style="height:{Math.max(8, norm(v) * 100)}%;background:{fill}"></i>
|
|
149
|
+
{/each}
|
|
150
|
+
{/if}
|
|
151
|
+
{:else}
|
|
152
|
+
<svg
|
|
153
|
+
class="chart"
|
|
154
|
+
viewBox="0 0 {VB_W} {VB_H}"
|
|
155
|
+
preserveAspectRatio="none"
|
|
156
|
+
aria-hidden="true"
|
|
157
|
+
focusable="false"
|
|
158
|
+
>
|
|
159
|
+
{#if variant === 'area' && areaPath}
|
|
160
|
+
<path class="area" d={areaPath} style="fill:{fill}" />
|
|
161
|
+
{/if}
|
|
162
|
+
{#if isSingle}
|
|
163
|
+
<circle class="marker" cx={points[0].x} cy={points[0].y} r="3" style="fill:{fill}" />
|
|
164
|
+
{:else}
|
|
165
|
+
<polyline class="line" points={polyline} style="stroke:{fill}" />
|
|
166
|
+
{/if}
|
|
167
|
+
</svg>
|
|
168
|
+
{/if}
|
|
27
169
|
</div>
|
|
28
170
|
|
|
29
171
|
<style>.ss-spark {
|
|
30
|
-
display: flex;
|
|
172
|
+
display: inline-flex;
|
|
31
173
|
align-items: flex-end;
|
|
32
|
-
gap: 1px;
|
|
33
|
-
height: 18px;
|
|
174
|
+
gap: var(--ss-spark-gap, 1px);
|
|
175
|
+
height: var(--ss-spark-h, 18px);
|
|
176
|
+
position: relative;
|
|
177
|
+
}
|
|
178
|
+
.ss-spark.fluid {
|
|
179
|
+
width: 100%;
|
|
34
180
|
}
|
|
35
181
|
.ss-spark i {
|
|
36
|
-
width: 3px;
|
|
182
|
+
width: var(--ss-spark-bar-w, 3px);
|
|
37
183
|
background: var(--ss-primary);
|
|
38
184
|
opacity: 0.85;
|
|
185
|
+
border-radius: 0;
|
|
186
|
+
}
|
|
187
|
+
.ss-spark.fluid i {
|
|
188
|
+
flex: 1 1 0;
|
|
189
|
+
width: auto;
|
|
190
|
+
min-width: 1px;
|
|
191
|
+
}
|
|
192
|
+
.ss-spark .single {
|
|
193
|
+
margin: 0 auto;
|
|
194
|
+
}
|
|
195
|
+
.ss-spark .empty {
|
|
196
|
+
align-self: center;
|
|
197
|
+
margin: auto;
|
|
198
|
+
color: var(--ss-fg-muted);
|
|
199
|
+
font-family: var(--ss-font-mono);
|
|
200
|
+
line-height: 1;
|
|
201
|
+
}
|
|
202
|
+
.ss-spark .chart {
|
|
203
|
+
display: block;
|
|
204
|
+
width: 100%;
|
|
205
|
+
height: 100%;
|
|
206
|
+
overflow: visible;
|
|
207
|
+
}
|
|
208
|
+
.ss-spark .line {
|
|
209
|
+
fill: none;
|
|
210
|
+
stroke: var(--ss-primary);
|
|
211
|
+
stroke-width: 1.5;
|
|
212
|
+
vector-effect: non-scaling-stroke;
|
|
213
|
+
stroke-linejoin: round;
|
|
214
|
+
stroke-linecap: round;
|
|
215
|
+
}
|
|
216
|
+
.ss-spark .area {
|
|
217
|
+
opacity: 0.22;
|
|
218
|
+
stroke: none;
|
|
219
|
+
}
|
|
220
|
+
.ss-spark .marker {
|
|
221
|
+
fill: var(--ss-primary);
|
|
39
222
|
}</style>
|
|
@@ -1,11 +1,30 @@
|
|
|
1
1
|
import { type Size } from '../config.js';
|
|
2
|
+
type Trend = 'auto' | 'up' | 'down' | 'flat' | 'none';
|
|
3
|
+
type Variant = 'bars' | 'line' | 'area';
|
|
2
4
|
interface Props {
|
|
3
5
|
data: number[];
|
|
6
|
+
/** Bar/line fill. Ignored when `trend` resolves to a non-`none` direction. */
|
|
4
7
|
color?: string;
|
|
5
8
|
/** Token size (sm|md|lg); inherits the global size when unset. */
|
|
6
9
|
size?: Size;
|
|
7
|
-
/** Accessible label;
|
|
10
|
+
/** Accessible label; overrides the auto-generated summary as the accessible name. */
|
|
8
11
|
label?: string;
|
|
12
|
+
/** Lower bound of the scale. Defaults to the data min — set to fix the scale across rows. */
|
|
13
|
+
min?: number;
|
|
14
|
+
/** Upper bound of the scale. Defaults to the data max — set to fix the scale across rows. */
|
|
15
|
+
max?: number;
|
|
16
|
+
/** Colour by direction. `auto` derives first-vs-last → success/danger/muted. Default `none`. */
|
|
17
|
+
trend?: Trend;
|
|
18
|
+
/** Rendering style. Default `bars`. */
|
|
19
|
+
variant?: Variant;
|
|
20
|
+
/** Flex the chart to fill its container width (table-cell friendly). */
|
|
21
|
+
fluid?: boolean;
|
|
22
|
+
/** Explicit CSS width (e.g. `'120px'`, `'100%'`). Overrides the intrinsic width. */
|
|
23
|
+
width?: string;
|
|
24
|
+
/** Format a value for the screen-reader summary (e.g. `v => v + '%'`). */
|
|
25
|
+
valueFormat?: (v: number) => string;
|
|
26
|
+
/** Replace the auto-generated screen-reader summary entirely. */
|
|
27
|
+
summary?: string;
|
|
9
28
|
}
|
|
10
29
|
declare const Sparkline: import("svelte").Component<Props, {}, "">;
|
|
11
30
|
type Sparkline = ReturnType<typeof Sparkline>;
|
|
@@ -1,46 +1,169 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { fly } from 'svelte/transition'
|
|
3
3
|
import { prefersReducedMotion } from 'svelte/motion'
|
|
4
|
-
import { toasts, type ToastKind } from '../toast.svelte.js'
|
|
4
|
+
import { toasts, type Toast, type ToastKind } from '../toast.svelte.js'
|
|
5
5
|
import { resolveComponentSize, type Size } from '../config.js'
|
|
6
6
|
|
|
7
|
+
type Position =
|
|
8
|
+
| 'top-right'
|
|
9
|
+
| 'top-left'
|
|
10
|
+
| 'bottom-right'
|
|
11
|
+
| 'bottom-left'
|
|
12
|
+
| 'top-center'
|
|
13
|
+
| 'bottom-center'
|
|
14
|
+
|
|
7
15
|
interface Props {
|
|
8
16
|
/** Token size (sm|md|lg); inherits the global size when unset. */
|
|
9
17
|
size?: Size
|
|
18
|
+
/** Where the stack anchors on screen. @default 'top-right' */
|
|
19
|
+
position?: Position
|
|
10
20
|
}
|
|
11
21
|
|
|
12
|
-
let { size }: Props = $props()
|
|
22
|
+
let { size, position = 'top-right' }: Props = $props()
|
|
13
23
|
|
|
14
|
-
const glyph: Record<ToastKind, string> = { success: '✓', error: '✕', info: 'i' }
|
|
24
|
+
const glyph: Record<ToastKind, string> = { success: '✓', error: '✕', info: 'i', loading: '' }
|
|
15
25
|
// Honor prefers-reduced-motion: collapse the fly transition to an instant swap.
|
|
16
|
-
const
|
|
26
|
+
const reduce = $derived(prefersReducedMotion.current)
|
|
27
|
+
const flyDuration = $derived(reduce ? 0 : 180)
|
|
28
|
+
// Bottom anchors slide in from below; centered ones come straight down/up.
|
|
29
|
+
const flyX = $derived(position.endsWith('center') ? 0 : position.endsWith('left') ? -16 : 16)
|
|
30
|
+
const flyY = $derived(position.endsWith('center') ? (position.startsWith('top') ? -16 : 16) : 0)
|
|
31
|
+
|
|
32
|
+
// ── swipe-to-dismiss ──────────────────────────────────────────────
|
|
33
|
+
let dragId = $state<number | null>(null)
|
|
34
|
+
let dragDx = $state(0)
|
|
35
|
+
let dragStartX = 0
|
|
36
|
+
let dragPointer: number | null = null
|
|
37
|
+
|
|
38
|
+
const SWIPE_THRESHOLD = 64
|
|
39
|
+
|
|
40
|
+
function onPointerDown(e: PointerEvent, t: Toast) {
|
|
41
|
+
if (reduce || e.button !== 0) return
|
|
42
|
+
// Ignore drags that start on the controls (buttons own their clicks).
|
|
43
|
+
if ((e.target as HTMLElement).closest('button')) return
|
|
44
|
+
dragId = t.id
|
|
45
|
+
dragDx = 0
|
|
46
|
+
dragStartX = e.clientX
|
|
47
|
+
dragPointer = e.pointerId
|
|
48
|
+
toasts.pause(t.id)
|
|
49
|
+
;(e.currentTarget as HTMLElement).setPointerCapture(e.pointerId)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function onPointerMove(e: PointerEvent, t: Toast) {
|
|
53
|
+
if (dragId !== t.id || e.pointerId !== dragPointer) return
|
|
54
|
+
dragDx = e.clientX - dragStartX
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function endDrag(e: PointerEvent, t: Toast) {
|
|
58
|
+
if (dragId !== t.id || e.pointerId !== dragPointer) return
|
|
59
|
+
const passed = Math.abs(dragDx) >= SWIPE_THRESHOLD
|
|
60
|
+
dragId = null
|
|
61
|
+
dragPointer = null
|
|
62
|
+
if (passed) toasts.dismiss(t.id)
|
|
63
|
+
else {
|
|
64
|
+
dragDx = 0
|
|
65
|
+
toasts.resume(t.id)
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function runAction(t: Toast) {
|
|
70
|
+
const keep = t.action?.onClick() === false
|
|
71
|
+
if (!keep) toasts.dismiss(t.id)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function onKeydown(e: KeyboardEvent, t: Toast) {
|
|
75
|
+
if (e.key === 'Escape') {
|
|
76
|
+
e.stopPropagation()
|
|
77
|
+
toasts.dismiss(t.id)
|
|
78
|
+
}
|
|
79
|
+
}
|
|
17
80
|
</script>
|
|
18
81
|
|
|
19
|
-
<div
|
|
82
|
+
<div
|
|
83
|
+
class="ss-toaster"
|
|
84
|
+
aria-label="Notifications"
|
|
85
|
+
data-position={position}
|
|
86
|
+
data-size-variant={resolveComponentSize('Toaster', size)}
|
|
87
|
+
>
|
|
20
88
|
{#each toasts.items as t (t.id)}
|
|
21
89
|
<div
|
|
22
90
|
class="ss-toast {t.kind}"
|
|
91
|
+
class:dragging={dragId === t.id}
|
|
23
92
|
role={t.kind === 'error' ? 'alert' : 'status'}
|
|
24
93
|
aria-live={t.kind === 'error' ? 'assertive' : 'polite'}
|
|
25
|
-
|
|
94
|
+
tabindex="-1"
|
|
95
|
+
style:transform={dragId === t.id ? `translateX(${dragDx}px)` : undefined}
|
|
96
|
+
style:opacity={dragId === t.id
|
|
97
|
+
? Math.max(0.3, 1 - Math.abs(dragDx) / 200)
|
|
98
|
+
: undefined}
|
|
99
|
+
transition:fly={{ x: flyX, y: flyY, duration: flyDuration }}
|
|
100
|
+
onpointerenter={() => toasts.pause(t.id)}
|
|
101
|
+
onpointerleave={() => dragId !== t.id && toasts.resume(t.id)}
|
|
102
|
+
onfocusin={() => toasts.pause(t.id)}
|
|
103
|
+
onfocusout={() => toasts.resume(t.id)}
|
|
104
|
+
onpointerdown={(e) => onPointerDown(e, t)}
|
|
105
|
+
onpointermove={(e) => onPointerMove(e, t)}
|
|
106
|
+
onpointerup={(e) => endDrag(e, t)}
|
|
107
|
+
onpointercancel={(e) => endDrag(e, t)}
|
|
108
|
+
onkeydown={(e) => onKeydown(e, t)}
|
|
26
109
|
>
|
|
27
|
-
|
|
110
|
+
{#if t.kind === 'loading'}
|
|
111
|
+
<span class="ic spinner" class:still={reduce} aria-hidden="true"></span>
|
|
112
|
+
{:else}
|
|
113
|
+
<span class="ic" aria-hidden="true">{glyph[t.kind]}</span>
|
|
114
|
+
{/if}
|
|
28
115
|
<span class="msg">{t.message}</span>
|
|
29
|
-
|
|
116
|
+
{#if t.action}
|
|
117
|
+
<button class="action" type="button" onclick={() => runAction(t)}>
|
|
118
|
+
{t.action.label}
|
|
119
|
+
</button>
|
|
120
|
+
{/if}
|
|
121
|
+
<button class="x" type="button" aria-label="Dismiss" onclick={() => toasts.dismiss(t.id)}
|
|
122
|
+
>×</button
|
|
123
|
+
>
|
|
30
124
|
</div>
|
|
31
125
|
{/each}
|
|
32
126
|
</div>
|
|
33
127
|
|
|
34
128
|
<style>.ss-toaster {
|
|
35
129
|
position: fixed;
|
|
36
|
-
top: var(--ss-s-4);
|
|
37
|
-
right: var(--ss-s-4);
|
|
38
130
|
z-index: 1000;
|
|
39
131
|
display: flex;
|
|
40
132
|
flex-direction: column;
|
|
41
133
|
gap: var(--ss-s-2);
|
|
42
134
|
max-width: min(360px, 100vw - var(--ss-s-8));
|
|
43
135
|
pointer-events: none;
|
|
136
|
+
top: var(--ss-s-4);
|
|
137
|
+
right: var(--ss-s-4);
|
|
138
|
+
}
|
|
139
|
+
.ss-toaster[data-position=top-left] {
|
|
140
|
+
right: auto;
|
|
141
|
+
left: var(--ss-s-4);
|
|
142
|
+
}
|
|
143
|
+
.ss-toaster[data-position=bottom-right] {
|
|
144
|
+
top: auto;
|
|
145
|
+
bottom: var(--ss-s-4);
|
|
146
|
+
flex-direction: column-reverse;
|
|
147
|
+
}
|
|
148
|
+
.ss-toaster[data-position=bottom-left] {
|
|
149
|
+
top: auto;
|
|
150
|
+
right: auto;
|
|
151
|
+
bottom: var(--ss-s-4);
|
|
152
|
+
left: var(--ss-s-4);
|
|
153
|
+
flex-direction: column-reverse;
|
|
154
|
+
}
|
|
155
|
+
.ss-toaster[data-position=top-center] {
|
|
156
|
+
right: auto;
|
|
157
|
+
left: 50%;
|
|
158
|
+
transform: translateX(-50%);
|
|
159
|
+
}
|
|
160
|
+
.ss-toaster[data-position=bottom-center] {
|
|
161
|
+
top: auto;
|
|
162
|
+
right: auto;
|
|
163
|
+
bottom: var(--ss-s-4);
|
|
164
|
+
left: 50%;
|
|
165
|
+
transform: translateX(-50%);
|
|
166
|
+
flex-direction: column-reverse;
|
|
44
167
|
}
|
|
45
168
|
|
|
46
169
|
.ss-toast {
|
|
@@ -56,6 +179,15 @@
|
|
|
56
179
|
font-family: var(--ss-font-mono);
|
|
57
180
|
font-size: var(--ss-ui-md);
|
|
58
181
|
color: var(--ss-fg);
|
|
182
|
+
touch-action: pan-y;
|
|
183
|
+
outline: none;
|
|
184
|
+
}
|
|
185
|
+
.ss-toast:focus-visible {
|
|
186
|
+
border-color: var(--ss-line-strong);
|
|
187
|
+
box-shadow: var(--ss-shadow-pop), 0 0 0 2px var(--ss-primary);
|
|
188
|
+
}
|
|
189
|
+
.ss-toast:not(.dragging) {
|
|
190
|
+
transition: transform var(--ss-dur-fast) var(--ss-ease);
|
|
59
191
|
}
|
|
60
192
|
.ss-toast.success {
|
|
61
193
|
border-left-color: var(--ss-primary);
|
|
@@ -66,12 +198,15 @@
|
|
|
66
198
|
.ss-toast.info {
|
|
67
199
|
border-left-color: var(--ss-cyan);
|
|
68
200
|
}
|
|
201
|
+
.ss-toast.loading {
|
|
202
|
+
border-left-color: var(--ss-fg-faint);
|
|
203
|
+
}
|
|
69
204
|
.ss-toast .ic {
|
|
70
205
|
display: inline-flex;
|
|
71
206
|
align-items: center;
|
|
72
207
|
justify-content: center;
|
|
73
|
-
width:
|
|
74
|
-
height:
|
|
208
|
+
width: var(--ss-toast-ic);
|
|
209
|
+
height: var(--ss-toast-ic);
|
|
75
210
|
font-size: var(--ss-ui-sm);
|
|
76
211
|
color: var(--ss-fg-on-primary);
|
|
77
212
|
flex: none;
|
|
@@ -85,10 +220,40 @@
|
|
|
85
220
|
.ss-toast.info .ic {
|
|
86
221
|
background: var(--ss-cyan);
|
|
87
222
|
}
|
|
223
|
+
.ss-toast .spinner {
|
|
224
|
+
box-sizing: border-box;
|
|
225
|
+
background: transparent;
|
|
226
|
+
border: 2px solid var(--ss-line-strong);
|
|
227
|
+
border-top-color: var(--ss-cyan);
|
|
228
|
+
animation: ss-toast-spin 0.7s linear infinite;
|
|
229
|
+
}
|
|
230
|
+
.ss-toast .spinner.still {
|
|
231
|
+
animation: none;
|
|
232
|
+
border-color: var(--ss-cyan);
|
|
233
|
+
}
|
|
88
234
|
.ss-toast .msg {
|
|
89
235
|
flex: 1;
|
|
90
236
|
line-height: 1.3;
|
|
91
237
|
}
|
|
238
|
+
.ss-toast .action {
|
|
239
|
+
flex: none;
|
|
240
|
+
background: none;
|
|
241
|
+
border: 1px solid var(--ss-line-strong);
|
|
242
|
+
color: var(--ss-fg);
|
|
243
|
+
cursor: pointer;
|
|
244
|
+
font-family: inherit;
|
|
245
|
+
font-size: var(--ss-ui-sm);
|
|
246
|
+
line-height: 1;
|
|
247
|
+
padding: var(--ss-s-1) var(--ss-s-2);
|
|
248
|
+
}
|
|
249
|
+
.ss-toast .action:hover {
|
|
250
|
+
background: var(--ss-hover);
|
|
251
|
+
border-color: var(--ss-fg-faint);
|
|
252
|
+
}
|
|
253
|
+
.ss-toast .action:focus-visible {
|
|
254
|
+
outline: 2px solid var(--ss-primary);
|
|
255
|
+
outline-offset: 1px;
|
|
256
|
+
}
|
|
92
257
|
.ss-toast .x {
|
|
93
258
|
flex: none;
|
|
94
259
|
background: none;
|
|
@@ -101,4 +266,20 @@
|
|
|
101
266
|
}
|
|
102
267
|
.ss-toast .x:hover {
|
|
103
268
|
color: var(--ss-fg);
|
|
269
|
+
}
|
|
270
|
+
.ss-toast .x:focus-visible {
|
|
271
|
+
outline: 2px solid var(--ss-primary);
|
|
272
|
+
outline-offset: 1px;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
@keyframes ss-toast-spin {
|
|
276
|
+
to {
|
|
277
|
+
transform: rotate(360deg);
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
@media (prefers-reduced-motion: reduce) {
|
|
281
|
+
.ss-toast .spinner {
|
|
282
|
+
animation: none;
|
|
283
|
+
border-color: var(--ss-cyan);
|
|
284
|
+
}
|
|
104
285
|
}</style>
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { type Size } from '../config.js';
|
|
2
|
+
type Position = 'top-right' | 'top-left' | 'bottom-right' | 'bottom-left' | 'top-center' | 'bottom-center';
|
|
2
3
|
interface Props {
|
|
3
4
|
/** Token size (sm|md|lg); inherits the global size when unset. */
|
|
4
5
|
size?: Size;
|
|
6
|
+
/** Where the stack anchors on screen. @default 'top-right' */
|
|
7
|
+
position?: Position;
|
|
5
8
|
}
|
|
6
9
|
declare const Toaster: import("svelte").Component<Props, {}, "">;
|
|
7
10
|
type Toaster = ReturnType<typeof Toaster>;
|