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,8 +1,75 @@
|
|
|
1
|
+
/** Curated glyph set. `target`'s centre dot is a filled circle in the *outline*
|
|
2
|
+
* variant — handled by the `variant` switch in markup, not a per-glyph fill hack. */
|
|
3
|
+
declare const BUILTIN_PATHS: {
|
|
4
|
+
readonly grid: "<rect x=\"3\" y=\"3\" width=\"7\" height=\"7\"/><rect x=\"14\" y=\"3\" width=\"7\" height=\"7\"/><rect x=\"3\" y=\"14\" width=\"7\" height=\"7\"/><rect x=\"14\" y=\"14\" width=\"7\" height=\"7\"/>";
|
|
5
|
+
readonly activity: "<path d=\"M3 12h4l3-8 4 16 3-8h4\"/>";
|
|
6
|
+
readonly database: "<rect x=\"3\" y=\"4\" width=\"18\" height=\"16\"/><path d=\"M3 9h18M8 4v5\"/>";
|
|
7
|
+
readonly logs: "<path d=\"M4 6h16M4 12h16M4 18h10\"/>";
|
|
8
|
+
readonly terminal: "<rect x=\"3\" y=\"5\" width=\"18\" height=\"14\"/><path d=\"M3 9h18M7 14h4\"/>";
|
|
9
|
+
readonly settings: "<circle cx=\"12\" cy=\"12\" r=\"3\"/><path d=\"M12 2v3M12 19v3M2 12h3M19 12h3M4.9 4.9l2.1 2.1M17 17l2.1 2.1M4.9 19.1L7 17M17 7l2.1-2.1\"/>";
|
|
10
|
+
readonly user: "<circle cx=\"12\" cy=\"8\" r=\"4\"/><path d=\"M4 21c0-4 4-7 8-7s8 3 8 7\"/>";
|
|
11
|
+
readonly arrow: "<path d=\"M5 12h14M13 5l7 7-7 7\"/>";
|
|
12
|
+
readonly external: "<path d=\"M7 17L17 7M9 7h8v8\"/>";
|
|
13
|
+
readonly film: "<rect x=\"3\" y=\"4\" width=\"18\" height=\"16\"/><path d=\"M3 8h4M3 16h4M17 8h4M17 16h4M3 12h18\"/>";
|
|
14
|
+
readonly note: "<rect x=\"4\" y=\"3\" width=\"16\" height=\"18\"/><path d=\"M8 8h8M8 12h8M8 16h6\"/>";
|
|
15
|
+
readonly book: "<path d=\"M6 4h11a1 1 0 011 1v15H7a1 1 0 01-1-1z\"/><path d=\"M17 20a2 2 0 002-2V6a2 2 0 00-2-2\"/><path d=\"M9 8h5\"/>";
|
|
16
|
+
readonly check: "<path d=\"M5 12l4 4L19 6\"/>";
|
|
17
|
+
readonly cup: "<path d=\"M4 8h12v6a4 4 0 01-4 4H8a4 4 0 01-4-4z\"/><path d=\"M16 10h2a2 2 0 010 4h-2M6 4v2M10 4v2M14 4v2\"/>";
|
|
18
|
+
readonly wallet: "<rect x=\"3\" y=\"6\" width=\"18\" height=\"14\"/><path d=\"M3 10h18M17 14h2\"/>";
|
|
19
|
+
readonly target: "<circle cx=\"12\" cy=\"12\" r=\"9\"/><circle cx=\"12\" cy=\"12\" r=\"5\"/><circle cx=\"12\" cy=\"12\" r=\"1.5\" class=\"ss-icon-dot\"/>";
|
|
20
|
+
readonly spinner: "<path d=\"M12 3a9 9 0 1 0 9 9\" stroke-linecap=\"round\"/>";
|
|
21
|
+
};
|
|
22
|
+
export type IconName = keyof typeof BUILTIN_PATHS;
|
|
23
|
+
/**
|
|
24
|
+
* The curated built-in glyphs plus any runtime-registered ones.
|
|
25
|
+
* (`PATHS` is kept as the public name for backward compatibility.)
|
|
26
|
+
*/
|
|
1
27
|
export declare const PATHS: Record<string, string>;
|
|
2
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Register (or override) a glyph at runtime so `<Icon name="foo" />` resolves
|
|
30
|
+
* raw SVG inner markup that isn't part of the curated {@link IconName} union.
|
|
31
|
+
* The markup is rendered verbatim inside the icon's `<svg viewBox="0 0 24 24">`.
|
|
32
|
+
*
|
|
33
|
+
* registerIcon('heart', '<path d="M12 21 4 13a5 5 0 0 1 7-7l1 1 1-1a5 5 0 0 1 7 7z"/>')
|
|
34
|
+
* <Icon name={'heart' as IconName} />
|
|
35
|
+
*/
|
|
36
|
+
export declare function registerIcon(name: string, paths: string): void;
|
|
37
|
+
/** Look a glyph up; built-ins first, then runtime registrations. */
|
|
38
|
+
export declare function resolveIcon(name: string): string | undefined;
|
|
39
|
+
import { type Size } from '../config.js';
|
|
3
40
|
interface Props {
|
|
4
41
|
name: IconName;
|
|
5
|
-
size
|
|
42
|
+
/** Token-driven size (sm|md|lg); inherits the active size when unset. */
|
|
43
|
+
size?: Size;
|
|
44
|
+
/** Explicit pixel size — overrides the token sizing. */
|
|
45
|
+
px?: number;
|
|
46
|
+
/**
|
|
47
|
+
* Raw SVG inner markup escape hatch — rendered when `name` is not a known
|
|
48
|
+
* (built-in or runtime-registered) glyph. Lets callers pass one-off icons
|
|
49
|
+
* without registering them globally.
|
|
50
|
+
*/
|
|
51
|
+
paths?: string;
|
|
52
|
+
/** Accessible name; rendered as a real <title> and wired via aria-labelledby. */
|
|
53
|
+
title?: string;
|
|
54
|
+
/** Extended description, rendered as <desc> and appended to aria-labelledby. */
|
|
55
|
+
desc?: string;
|
|
56
|
+
/**
|
|
57
|
+
* Mark the icon purely decorative (aria-hidden, no a11y name). Defaults to
|
|
58
|
+
* true when no `title` is given, false when a `title` is present.
|
|
59
|
+
*/
|
|
60
|
+
decorative?: boolean;
|
|
61
|
+
/** Spin the glyph (e.g. a loader). Honours prefers-reduced-motion. */
|
|
62
|
+
spin?: boolean;
|
|
63
|
+
/** Quarter-turn rotation. */
|
|
64
|
+
rotate?: 0 | 90 | 180 | 270;
|
|
65
|
+
/** Mirror the glyph. */
|
|
66
|
+
flip?: 'horizontal' | 'vertical';
|
|
67
|
+
/** outline (stroked, default) | solid (filled with currentColor). */
|
|
68
|
+
variant?: 'outline' | 'solid';
|
|
69
|
+
/** Stroke weight in viewBox units (default 2). */
|
|
70
|
+
strokeWidth?: number;
|
|
71
|
+
/** Keep `strokeWidth` optically constant across sizes (recompute from resolved px). */
|
|
72
|
+
absoluteStroke?: boolean;
|
|
6
73
|
class?: string;
|
|
7
74
|
}
|
|
8
75
|
declare const Icon: import("svelte").Component<Props, {}, "">;
|
|
@@ -0,0 +1,430 @@
|
|
|
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
|
|
84
|
+
? ratio
|
|
85
|
+
: width && height && height > 0
|
|
86
|
+
? width / height
|
|
87
|
+
: null,
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
type State = 'loading' | 'loaded' | 'error'
|
|
91
|
+
let state = $state<State>('loading')
|
|
92
|
+
|
|
93
|
+
function onLoad() {
|
|
94
|
+
state = 'loaded'
|
|
95
|
+
}
|
|
96
|
+
function onError() {
|
|
97
|
+
state = 'error'
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// ── Lightbox ───────────────────────────────────────────────────────────
|
|
101
|
+
let open = $state(false)
|
|
102
|
+
let trigger = $state<HTMLButtonElement | null>(null)
|
|
103
|
+
let dialog = $state<HTMLDivElement | null>(null)
|
|
104
|
+
let closeBtn = $state<HTMLButtonElement | null>(null)
|
|
105
|
+
|
|
106
|
+
const canOpen = $derived(lightbox && state !== 'error')
|
|
107
|
+
|
|
108
|
+
async function openLightbox() {
|
|
109
|
+
if (!canOpen) return
|
|
110
|
+
open = true
|
|
111
|
+
await tick()
|
|
112
|
+
closeBtn?.focus()
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function closeLightbox() {
|
|
116
|
+
open = false
|
|
117
|
+
// Restore focus to the trigger (WCAG 2.4.3).
|
|
118
|
+
trigger?.focus()
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Focus trap + Esc, scoped to the dialog (keeps Tab inside the overlay).
|
|
122
|
+
function onDialogKeydown(e: KeyboardEvent) {
|
|
123
|
+
if (e.key === 'Escape') {
|
|
124
|
+
e.preventDefault()
|
|
125
|
+
e.stopPropagation()
|
|
126
|
+
closeLightbox()
|
|
127
|
+
return
|
|
128
|
+
}
|
|
129
|
+
if (e.key !== 'Tab' || !dialog) return
|
|
130
|
+
const focusables = dialog.querySelectorAll<HTMLElement>(
|
|
131
|
+
'button, [href], [tabindex]:not([tabindex="-1"])',
|
|
132
|
+
)
|
|
133
|
+
if (focusables.length === 0) return
|
|
134
|
+
const first = focusables[0]
|
|
135
|
+
const last = focusables[focusables.length - 1]
|
|
136
|
+
const active = document.activeElement
|
|
137
|
+
if (e.shiftKey && active === first) {
|
|
138
|
+
e.preventDefault()
|
|
139
|
+
last.focus()
|
|
140
|
+
} else if (!e.shiftKey && active === last) {
|
|
141
|
+
e.preventDefault()
|
|
142
|
+
first.focus()
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
</script>
|
|
146
|
+
|
|
147
|
+
<figure
|
|
148
|
+
class="ss-image {className ?? ''}"
|
|
149
|
+
class:is-loading={state === 'loading'}
|
|
150
|
+
class:is-error={state === 'error'}
|
|
151
|
+
class:has-ratio={aspect != null}
|
|
152
|
+
data-size-variant={resolveComponentSize('Image', size)}
|
|
153
|
+
>
|
|
154
|
+
<div
|
|
155
|
+
class="frame"
|
|
156
|
+
style:aspect-ratio={aspect != null ? `${aspect}` : undefined}
|
|
157
|
+
aria-busy={state === 'loading'}
|
|
158
|
+
>
|
|
159
|
+
{#if state === 'error'}
|
|
160
|
+
<div class="fallback" role="img" aria-label={alt || 'Image failed to load'}>
|
|
161
|
+
<span class="glyph" aria-hidden="true">⊘</span>
|
|
162
|
+
</div>
|
|
163
|
+
{:else}
|
|
164
|
+
{#if state === 'loading'}
|
|
165
|
+
<div class="skeleton" aria-hidden="true"></div>
|
|
166
|
+
{/if}
|
|
167
|
+
{#if canOpen}
|
|
168
|
+
<button
|
|
169
|
+
bind:this={trigger}
|
|
170
|
+
type="button"
|
|
171
|
+
class="trigger"
|
|
172
|
+
aria-haspopup="dialog"
|
|
173
|
+
aria-label={alt ? `View image: ${alt}` : 'View image full size'}
|
|
174
|
+
onclick={openLightbox}
|
|
175
|
+
>
|
|
176
|
+
{@render media()}
|
|
177
|
+
</button>
|
|
178
|
+
{:else}
|
|
179
|
+
{@render media()}
|
|
180
|
+
{/if}
|
|
181
|
+
{/if}
|
|
182
|
+
</div>
|
|
183
|
+
{#if caption}<figcaption>{caption}</figcaption>{/if}
|
|
184
|
+
</figure>
|
|
185
|
+
|
|
186
|
+
{#snippet media()}
|
|
187
|
+
<picture>
|
|
188
|
+
{#each sources as s (s.srcset)}
|
|
189
|
+
<source srcset={s.srcset} media={s.media} type={s.type} sizes={s.sizes} />
|
|
190
|
+
{/each}
|
|
191
|
+
<img
|
|
192
|
+
{src}
|
|
193
|
+
{alt}
|
|
194
|
+
{srcset}
|
|
195
|
+
{sizes}
|
|
196
|
+
{width}
|
|
197
|
+
{height}
|
|
198
|
+
class="img"
|
|
199
|
+
style:object-fit={aspect != null ? fit : undefined}
|
|
200
|
+
loading={eager ? 'eager' : 'lazy'}
|
|
201
|
+
decoding={eager ? 'auto' : 'async'}
|
|
202
|
+
fetchpriority={eager ? 'high' : undefined}
|
|
203
|
+
onload={onLoad}
|
|
204
|
+
onerror={onError}
|
|
205
|
+
/>
|
|
206
|
+
</picture>
|
|
207
|
+
{/snippet}
|
|
208
|
+
|
|
209
|
+
{#if open}
|
|
210
|
+
<!-- Built-in lightbox: dialog semantics + focus trap; backdrop click closes. -->
|
|
211
|
+
<div
|
|
212
|
+
bind:this={dialog}
|
|
213
|
+
class="ss-image-lightbox"
|
|
214
|
+
data-size-variant={resolveComponentSize('Image', size)}
|
|
215
|
+
role="dialog"
|
|
216
|
+
aria-modal="true"
|
|
217
|
+
aria-label={alt ? `Image: ${alt}` : 'Image preview'}
|
|
218
|
+
tabindex="-1"
|
|
219
|
+
onkeydown={onDialogKeydown}
|
|
220
|
+
>
|
|
221
|
+
<button
|
|
222
|
+
type="button"
|
|
223
|
+
class="backdrop"
|
|
224
|
+
tabindex="-1"
|
|
225
|
+
aria-hidden="true"
|
|
226
|
+
onclick={closeLightbox}
|
|
227
|
+
></button>
|
|
228
|
+
<div class="dialog-body">
|
|
229
|
+
<button
|
|
230
|
+
bind:this={closeBtn}
|
|
231
|
+
type="button"
|
|
232
|
+
class="close"
|
|
233
|
+
aria-label="Close image preview"
|
|
234
|
+
onclick={closeLightbox}>×</button
|
|
235
|
+
>
|
|
236
|
+
<picture>
|
|
237
|
+
{#each sources as s (s.srcset)}
|
|
238
|
+
<source srcset={s.srcset} media={s.media} type={s.type} sizes={s.sizes} />
|
|
239
|
+
{/each}
|
|
240
|
+
<img {src} {alt} {srcset} {sizes} class="full" decoding="async" />
|
|
241
|
+
</picture>
|
|
242
|
+
{#if caption}<p class="lightbox-caption">{caption}</p>{/if}
|
|
243
|
+
</div>
|
|
244
|
+
</div>
|
|
245
|
+
{/if}
|
|
246
|
+
|
|
247
|
+
<style>.ss-image {
|
|
248
|
+
margin: 0;
|
|
249
|
+
display: block;
|
|
250
|
+
max-width: 100%;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
.frame {
|
|
254
|
+
position: relative;
|
|
255
|
+
display: block;
|
|
256
|
+
width: 100%;
|
|
257
|
+
overflow: hidden;
|
|
258
|
+
background: var(--ss-image-frame-bg);
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
.ss-image:not(.has-ratio) .frame {
|
|
262
|
+
background: none;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
.img {
|
|
266
|
+
display: block;
|
|
267
|
+
width: 100%;
|
|
268
|
+
height: auto;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
.has-ratio .img {
|
|
272
|
+
height: 100%;
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
.trigger {
|
|
276
|
+
appearance: none;
|
|
277
|
+
display: block;
|
|
278
|
+
width: 100%;
|
|
279
|
+
height: 100%;
|
|
280
|
+
margin: 0;
|
|
281
|
+
padding: 0;
|
|
282
|
+
border: 0;
|
|
283
|
+
background: none;
|
|
284
|
+
cursor: zoom-in;
|
|
285
|
+
color: inherit;
|
|
286
|
+
font: inherit;
|
|
287
|
+
}
|
|
288
|
+
.trigger:focus-visible {
|
|
289
|
+
outline: var(--ss-image-focus-w) solid var(--ss-primary);
|
|
290
|
+
outline-offset: calc(-1 * var(--ss-image-focus-w));
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
.skeleton {
|
|
294
|
+
position: absolute;
|
|
295
|
+
inset: 0;
|
|
296
|
+
background: var(--ss-skeleton);
|
|
297
|
+
background-image: linear-gradient(90deg, transparent 0%, var(--ss-image-shimmer) 50%, transparent 100%);
|
|
298
|
+
background-size: 200% 100%;
|
|
299
|
+
background-repeat: no-repeat;
|
|
300
|
+
animation: ss-image-shimmer var(--ss-image-shimmer-dur) ease-in-out infinite;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
@keyframes ss-image-shimmer {
|
|
304
|
+
from {
|
|
305
|
+
background-position: 200% 0;
|
|
306
|
+
}
|
|
307
|
+
to {
|
|
308
|
+
background-position: -200% 0;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
@media (prefers-reduced-motion: reduce) {
|
|
312
|
+
.skeleton {
|
|
313
|
+
animation: none;
|
|
314
|
+
background-image: none;
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
.fallback {
|
|
318
|
+
position: absolute;
|
|
319
|
+
inset: 0;
|
|
320
|
+
display: flex;
|
|
321
|
+
align-items: center;
|
|
322
|
+
justify-content: center;
|
|
323
|
+
background: var(--ss-image-frame-bg);
|
|
324
|
+
color: var(--ss-fg-faint);
|
|
325
|
+
border: 1px solid var(--ss-line);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
.ss-image:not(.has-ratio) .fallback {
|
|
329
|
+
position: static;
|
|
330
|
+
min-height: var(--ss-image-fallback-min);
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
.fallback .glyph {
|
|
334
|
+
font-size: var(--ss-image-glyph);
|
|
335
|
+
line-height: 1;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
figcaption {
|
|
339
|
+
margin-top: var(--ss-image-caption-gap);
|
|
340
|
+
color: var(--ss-fg-muted);
|
|
341
|
+
font-size: var(--ss-ui-sm);
|
|
342
|
+
line-height: var(--ss-leading, 1.5);
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
.ss-image-lightbox {
|
|
346
|
+
position: fixed;
|
|
347
|
+
inset: 0;
|
|
348
|
+
z-index: var(--ss-image-lightbox-z);
|
|
349
|
+
display: flex;
|
|
350
|
+
align-items: center;
|
|
351
|
+
justify-content: center;
|
|
352
|
+
padding: var(--ss-image-lightbox-pad);
|
|
353
|
+
}
|
|
354
|
+
.ss-image-lightbox .backdrop {
|
|
355
|
+
position: absolute;
|
|
356
|
+
inset: 0;
|
|
357
|
+
appearance: none;
|
|
358
|
+
border: 0;
|
|
359
|
+
margin: 0;
|
|
360
|
+
padding: 0;
|
|
361
|
+
cursor: zoom-out;
|
|
362
|
+
background: var(--ss-image-backdrop);
|
|
363
|
+
animation: ss-image-fade var(--ss-dur-fast) var(--ss-ease);
|
|
364
|
+
}
|
|
365
|
+
.ss-image-lightbox .dialog-body {
|
|
366
|
+
position: relative;
|
|
367
|
+
z-index: 1;
|
|
368
|
+
max-width: min(92vw, 1400px);
|
|
369
|
+
max-height: 90vh;
|
|
370
|
+
display: flex;
|
|
371
|
+
flex-direction: column;
|
|
372
|
+
align-items: center;
|
|
373
|
+
gap: var(--ss-s-2);
|
|
374
|
+
animation: ss-image-fade var(--ss-dur-fast) var(--ss-ease);
|
|
375
|
+
}
|
|
376
|
+
.ss-image-lightbox .full {
|
|
377
|
+
display: block;
|
|
378
|
+
max-width: 100%;
|
|
379
|
+
max-height: 82vh;
|
|
380
|
+
width: auto;
|
|
381
|
+
height: auto;
|
|
382
|
+
object-fit: contain;
|
|
383
|
+
box-shadow: var(--ss-shadow-pop);
|
|
384
|
+
background: var(--ss-bg-elev);
|
|
385
|
+
}
|
|
386
|
+
.ss-image-lightbox .lightbox-caption {
|
|
387
|
+
margin: 0;
|
|
388
|
+
color: var(--ss-fg-shine);
|
|
389
|
+
font-size: var(--ss-ui-md);
|
|
390
|
+
text-align: center;
|
|
391
|
+
}
|
|
392
|
+
.ss-image-lightbox .close {
|
|
393
|
+
position: absolute;
|
|
394
|
+
top: calc(-1 * var(--ss-s-10));
|
|
395
|
+
right: 0;
|
|
396
|
+
appearance: none;
|
|
397
|
+
background: var(--ss-bg-elev);
|
|
398
|
+
border: 1px solid var(--ss-line-strong);
|
|
399
|
+
color: var(--ss-fg);
|
|
400
|
+
cursor: pointer;
|
|
401
|
+
width: var(--ss-image-close);
|
|
402
|
+
height: var(--ss-image-close);
|
|
403
|
+
font-size: var(--ss-size-h3);
|
|
404
|
+
line-height: 1;
|
|
405
|
+
display: inline-flex;
|
|
406
|
+
align-items: center;
|
|
407
|
+
justify-content: center;
|
|
408
|
+
}
|
|
409
|
+
.ss-image-lightbox .close:hover {
|
|
410
|
+
background: var(--ss-bg-elev-hover);
|
|
411
|
+
}
|
|
412
|
+
.ss-image-lightbox .close:focus-visible {
|
|
413
|
+
outline: 2px solid var(--ss-primary);
|
|
414
|
+
outline-offset: 2px;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
@keyframes ss-image-fade {
|
|
418
|
+
from {
|
|
419
|
+
opacity: 0;
|
|
420
|
+
}
|
|
421
|
+
to {
|
|
422
|
+
opacity: 1;
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
@media (prefers-reduced-motion: reduce) {
|
|
426
|
+
.ss-image-lightbox .backdrop,
|
|
427
|
+
.ss-image-lightbox .dialog-body {
|
|
428
|
+
animation: none;
|
|
429
|
+
}
|
|
430
|
+
}</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;
|