@stnd/ui 0.5.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/Accordion.astro +52 -0
- package/AccordionItem.astro +65 -0
- package/Alert.svelte +59 -0
- package/AlertDialog.svelte +146 -0
- package/CHANGELOG.md +25 -0
- package/CfImage.astro +70 -0
- package/Combobox.svelte +458 -0
- package/ContextMenu.svelte +120 -0
- package/ContextMenuItem.svelte +64 -0
- package/ContextMenuItemCheckbox.svelte +105 -0
- package/ContextMenuLabel.svelte +18 -0
- package/ContextMenuSeparator.svelte +1 -0
- package/DialogManager.svelte +32 -0
- package/Dropdown.svelte +107 -0
- package/DropdownItem.svelte +87 -0
- package/DropdownLabel.svelte +11 -0
- package/DropdownSeparator.svelte +1 -0
- package/LauncherHint.astro +35 -0
- package/Pagination.astro +154 -0
- package/Panel.svelte +365 -0
- package/README.md +150 -0
- package/Scroller.astro +11 -0
- package/Scroller.svelte +44 -0
- package/TableOfContents.astro +217 -0
- package/Toast.astro +202 -0
- package/dialog.js +53 -0
- package/package.json +35 -0
- package/transitions.js +78 -0
package/Panel.svelte
ADDED
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
/**
|
|
3
|
+
* @stnd/ui/Panel.svelte
|
|
4
|
+
* Edge Panel β a collapsible side panel fixed to the screen edge.
|
|
5
|
+
*
|
|
6
|
+
* Shows only a thin 6px handle strip by default. Clicking the handle slides
|
|
7
|
+
* the panel open. A pin button in the header locks it open so it won't close
|
|
8
|
+
* on outside clicks. Pin state is persisted to localStorage when `id` is set.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* <Panel side="right" title="Inspector" id="inspector-panel" width="320px">
|
|
12
|
+
* <p>Panel content here</p>
|
|
13
|
+
* </Panel>
|
|
14
|
+
*/
|
|
15
|
+
import { onMount } from "svelte";
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @typedef {Object} PanelProps
|
|
19
|
+
* @property {'left' | 'right'} [side] - Which screen edge to attach to
|
|
20
|
+
* @property {string} [title] - Optional header title
|
|
21
|
+
* @property {string} [width] - Panel open width (CSS value)
|
|
22
|
+
* @property {string} [id] - Optional ID for localStorage pin persistence
|
|
23
|
+
* @property {import('svelte').Snippet} [children] - Panel body content
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
/** @type {PanelProps} */
|
|
27
|
+
let {
|
|
28
|
+
side = "right",
|
|
29
|
+
title = "",
|
|
30
|
+
width = "280px",
|
|
31
|
+
id = "",
|
|
32
|
+
children,
|
|
33
|
+
} = $props();
|
|
34
|
+
|
|
35
|
+
let open = $state(false);
|
|
36
|
+
let pinned = $state(false);
|
|
37
|
+
|
|
38
|
+
const storageKey = $derived(id ? `panel-pinned:${id}` : "");
|
|
39
|
+
|
|
40
|
+
onMount(() => {
|
|
41
|
+
if (storageKey) {
|
|
42
|
+
try {
|
|
43
|
+
pinned = localStorage.getItem(storageKey) === "true";
|
|
44
|
+
if (pinned) open = true;
|
|
45
|
+
} catch {
|
|
46
|
+
// localStorage unavailable (e.g. private browsing with storage blocked)
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
function toggleOpen() {
|
|
52
|
+
open = !open;
|
|
53
|
+
// Unpinning when closing
|
|
54
|
+
if (!open && pinned) {
|
|
55
|
+
pinned = false;
|
|
56
|
+
persistPin(false);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function togglePin() {
|
|
61
|
+
pinned = !pinned;
|
|
62
|
+
persistPin(pinned);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function closePanel() {
|
|
66
|
+
if (pinned) return;
|
|
67
|
+
open = false;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** @param {boolean} value */
|
|
71
|
+
function persistPin(value) {
|
|
72
|
+
if (!storageKey) return;
|
|
73
|
+
try {
|
|
74
|
+
if (value) {
|
|
75
|
+
localStorage.setItem(storageKey, "true");
|
|
76
|
+
} else {
|
|
77
|
+
localStorage.removeItem(storageKey);
|
|
78
|
+
}
|
|
79
|
+
} catch {
|
|
80
|
+
// localStorage unavailable
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function handleKeydown(/** @type {KeyboardEvent} */ e) {
|
|
85
|
+
if (e.key === "Escape" && open && !pinned) {
|
|
86
|
+
open = false;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
</script>
|
|
90
|
+
|
|
91
|
+
<svelte:window onkeydown={handleKeydown} />
|
|
92
|
+
|
|
93
|
+
<!-- Overlay: closes panel on outside click when open and not pinned -->
|
|
94
|
+
{#if open && !pinned}
|
|
95
|
+
<div
|
|
96
|
+
class="panel-overlay"
|
|
97
|
+
onclick={closePanel}
|
|
98
|
+
role="presentation"
|
|
99
|
+
aria-hidden="true"
|
|
100
|
+
></div>
|
|
101
|
+
{/if}
|
|
102
|
+
|
|
103
|
+
<div
|
|
104
|
+
class="panel-root"
|
|
105
|
+
class:side-left={side === "left"}
|
|
106
|
+
class:side-right={side === "right"}
|
|
107
|
+
class:is-open={open}
|
|
108
|
+
class:is-pinned={pinned}
|
|
109
|
+
style="--panel-width: {width}"
|
|
110
|
+
>
|
|
111
|
+
<!-- Always-visible handle strip -->
|
|
112
|
+
<button
|
|
113
|
+
class="panel-handle"
|
|
114
|
+
onclick={toggleOpen}
|
|
115
|
+
aria-label={open ? "Close panel" : "Open panel"}
|
|
116
|
+
aria-expanded={open}
|
|
117
|
+
>
|
|
118
|
+
<span class="handle-line"></span>
|
|
119
|
+
<span class="handle-icon" aria-hidden="true">
|
|
120
|
+
<!-- Chevron: rotates based on side + open state via CSS -->
|
|
121
|
+
<svg width="10" height="10" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round">
|
|
122
|
+
<polyline points="9 18 15 12 9 6"></polyline>
|
|
123
|
+
</svg>
|
|
124
|
+
</span>
|
|
125
|
+
</button>
|
|
126
|
+
|
|
127
|
+
<!-- Sliding body -->
|
|
128
|
+
<div class="panel-body" aria-hidden={!open}>
|
|
129
|
+
<div class="panel-header">
|
|
130
|
+
{#if title}
|
|
131
|
+
<span class="panel-title">{title}</span>
|
|
132
|
+
{/if}
|
|
133
|
+
<button
|
|
134
|
+
class="panel-pin"
|
|
135
|
+
class:is-pinned={pinned}
|
|
136
|
+
onclick={togglePin}
|
|
137
|
+
aria-label={pinned ? "Unpin panel" : "Pin panel open"}
|
|
138
|
+
aria-pressed={pinned}
|
|
139
|
+
>
|
|
140
|
+
{#if pinned}
|
|
141
|
+
<!-- Pinned: filled path -->
|
|
142
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
143
|
+
<line x1="12" y1="17" x2="12" y2="22"/>
|
|
144
|
+
<path fill="currentColor" d="M5 17h14v-1.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V6h1a2 2 0 0 0 0-4H8a2 2 0 0 0 0 4h1v4.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24Z"/>
|
|
145
|
+
</svg>
|
|
146
|
+
{:else}
|
|
147
|
+
<!-- Unpinned: outline only -->
|
|
148
|
+
<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
|
|
149
|
+
<line x1="12" y1="17" x2="12" y2="22"/>
|
|
150
|
+
<path d="M5 17h14v-1.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V6h1a2 2 0 0 0 0-4H8a2 2 0 0 0 0 4h1v4.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24Z"/>
|
|
151
|
+
</svg>
|
|
152
|
+
{/if}
|
|
153
|
+
</button>
|
|
154
|
+
</div>
|
|
155
|
+
|
|
156
|
+
<div class="panel-content">
|
|
157
|
+
{@render children?.()}
|
|
158
|
+
</div>
|
|
159
|
+
</div>
|
|
160
|
+
</div>
|
|
161
|
+
|
|
162
|
+
<style>
|
|
163
|
+
/* ββ Root βββββββββββββββββββββββββββββββββββββββββββββββββββ */
|
|
164
|
+
|
|
165
|
+
.panel-root {
|
|
166
|
+
--panel-handle-width: 6px;
|
|
167
|
+
--panel-z: 500;
|
|
168
|
+
|
|
169
|
+
position: fixed;
|
|
170
|
+
top: 0;
|
|
171
|
+
bottom: 0;
|
|
172
|
+
z-index: var(--panel-z);
|
|
173
|
+
display: flex;
|
|
174
|
+
align-items: stretch;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
.side-right {
|
|
178
|
+
right: var(--gap-body, 1.5rem);
|
|
179
|
+
flex-direction: row-reverse; /* handle on left, body on right */
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
.side-left {
|
|
183
|
+
left: var(--gap-body, 1.5rem);
|
|
184
|
+
flex-direction: row; /* handle on right, body on left */
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/* ββ Handle βββββββββββββββββββββββββββββββββββββββββββββββββ */
|
|
188
|
+
|
|
189
|
+
.panel-handle {
|
|
190
|
+
flex-shrink: 0;
|
|
191
|
+
width: var(--panel-handle-width);
|
|
192
|
+
height: 100%;
|
|
193
|
+
display: flex;
|
|
194
|
+
flex-direction: column;
|
|
195
|
+
align-items: center;
|
|
196
|
+
justify-content: center;
|
|
197
|
+
gap: var(--space-d2, 0.25rem);
|
|
198
|
+
background: transparent;
|
|
199
|
+
border: none;
|
|
200
|
+
padding: 0;
|
|
201
|
+
cursor: pointer;
|
|
202
|
+
position: relative;
|
|
203
|
+
z-index: 1;
|
|
204
|
+
transition: background var(--transition, 200ms ease);
|
|
205
|
+
|
|
206
|
+
&:hover,
|
|
207
|
+
&:focus-visible {
|
|
208
|
+
background: oklch(from var(--color-foreground, currentColor) l c h / 0.06);
|
|
209
|
+
outline: none;
|
|
210
|
+
|
|
211
|
+
.handle-line {
|
|
212
|
+
opacity: 1;
|
|
213
|
+
background: var(--color-accent, currentColor);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
.handle-icon {
|
|
217
|
+
opacity: 1;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
.handle-line {
|
|
223
|
+
width: 2px;
|
|
224
|
+
height: 2rem;
|
|
225
|
+
border-radius: 999px;
|
|
226
|
+
background: oklch(from var(--color-foreground, currentColor) l c h / 0.25);
|
|
227
|
+
opacity: 0.6;
|
|
228
|
+
transition: background var(--transition, 200ms ease), opacity var(--transition, 200ms ease);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
.handle-icon {
|
|
232
|
+
display: flex;
|
|
233
|
+
align-items: center;
|
|
234
|
+
justify-content: center;
|
|
235
|
+
opacity: 0.5;
|
|
236
|
+
color: var(--color-foreground, currentColor);
|
|
237
|
+
transition: opacity var(--transition, 200ms ease), transform var(--transition, 200ms ease);
|
|
238
|
+
|
|
239
|
+
/* Chevron points inward by default; flip based on side + open state */
|
|
240
|
+
.side-right & {
|
|
241
|
+
transform: rotate(180deg); /* points left (into the panel) */
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
.side-left & {
|
|
245
|
+
transform: rotate(0deg); /* points right (into the panel) */
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/* When open, chevron reverses direction to indicate close */
|
|
249
|
+
.is-open.side-right & {
|
|
250
|
+
transform: rotate(0deg);
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
.is-open.side-left & {
|
|
254
|
+
transform: rotate(180deg);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/* Hide handle when pinned open (optional β gives more space) */
|
|
259
|
+
.is-pinned .panel-handle {
|
|
260
|
+
opacity: 0;
|
|
261
|
+
pointer-events: none;
|
|
262
|
+
width: 0;
|
|
263
|
+
overflow: hidden;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/* ββ Panel body βββββββββββββββββββββββββββββββββββββββββββββ */
|
|
267
|
+
|
|
268
|
+
.panel-body {
|
|
269
|
+
width: 0;
|
|
270
|
+
opacity: 0;
|
|
271
|
+
overflow: hidden;
|
|
272
|
+
display: flex;
|
|
273
|
+
flex-direction: column;
|
|
274
|
+
background: var(--color-surface, white);
|
|
275
|
+
border-inline: 1px solid var(--border, rgba(0 0 0 / 0.1));
|
|
276
|
+
box-shadow: var(--shadow-raised, 0 4px 16px rgba(0 0 0 / 0.12));
|
|
277
|
+
backdrop-filter: var(--filter-blur, none);
|
|
278
|
+
transition:
|
|
279
|
+
width var(--transition, 200ms ease),
|
|
280
|
+
opacity var(--transition, 200ms ease);
|
|
281
|
+
/* Prevent content from wrapping during the slide-in transition */
|
|
282
|
+
min-width: 0;
|
|
283
|
+
|
|
284
|
+
.is-open & {
|
|
285
|
+
width: var(--panel-width, 280px);
|
|
286
|
+
opacity: 1;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/* ββ Header βββββββββββββββββββββββββββββββββββββββββββββββββ */
|
|
291
|
+
|
|
292
|
+
.panel-header {
|
|
293
|
+
display: flex;
|
|
294
|
+
align-items: center;
|
|
295
|
+
justify-content: space-between;
|
|
296
|
+
gap: var(--space-d2, 0.25rem);
|
|
297
|
+
padding: var(--space, 1rem);
|
|
298
|
+
border-block-end: 1px solid var(--border, rgba(0 0 0 / 0.08));
|
|
299
|
+
flex-shrink: 0;
|
|
300
|
+
min-height: 2.75rem;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
.panel-title {
|
|
304
|
+
font-family: var(--font-interface, sans-serif);
|
|
305
|
+
font-size: var(--size-sm, 0.875rem);
|
|
306
|
+
font-weight: 600;
|
|
307
|
+
color: var(--color-foreground, currentColor);
|
|
308
|
+
white-space: nowrap;
|
|
309
|
+
overflow: hidden;
|
|
310
|
+
text-overflow: ellipsis;
|
|
311
|
+
flex: 1;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/* ββ Pin button βββββββββββββββββββββββββββββββββββββββββββββ */
|
|
315
|
+
|
|
316
|
+
.panel-pin {
|
|
317
|
+
display: inline-flex;
|
|
318
|
+
align-items: center;
|
|
319
|
+
justify-content: center;
|
|
320
|
+
flex-shrink: 0;
|
|
321
|
+
width: 1.75rem;
|
|
322
|
+
height: 1.75rem;
|
|
323
|
+
border-radius: var(--radius, 6px);
|
|
324
|
+
border: none;
|
|
325
|
+
background: transparent;
|
|
326
|
+
color: oklch(from var(--color-foreground, currentColor) l c h / 0.4);
|
|
327
|
+
cursor: pointer;
|
|
328
|
+
transition:
|
|
329
|
+
background var(--transition, 200ms ease),
|
|
330
|
+
color var(--transition, 200ms ease);
|
|
331
|
+
|
|
332
|
+
&:hover,
|
|
333
|
+
&:focus-visible {
|
|
334
|
+
background: oklch(from var(--color-foreground, currentColor) l c h / 0.08);
|
|
335
|
+
color: var(--color-foreground, currentColor);
|
|
336
|
+
outline: none;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
&.is-pinned {
|
|
340
|
+
color: var(--color-accent, currentColor);
|
|
341
|
+
background: oklch(from var(--color-accent, currentColor) l c h / 0.1);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
/* ββ Content ββββββββββββββββββββββββββββββββββββββββββββββββ */
|
|
346
|
+
|
|
347
|
+
.panel-content {
|
|
348
|
+
flex: 1;
|
|
349
|
+
overflow-y: auto;
|
|
350
|
+
overflow-x: hidden;
|
|
351
|
+
padding: var(--space, 1rem);
|
|
352
|
+
/* Prevent content reflow flash during width transition */
|
|
353
|
+
min-width: var(--panel-width, 280px);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/* ββ Overlay ββββββββββββββββββββββββββββββββββββββββββββββββ */
|
|
357
|
+
|
|
358
|
+
.panel-overlay {
|
|
359
|
+
position: fixed;
|
|
360
|
+
inset: 0;
|
|
361
|
+
z-index: 498;
|
|
362
|
+
background: transparent;
|
|
363
|
+
cursor: default;
|
|
364
|
+
}
|
|
365
|
+
</style>
|
package/README.md
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "@stnd/ui"
|
|
3
|
+
aliases: []
|
|
4
|
+
created: 2026-07-05 07:47
|
|
5
|
+
modified: 2026-07-05 19:15
|
|
6
|
+
last_audited: 2026-07-14
|
|
7
|
+
audit_interval_days: 90
|
|
8
|
+
next_audit: 2026-10-12
|
|
9
|
+
audit_priority: 3
|
|
10
|
+
maturity: sprout
|
|
11
|
+
mode: read
|
|
12
|
+
publish: false
|
|
13
|
+
status: active
|
|
14
|
+
tags:
|
|
15
|
+
- package
|
|
16
|
+
- stnd
|
|
17
|
+
theme: kernel
|
|
18
|
+
type: package
|
|
19
|
+
visibility: private
|
|
20
|
+
---
|
|
21
|
+
|
|
22
|
+
# @[stnd](../README)/ui
|
|
23
|
+
|
|
24
|
+
Shared UI components for the Standard Ecosystem.
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
Most buttons/badges/cards should just be a CSS class on plain HTML (see `@stnd/styles`) β no JS, no import. This package is only for the handful of things that genuinely need interactivity: a dropdown that manages keyboard navigation, a confirm dialog you can `await`, a right-click menu. If youβre reaching for a component here and itβs not doing something stateful or ARIA-heavy, check whether a CSS class already does the job.
|
|
29
|
+
|
|
30
|
+
**Use it (the confirm dialog, the most common one):**
|
|
31
|
+
|
|
32
|
+
```javascript
|
|
33
|
+
import { confirm } from "@stnd/ui/dialog.js";
|
|
34
|
+
const ok = await confirm({ title: "Delete this?", intent: "danger" });
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Overview
|
|
38
|
+
|
|
39
|
+
`@stnd/ui` provides a collection of reusable, accessible, and high-quality UI components built for Astro and Svelte 5. These components are designed to work seamlessly with `@stnd/styles` and follow the Standard design principles.
|
|
40
|
+
|
|
41
|
+
## π The Philosophy: CSS First, Components Second
|
|
42
|
+
|
|
43
|
+
Standard is built on the philosophy of keeping the codebase as clean, fast, and static as possible. Before importing a component from `@stnd/ui`, ask yourself: **Can this be done with just HTML and `@stnd/styles`?**
|
|
44
|
+
|
|
45
|
+
Many UI elements you see in the Playground (like Buttons, Badges, Cards, and Inputs) are **not components**. They are simple CSS classes applied to standard HTML elements.
|
|
46
|
+
|
|
47
|
+
**Why?**
|
|
48
|
+
- Zero JavaScript overhead.
|
|
49
|
+
- Perfect semantic HTML.
|
|
50
|
+
- Maximum flexibility without passing dozens of props.
|
|
51
|
+
|
|
52
|
+
### Example: Buttons & Badges (CSS Only)
|
|
53
|
+
You do not need a `<Button>` or `<Badge>` component. Just use the global classes provided by `@stnd/styles`:
|
|
54
|
+
|
|
55
|
+
```html
|
|
56
|
+
<!-- Primary Button -->
|
|
57
|
+
<button class="btn">Save Changes</button>
|
|
58
|
+
|
|
59
|
+
<!-- Ghost Button -->
|
|
60
|
+
<button class="btn ghost">Cancel</button>
|
|
61
|
+
|
|
62
|
+
<!-- Success Badge -->
|
|
63
|
+
<span class="badge success">Active</span>
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### When to use `@stnd/ui` Components?
|
|
67
|
+
You should only import components from this package when you need:
|
|
68
|
+
1. **Complex interactivity** (e.g., `Dropdown`, `ContextMenu`).
|
|
69
|
+
2. **State management** (e.g., `DialogManager`, `ComboBox`).
|
|
70
|
+
3. **Advanced Accessibility / ARIA management** (e.g., `Accordion`).
|
|
71
|
+
4. **Complex composition** (e.g., `Accordion`, `Scroller`, `TableOfContents`).
|
|
72
|
+
|
|
73
|
+
> Icons and Lottie animations are **not** in this package β they live in
|
|
74
|
+
> `@stnd/icon` (`import Icon from "@stnd/icon/Icon.astro"`). See its README.
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## π§© Component API Reference
|
|
79
|
+
|
|
80
|
+
### Astro Components (Zero JS)
|
|
81
|
+
|
|
82
|
+
#### `<Accordion />`
|
|
83
|
+
Accessible, collapsible content sections.
|
|
84
|
+
- `open` (boolean): Sets the initial open state.
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
### Svelte 5 Components (Hydrated)
|
|
89
|
+
|
|
90
|
+
#### `<Alert />`
|
|
91
|
+
Semantic feedback banners.
|
|
92
|
+
- `class` (string): The semantic intent: `success`, `warning`, `error`, `info`. (Defaults to accent color).
|
|
93
|
+
- `title` (string): Optional bold title.
|
|
94
|
+
- `icon` (string): Optional string icon (e.g., `β`, `β `).
|
|
95
|
+
|
|
96
|
+
```svelte
|
|
97
|
+
<Alert class="warning" title="Watch out!" icon="β ">
|
|
98
|
+
This action cannot be undone.
|
|
99
|
+
</Alert>
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
#### `<Dropdown />`
|
|
103
|
+
Accessible, keyboard-navigable dropdown menus.
|
|
104
|
+
- `align` (string): Alignment of the menu (`start`, `center`, `end`). Defaults to `start`.
|
|
105
|
+
- **Slots**: `trigger` (the button that opens the menu), `default` (the menu items).
|
|
106
|
+
|
|
107
|
+
**Related Sub-components**:
|
|
108
|
+
- `<DropdownItem icon="ph:user" shortcut="βP">Profile</DropdownItem>`
|
|
109
|
+
- `<DropdownLabel label="My Account" />`
|
|
110
|
+
- `<DropdownSeparator />`
|
|
111
|
+
|
|
112
|
+
#### `<ContextMenu />`
|
|
113
|
+
Viewport-aware right-click menus.
|
|
114
|
+
- **Slots**: `default` (the area that triggers the menu on right-click), `content` (the menu items).
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## π¨ Dialog Manager
|
|
119
|
+
|
|
120
|
+
The `DialogManager` allows you to trigger accessible confirmation dialogs programmatically from any script using a simple Promise-based API. This prevents littering your DOM with hidden modal HTML.
|
|
121
|
+
|
|
122
|
+
### 1. Mount the Manager
|
|
123
|
+
Ensure `<DialogManagerComponent client:load />` is mounted once in your root layout (Standard does this by default).
|
|
124
|
+
|
|
125
|
+
### 2. Call the API
|
|
126
|
+
|
|
127
|
+
```javascript
|
|
128
|
+
import { confirm } from "@stnd/ui/dialog.js";
|
|
129
|
+
|
|
130
|
+
const isConfirmed = await confirm({
|
|
131
|
+
title: "Delete this item?",
|
|
132
|
+
description: "This action cannot be undone. Are you sure?",
|
|
133
|
+
confirmLabel: "Yes, Delete",
|
|
134
|
+
cancelLabel: "Cancel",
|
|
135
|
+
intent: "danger" // "neutral" | "danger"
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
if (isConfirmed) {
|
|
139
|
+
// Proceed with deletion
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
## Notes / Observations
|
|
144
|
+
|
|
145
|
+
*(jot down anything noticed here β quirks, gotchas, ideas)*
|
|
146
|
+
|
|
147
|
+
## Todo
|
|
148
|
+
|
|
149
|
+
- [ ] **README is thin relative to the component count** β `Combobox`, [priority:: 3] [token_scale:: 3] [created:: 2026-07-14] [area:: framework]
|
|
150
|
+
`Panel`, `Pagination`, `Scroller`, `TableOfContents`, `Toast`, `CfImage`, `LauncherHint` exist on disk but arenβt documented above. Worth a pass once this package settles.
|
package/Scroller.astro
ADDED
package/Scroller.svelte
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
let progress = $state(0);
|
|
3
|
+
|
|
4
|
+
function updateProgress() {
|
|
5
|
+
const scrollTop = window.scrollY;
|
|
6
|
+
const docHeight =
|
|
7
|
+
document.documentElement.scrollHeight - window.innerHeight;
|
|
8
|
+
progress = (scrollTop / docHeight) * 100;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
$effect(() => {
|
|
12
|
+
window.addEventListener("scroll", updateProgress);
|
|
13
|
+
return () => {
|
|
14
|
+
window.removeEventListener("scroll", updateProgress);
|
|
15
|
+
};
|
|
16
|
+
});
|
|
17
|
+
</script>
|
|
18
|
+
|
|
19
|
+
<div class="progress-container">
|
|
20
|
+
<div class="progress-bar" style="width: {progress}%"></div>
|
|
21
|
+
</div>
|
|
22
|
+
|
|
23
|
+
<style>
|
|
24
|
+
.progress-container {
|
|
25
|
+
position: fixed;
|
|
26
|
+
top: 0;
|
|
27
|
+
left: 0;
|
|
28
|
+
width: 100%;
|
|
29
|
+
height: var(--stroke-width-lg);
|
|
30
|
+
z-index: 999999999;
|
|
31
|
+
pointer-events: none;
|
|
32
|
+
margin-top: 0 !important;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.progress-bar {
|
|
36
|
+
height: 100%;
|
|
37
|
+
background-color: oklch(from var(--color-foreground) l c h / 0.15);
|
|
38
|
+
backdrop-filter: var(--filter-glass);
|
|
39
|
+
box-shadow: var(--shadow-lg) !important;
|
|
40
|
+
transition: width var(--transition-fast);
|
|
41
|
+
border-radius: var(--radius);
|
|
42
|
+
margin-top: 0 !important;
|
|
43
|
+
}
|
|
44
|
+
</style>
|