dssoca 0.5.0 → 0.9.0
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 +39 -13
- package/dist/components/Accordion.svelte +297 -0
- package/dist/components/Accordion.svelte.d.ts +51 -0
- package/dist/components/Badge.svelte +113 -18
- package/dist/components/Badge.svelte.d.ts +28 -2
- package/dist/components/BottomNav.svelte +254 -0
- package/dist/components/BottomNav.svelte.d.ts +32 -0
- package/dist/components/Button.svelte +147 -10
- package/dist/components/Button.svelte.d.ts +21 -4
- package/dist/components/Card.svelte +173 -8
- package/dist/components/Card.svelte.d.ts +16 -1
- package/dist/components/Container.svelte +55 -0
- package/dist/components/Container.svelte.d.ts +16 -0
- package/dist/components/EmptyState.svelte +91 -9
- package/dist/components/EmptyState.svelte.d.ts +20 -3
- package/dist/components/Heading.svelte +83 -0
- package/dist/components/Heading.svelte.d.ts +17 -0
- package/dist/components/Icon.svelte +199 -24
- package/dist/components/Icon.svelte.d.ts +70 -2
- package/dist/components/Image.svelte +428 -0
- package/dist/components/Image.svelte.d.ts +49 -0
- package/dist/components/Input.svelte +173 -39
- package/dist/components/Input.svelte.d.ts +22 -0
- package/dist/components/Link.svelte +183 -0
- package/dist/components/Link.svelte.d.ts +29 -0
- package/dist/components/LogStream.svelte +403 -47
- package/dist/components/LogStream.svelte.d.ts +35 -7
- package/dist/components/Menu.svelte +408 -0
- package/dist/components/Menu.svelte.d.ts +66 -0
- package/dist/components/MetricTile.svelte +124 -12
- package/dist/components/MetricTile.svelte.d.ts +20 -0
- package/dist/components/SegmentedControl.svelte +220 -0
- package/dist/components/SegmentedControl.svelte.d.ts +37 -0
- package/dist/components/ServiceCard.svelte +226 -30
- package/dist/components/ServiceCard.svelte.d.ts +13 -1
- package/dist/components/Sidebar.svelte +377 -40
- package/dist/components/Sidebar.svelte.d.ts +18 -7
- package/dist/components/Sparkline.svelte +198 -13
- package/dist/components/Sparkline.svelte.d.ts +20 -1
- package/dist/components/Spinner.svelte +124 -0
- package/dist/components/Spinner.svelte.d.ts +74 -0
- package/dist/components/Textarea.svelte +214 -0
- package/dist/components/Textarea.svelte.d.ts +38 -0
- package/dist/components/Toaster.svelte +209 -12
- package/dist/components/Toaster.svelte.d.ts +3 -0
- package/dist/components/Topbar.svelte +293 -42
- package/dist/components/Topbar.svelte.d.ts +48 -1
- package/dist/dssoca.config.d.ts +1 -1
- package/dist/dssoca.config.js +10 -0
- package/dist/index.d.ts +16 -3
- package/dist/index.js +18 -2
- package/dist/theme.css +406 -24
- package/dist/toast.svelte.d.ts +49 -5
- package/dist/toast.svelte.js +165 -9
- package/dist/tokens.css +597 -0
- package/package.json +25 -4
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
<script module lang="ts">
|
|
2
|
+
/** One responsive source for an {@link Image} `<picture>`. */
|
|
3
|
+
export interface ImageSource {
|
|
4
|
+
srcset: string
|
|
5
|
+
/** e.g. '(max-width: 600px)' or a type like 'image/webp'. */
|
|
6
|
+
media?: string
|
|
7
|
+
type?: string
|
|
8
|
+
/** Per-source `sizes` hint for the browser's resource selection. */
|
|
9
|
+
sizes?: string
|
|
10
|
+
}
|
|
11
|
+
</script>
|
|
12
|
+
|
|
13
|
+
<script lang="ts">
|
|
14
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
15
|
+
// Image (DS-0055). Responsive <picture>/srcset, aspect-ratio box (no layout
|
|
16
|
+
// shift), lazy + async decode, token-driven loading skeleton + error
|
|
17
|
+
// fallback (reduced-motion safe), optional LIGHTWEIGHT built-in lightbox
|
|
18
|
+
// (role=dialog, aria-modal, focus trap, Esc to close, restores focus).
|
|
19
|
+
//
|
|
20
|
+
// DECISION: ship a built-in dialog overlay rather than depending on
|
|
21
|
+
// PhotoSwipe — dssoca stays zero-runtime-dependency (see PR/doc).
|
|
22
|
+
// ─────────────────────────────────────────────────────────────────────────
|
|
23
|
+
import { tick } from 'svelte'
|
|
24
|
+
import { resolveComponentSize, type Size } from '../config.js'
|
|
25
|
+
|
|
26
|
+
interface Props {
|
|
27
|
+
/** Image URL. */
|
|
28
|
+
src: string
|
|
29
|
+
/** Required alternative text (WCAG 1.1.1). Pass `''` only for purely decorative images. */
|
|
30
|
+
alt: string
|
|
31
|
+
/** Responsive `srcset` for the default `<img>` (used alongside `sources`). */
|
|
32
|
+
srcset?: string
|
|
33
|
+
/** `sizes` hint paired with `srcset`. */
|
|
34
|
+
sizes?: string
|
|
35
|
+
/** Responsive `<picture>` sources; rendered before the fallback `<img>`. */
|
|
36
|
+
sources?: ImageSource[]
|
|
37
|
+
/** Intrinsic width (px) — feeds the aspect-ratio box and the `<img>` attr. */
|
|
38
|
+
width?: number
|
|
39
|
+
/** Intrinsic height (px) — feeds the aspect-ratio box and the `<img>` attr. */
|
|
40
|
+
height?: number
|
|
41
|
+
/**
|
|
42
|
+
* Aspect ratio (w / h) used to reserve space before load. Wins over
|
|
43
|
+
* `width`/`height` when set; otherwise derived from them when both exist.
|
|
44
|
+
*/
|
|
45
|
+
ratio?: number
|
|
46
|
+
/**
|
|
47
|
+
* How the image fills the reserved box once a ratio is known.
|
|
48
|
+
* @default 'cover'
|
|
49
|
+
*/
|
|
50
|
+
fit?: 'cover' | 'contain' | 'fill' | 'none' | 'scale-down'
|
|
51
|
+
/** Eager-load (above-the-fold) — flips `loading`/`decoding`/`fetchpriority`. @default false */
|
|
52
|
+
eager?: boolean
|
|
53
|
+
/** Open a lightweight built-in lightbox overlay on click. @default false */
|
|
54
|
+
lightbox?: boolean
|
|
55
|
+
/** Caption rendered under the image inside a `<figcaption>`. */
|
|
56
|
+
caption?: string
|
|
57
|
+
/** Token size (sm|md|lg); inherits the global size when unset. Affects chrome, not image dims. */
|
|
58
|
+
size?: Size
|
|
59
|
+
/** Extra class on the root `<figure>`. */
|
|
60
|
+
class?: string
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
let {
|
|
64
|
+
src,
|
|
65
|
+
alt,
|
|
66
|
+
srcset,
|
|
67
|
+
sizes,
|
|
68
|
+
sources = [],
|
|
69
|
+
width,
|
|
70
|
+
height,
|
|
71
|
+
ratio,
|
|
72
|
+
fit = 'cover',
|
|
73
|
+
eager = false,
|
|
74
|
+
lightbox = false,
|
|
75
|
+
caption,
|
|
76
|
+
size,
|
|
77
|
+
class: className,
|
|
78
|
+
}: Props = $props()
|
|
79
|
+
|
|
80
|
+
// Reserve space before load → no layout shift (CLS). Prefer an explicit
|
|
81
|
+
// ratio, else derive from intrinsic width/height. `null` → no box reserved.
|
|
82
|
+
const aspect = $derived(
|
|
83
|
+
ratio && ratio > 0 ? ratio : width && height && height > 0 ? width / height : null,
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
type State = 'loading' | 'loaded' | 'error'
|
|
87
|
+
let loadState = $state<State>('loading')
|
|
88
|
+
|
|
89
|
+
function onLoad() {
|
|
90
|
+
loadState = 'loaded'
|
|
91
|
+
}
|
|
92
|
+
function onError() {
|
|
93
|
+
loadState = 'error'
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// ── Lightbox ───────────────────────────────────────────────────────────
|
|
97
|
+
let open = $state(false)
|
|
98
|
+
let trigger = $state<HTMLButtonElement | null>(null)
|
|
99
|
+
let dialog = $state<HTMLDivElement | null>(null)
|
|
100
|
+
let closeBtn = $state<HTMLButtonElement | null>(null)
|
|
101
|
+
|
|
102
|
+
const canOpen = $derived(lightbox && loadState !== 'error')
|
|
103
|
+
|
|
104
|
+
async function openLightbox() {
|
|
105
|
+
if (!canOpen) return
|
|
106
|
+
open = true
|
|
107
|
+
await tick()
|
|
108
|
+
closeBtn?.focus()
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
function closeLightbox() {
|
|
112
|
+
open = false
|
|
113
|
+
// Restore focus to the trigger (WCAG 2.4.3).
|
|
114
|
+
trigger?.focus()
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Focus trap + Esc, scoped to the dialog (keeps Tab inside the overlay).
|
|
118
|
+
function onDialogKeydown(e: KeyboardEvent) {
|
|
119
|
+
if (e.key === 'Escape') {
|
|
120
|
+
e.preventDefault()
|
|
121
|
+
e.stopPropagation()
|
|
122
|
+
closeLightbox()
|
|
123
|
+
return
|
|
124
|
+
}
|
|
125
|
+
if (e.key !== 'Tab' || !dialog) return
|
|
126
|
+
// DS-0078: exclude disabled focusables (and anything opted out of the tab
|
|
127
|
+
// order with tabindex="-1", e.g. the backdrop button) so the trap never
|
|
128
|
+
// wraps relative to an element that cannot actually take tab focus.
|
|
129
|
+
const focusables = dialog.querySelectorAll<HTMLElement>(
|
|
130
|
+
[
|
|
131
|
+
'button:not([disabled]):not([aria-disabled="true"]):not([tabindex="-1"])',
|
|
132
|
+
'[href]:not([aria-disabled="true"]):not([tabindex="-1"])',
|
|
133
|
+
'[tabindex]:not([tabindex="-1"]):not([disabled]):not([aria-disabled="true"])',
|
|
134
|
+
].join(', '),
|
|
135
|
+
)
|
|
136
|
+
if (focusables.length === 0) return
|
|
137
|
+
const first = focusables[0]
|
|
138
|
+
const last = focusables[focusables.length - 1]
|
|
139
|
+
const active = document.activeElement
|
|
140
|
+
if (e.shiftKey && active === first) {
|
|
141
|
+
e.preventDefault()
|
|
142
|
+
last.focus()
|
|
143
|
+
} else if (!e.shiftKey && active === last) {
|
|
144
|
+
e.preventDefault()
|
|
145
|
+
first.focus()
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
</script>
|
|
149
|
+
|
|
150
|
+
<figure
|
|
151
|
+
class="ss-image {className ?? ''}"
|
|
152
|
+
class:is-loading={loadState === 'loading'}
|
|
153
|
+
class:is-error={loadState === 'error'}
|
|
154
|
+
class:has-ratio={aspect != null}
|
|
155
|
+
data-size-variant={resolveComponentSize('Image', size)}
|
|
156
|
+
>
|
|
157
|
+
<div
|
|
158
|
+
class="frame"
|
|
159
|
+
style:aspect-ratio={aspect != null ? `${aspect}` : undefined}
|
|
160
|
+
aria-busy={loadState === 'loading'}
|
|
161
|
+
>
|
|
162
|
+
{#if loadState === 'error'}
|
|
163
|
+
<div class="fallback" role="img" aria-label={alt || 'Image failed to load'}>
|
|
164
|
+
<span class="glyph" aria-hidden="true">⊘</span>
|
|
165
|
+
</div>
|
|
166
|
+
{:else}
|
|
167
|
+
{#if loadState === 'loading'}
|
|
168
|
+
<div class="skeleton" aria-hidden="true"></div>
|
|
169
|
+
{/if}
|
|
170
|
+
{#if canOpen}
|
|
171
|
+
<button
|
|
172
|
+
bind:this={trigger}
|
|
173
|
+
type="button"
|
|
174
|
+
class="trigger"
|
|
175
|
+
aria-haspopup="dialog"
|
|
176
|
+
aria-label={alt ? `View image: ${alt}` : 'View image full size'}
|
|
177
|
+
onclick={openLightbox}
|
|
178
|
+
>
|
|
179
|
+
{@render media()}
|
|
180
|
+
</button>
|
|
181
|
+
{:else}
|
|
182
|
+
{@render media()}
|
|
183
|
+
{/if}
|
|
184
|
+
{/if}
|
|
185
|
+
</div>
|
|
186
|
+
{#if caption}<figcaption>{caption}</figcaption>{/if}
|
|
187
|
+
</figure>
|
|
188
|
+
|
|
189
|
+
{#snippet media()}
|
|
190
|
+
<picture>
|
|
191
|
+
{#each sources as s (s.srcset)}
|
|
192
|
+
<source srcset={s.srcset} media={s.media} type={s.type} sizes={s.sizes} />
|
|
193
|
+
{/each}
|
|
194
|
+
<img
|
|
195
|
+
{src}
|
|
196
|
+
{alt}
|
|
197
|
+
{srcset}
|
|
198
|
+
{sizes}
|
|
199
|
+
{width}
|
|
200
|
+
{height}
|
|
201
|
+
class="img"
|
|
202
|
+
style:object-fit={aspect != null ? fit : undefined}
|
|
203
|
+
loading={eager ? 'eager' : 'lazy'}
|
|
204
|
+
decoding={eager ? 'auto' : 'async'}
|
|
205
|
+
fetchpriority={eager ? 'high' : undefined}
|
|
206
|
+
onload={onLoad}
|
|
207
|
+
onerror={onError}
|
|
208
|
+
/>
|
|
209
|
+
</picture>
|
|
210
|
+
{/snippet}
|
|
211
|
+
|
|
212
|
+
{#if open}
|
|
213
|
+
<!-- Built-in lightbox: dialog semantics + focus trap; backdrop click closes. -->
|
|
214
|
+
<div
|
|
215
|
+
bind:this={dialog}
|
|
216
|
+
class="ss-image-lightbox"
|
|
217
|
+
data-size-variant={resolveComponentSize('Image', size)}
|
|
218
|
+
role="dialog"
|
|
219
|
+
aria-modal="true"
|
|
220
|
+
aria-label={alt ? `Image: ${alt}` : 'Image preview'}
|
|
221
|
+
tabindex="-1"
|
|
222
|
+
onkeydown={onDialogKeydown}
|
|
223
|
+
>
|
|
224
|
+
<button type="button" class="backdrop" tabindex="-1" aria-hidden="true" onclick={closeLightbox}
|
|
225
|
+
></button>
|
|
226
|
+
<div class="dialog-body">
|
|
227
|
+
<button
|
|
228
|
+
bind:this={closeBtn}
|
|
229
|
+
type="button"
|
|
230
|
+
class="close"
|
|
231
|
+
aria-label="Close image preview"
|
|
232
|
+
onclick={closeLightbox}>×</button
|
|
233
|
+
>
|
|
234
|
+
<picture>
|
|
235
|
+
{#each sources as s (s.srcset)}
|
|
236
|
+
<source srcset={s.srcset} media={s.media} type={s.type} sizes={s.sizes} />
|
|
237
|
+
{/each}
|
|
238
|
+
<img {src} {alt} {srcset} {sizes} class="full" decoding="async" />
|
|
239
|
+
</picture>
|
|
240
|
+
{#if caption}<p class="lightbox-caption">{caption}</p>{/if}
|
|
241
|
+
</div>
|
|
242
|
+
</div>
|
|
243
|
+
{/if}
|
|
244
|
+
|
|
245
|
+
<style>.ss-image {
|
|
246
|
+
margin: 0;
|
|
247
|
+
display: block;
|
|
248
|
+
max-width: 100%;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
.frame {
|
|
252
|
+
position: relative;
|
|
253
|
+
display: block;
|
|
254
|
+
width: 100%;
|
|
255
|
+
overflow: hidden;
|
|
256
|
+
background: var(--ss-image-frame-bg);
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
.ss-image:not(.has-ratio) .frame {
|
|
260
|
+
background: none;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
.img {
|
|
264
|
+
display: block;
|
|
265
|
+
width: 100%;
|
|
266
|
+
height: auto;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
.has-ratio .img {
|
|
270
|
+
height: 100%;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
.trigger {
|
|
274
|
+
appearance: none;
|
|
275
|
+
display: block;
|
|
276
|
+
width: 100%;
|
|
277
|
+
height: 100%;
|
|
278
|
+
margin: 0;
|
|
279
|
+
padding: 0;
|
|
280
|
+
border: 0;
|
|
281
|
+
background: none;
|
|
282
|
+
cursor: zoom-in;
|
|
283
|
+
color: inherit;
|
|
284
|
+
font: inherit;
|
|
285
|
+
}
|
|
286
|
+
.trigger:focus-visible {
|
|
287
|
+
outline: var(--ss-image-focus-w) solid var(--ss-primary);
|
|
288
|
+
outline-offset: calc(-1 * var(--ss-image-focus-w));
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
.skeleton {
|
|
292
|
+
position: absolute;
|
|
293
|
+
inset: 0;
|
|
294
|
+
background: var(--ss-skeleton);
|
|
295
|
+
background-image: linear-gradient(90deg, transparent 0%, var(--ss-image-shimmer) 50%, transparent 100%);
|
|
296
|
+
background-size: 200% 100%;
|
|
297
|
+
background-repeat: no-repeat;
|
|
298
|
+
animation: ss-image-shimmer var(--ss-image-shimmer-dur) ease-in-out infinite;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
@keyframes ss-image-shimmer {
|
|
302
|
+
from {
|
|
303
|
+
background-position: 200% 0;
|
|
304
|
+
}
|
|
305
|
+
to {
|
|
306
|
+
background-position: -200% 0;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
@media (prefers-reduced-motion: reduce) {
|
|
310
|
+
.skeleton {
|
|
311
|
+
animation: none;
|
|
312
|
+
background-image: none;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
.fallback {
|
|
316
|
+
position: absolute;
|
|
317
|
+
inset: 0;
|
|
318
|
+
display: flex;
|
|
319
|
+
align-items: center;
|
|
320
|
+
justify-content: center;
|
|
321
|
+
background: var(--ss-image-frame-bg);
|
|
322
|
+
color: var(--ss-fg-faint);
|
|
323
|
+
border: 1px solid var(--ss-line);
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
.ss-image:not(.has-ratio) .fallback {
|
|
327
|
+
position: static;
|
|
328
|
+
min-height: var(--ss-image-fallback-min);
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
.fallback .glyph {
|
|
332
|
+
font-size: var(--ss-image-glyph);
|
|
333
|
+
line-height: 1;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
figcaption {
|
|
337
|
+
margin-top: var(--ss-image-caption-gap);
|
|
338
|
+
color: var(--ss-fg-muted);
|
|
339
|
+
font-size: var(--ss-ui-sm);
|
|
340
|
+
line-height: var(--ss-leading, 1.5);
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
.ss-image-lightbox {
|
|
344
|
+
position: fixed;
|
|
345
|
+
inset: 0;
|
|
346
|
+
z-index: var(--ss-image-lightbox-z);
|
|
347
|
+
display: flex;
|
|
348
|
+
align-items: center;
|
|
349
|
+
justify-content: center;
|
|
350
|
+
padding: var(--ss-image-lightbox-pad);
|
|
351
|
+
}
|
|
352
|
+
.ss-image-lightbox .backdrop {
|
|
353
|
+
position: absolute;
|
|
354
|
+
inset: 0;
|
|
355
|
+
appearance: none;
|
|
356
|
+
border: 0;
|
|
357
|
+
margin: 0;
|
|
358
|
+
padding: 0;
|
|
359
|
+
cursor: zoom-out;
|
|
360
|
+
background: var(--ss-image-backdrop);
|
|
361
|
+
animation: ss-image-fade var(--ss-dur-fast) var(--ss-ease);
|
|
362
|
+
}
|
|
363
|
+
.ss-image-lightbox .dialog-body {
|
|
364
|
+
position: relative;
|
|
365
|
+
z-index: 1;
|
|
366
|
+
max-width: min(92vw, 1400px);
|
|
367
|
+
max-height: 90vh;
|
|
368
|
+
display: flex;
|
|
369
|
+
flex-direction: column;
|
|
370
|
+
align-items: center;
|
|
371
|
+
gap: var(--ss-s-2);
|
|
372
|
+
animation: ss-image-fade var(--ss-dur-fast) var(--ss-ease);
|
|
373
|
+
}
|
|
374
|
+
.ss-image-lightbox .full {
|
|
375
|
+
display: block;
|
|
376
|
+
max-width: 100%;
|
|
377
|
+
max-height: 82vh;
|
|
378
|
+
width: auto;
|
|
379
|
+
height: auto;
|
|
380
|
+
object-fit: contain;
|
|
381
|
+
box-shadow: var(--ss-shadow-pop);
|
|
382
|
+
background: var(--ss-bg-elev);
|
|
383
|
+
}
|
|
384
|
+
.ss-image-lightbox .lightbox-caption {
|
|
385
|
+
margin: 0;
|
|
386
|
+
color: var(--ss-fg-shine);
|
|
387
|
+
font-size: var(--ss-ui-md);
|
|
388
|
+
text-align: center;
|
|
389
|
+
}
|
|
390
|
+
.ss-image-lightbox .close {
|
|
391
|
+
position: absolute;
|
|
392
|
+
top: calc(-1 * var(--ss-s-10));
|
|
393
|
+
right: 0;
|
|
394
|
+
appearance: none;
|
|
395
|
+
background: var(--ss-bg-elev);
|
|
396
|
+
border: 1px solid var(--ss-line-strong);
|
|
397
|
+
color: var(--ss-fg);
|
|
398
|
+
cursor: pointer;
|
|
399
|
+
width: var(--ss-image-close);
|
|
400
|
+
height: var(--ss-image-close);
|
|
401
|
+
font-size: var(--ss-size-h3);
|
|
402
|
+
line-height: 1;
|
|
403
|
+
display: inline-flex;
|
|
404
|
+
align-items: center;
|
|
405
|
+
justify-content: center;
|
|
406
|
+
}
|
|
407
|
+
.ss-image-lightbox .close:hover {
|
|
408
|
+
background: var(--ss-bg-elev-hover);
|
|
409
|
+
}
|
|
410
|
+
.ss-image-lightbox .close:focus-visible {
|
|
411
|
+
outline: 2px solid var(--ss-primary);
|
|
412
|
+
outline-offset: 2px;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
@keyframes ss-image-fade {
|
|
416
|
+
from {
|
|
417
|
+
opacity: 0;
|
|
418
|
+
}
|
|
419
|
+
to {
|
|
420
|
+
opacity: 1;
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
@media (prefers-reduced-motion: reduce) {
|
|
424
|
+
.ss-image-lightbox .backdrop,
|
|
425
|
+
.ss-image-lightbox .dialog-body {
|
|
426
|
+
animation: none;
|
|
427
|
+
}
|
|
428
|
+
}</style>
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/** One responsive source for an {@link Image} `<picture>`. */
|
|
2
|
+
export interface ImageSource {
|
|
3
|
+
srcset: string;
|
|
4
|
+
/** e.g. '(max-width: 600px)' or a type like 'image/webp'. */
|
|
5
|
+
media?: string;
|
|
6
|
+
type?: string;
|
|
7
|
+
/** Per-source `sizes` hint for the browser's resource selection. */
|
|
8
|
+
sizes?: string;
|
|
9
|
+
}
|
|
10
|
+
import { type Size } from '../config.js';
|
|
11
|
+
interface Props {
|
|
12
|
+
/** Image URL. */
|
|
13
|
+
src: string;
|
|
14
|
+
/** Required alternative text (WCAG 1.1.1). Pass `''` only for purely decorative images. */
|
|
15
|
+
alt: string;
|
|
16
|
+
/** Responsive `srcset` for the default `<img>` (used alongside `sources`). */
|
|
17
|
+
srcset?: string;
|
|
18
|
+
/** `sizes` hint paired with `srcset`. */
|
|
19
|
+
sizes?: string;
|
|
20
|
+
/** Responsive `<picture>` sources; rendered before the fallback `<img>`. */
|
|
21
|
+
sources?: ImageSource[];
|
|
22
|
+
/** Intrinsic width (px) — feeds the aspect-ratio box and the `<img>` attr. */
|
|
23
|
+
width?: number;
|
|
24
|
+
/** Intrinsic height (px) — feeds the aspect-ratio box and the `<img>` attr. */
|
|
25
|
+
height?: number;
|
|
26
|
+
/**
|
|
27
|
+
* Aspect ratio (w / h) used to reserve space before load. Wins over
|
|
28
|
+
* `width`/`height` when set; otherwise derived from them when both exist.
|
|
29
|
+
*/
|
|
30
|
+
ratio?: number;
|
|
31
|
+
/**
|
|
32
|
+
* How the image fills the reserved box once a ratio is known.
|
|
33
|
+
* @default 'cover'
|
|
34
|
+
*/
|
|
35
|
+
fit?: 'cover' | 'contain' | 'fill' | 'none' | 'scale-down';
|
|
36
|
+
/** Eager-load (above-the-fold) — flips `loading`/`decoding`/`fetchpriority`. @default false */
|
|
37
|
+
eager?: boolean;
|
|
38
|
+
/** Open a lightweight built-in lightbox overlay on click. @default false */
|
|
39
|
+
lightbox?: boolean;
|
|
40
|
+
/** Caption rendered under the image inside a `<figcaption>`. */
|
|
41
|
+
caption?: string;
|
|
42
|
+
/** Token size (sm|md|lg); inherits the global size when unset. Affects chrome, not image dims. */
|
|
43
|
+
size?: Size;
|
|
44
|
+
/** Extra class on the root `<figure>`. */
|
|
45
|
+
class?: string;
|
|
46
|
+
}
|
|
47
|
+
declare const Image: import("svelte").Component<Props, {}, "">;
|
|
48
|
+
type Image = ReturnType<typeof Image>;
|
|
49
|
+
export default Image;
|