glasslikeui 1.8.0 → 1.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
CHANGED
|
@@ -164,8 +164,21 @@ to mirror all of these onto an ancestor that your strip can read.
|
|
|
164
164
|
```
|
|
165
165
|
|
|
166
166
|
A sheet with a `title` shows a header with the title centred and an icon-only
|
|
167
|
-
close button (`aria-label="Close"`) at the
|
|
168
|
-
`dialog`, labelled by its title (or by an `aria-label`
|
|
167
|
+
close button (`aria-label="Close"`) at the leading side, as on iOS 26 sheets.
|
|
168
|
+
The sheet is a modal `dialog`, labelled by its title (or by an `aria-label`
|
|
169
|
+
when there is none).
|
|
170
|
+
|
|
171
|
+
- `closePlacement` picks the side of the close button: `'leading'` (the
|
|
172
|
+
default) or `'trailing'`, the placement before 1.9. The sides are logical:
|
|
173
|
+
under `dir="rtl"` leading is the right. The button moves in the DOM as well,
|
|
174
|
+
so Tab reaches it first in the header when it leads. The title stays centred
|
|
175
|
+
either way. The header carries `data-close-placement` with the value in use.
|
|
176
|
+
|
|
177
|
+
```svelte
|
|
178
|
+
<Sheet bind:isOpen title="Options" closePlacement="trailing">
|
|
179
|
+
{#snippet children()}...{/snippet}
|
|
180
|
+
</Sheet>
|
|
181
|
+
```
|
|
169
182
|
|
|
170
183
|
- Dragging the handle or the header moves the sheet between its detents.
|
|
171
184
|
Presses on the close button or on interactive content never start a drag.
|
|
@@ -39,6 +39,14 @@
|
|
|
39
39
|
* close button, Escape and the backdrop still close the sheet.
|
|
40
40
|
*/
|
|
41
41
|
interactiveDismissDisabled?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Which side of the header the close button sits on. 'leading' (the
|
|
44
|
+
* default, as on iOS 26 sheets) is the left in LTR and the right in RTL;
|
|
45
|
+
* 'trailing' is the opposite side, the placement before 1.9. The button
|
|
46
|
+
* moves in the DOM too, so it is first in the header's Tab order when it
|
|
47
|
+
* leads.
|
|
48
|
+
*/
|
|
49
|
+
closePlacement?: 'leading' | 'trailing';
|
|
42
50
|
class?: string;
|
|
43
51
|
}
|
|
44
52
|
|
|
@@ -53,12 +61,15 @@
|
|
|
53
61
|
showHandle = true,
|
|
54
62
|
draggable = true,
|
|
55
63
|
interactiveDismissDisabled = false,
|
|
64
|
+
closePlacement = 'leading',
|
|
56
65
|
class: className = ''
|
|
57
66
|
}: Props = $props();
|
|
58
67
|
|
|
59
68
|
const uid = $props.id();
|
|
60
69
|
const titleId = `${uid}-title`;
|
|
61
70
|
|
|
71
|
+
const closeLeads = $derived(closePlacement !== 'trailing');
|
|
72
|
+
|
|
62
73
|
const fractions = $derived(detentFractions(detents));
|
|
63
74
|
const initialIndex = $derived(Math.max(0, detents.indexOf(initialDetent)));
|
|
64
75
|
|
|
@@ -211,6 +222,26 @@
|
|
|
211
222
|
|
|
212
223
|
<svelte:window onkeydown={handleKeydown} />
|
|
213
224
|
|
|
225
|
+
{#snippet closeButton()}
|
|
226
|
+
<button type="button" class="sheet-close-btn" onclick={close} aria-label="Close">
|
|
227
|
+
<svg
|
|
228
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
229
|
+
width="16"
|
|
230
|
+
height="16"
|
|
231
|
+
viewBox="0 0 24 24"
|
|
232
|
+
fill="none"
|
|
233
|
+
stroke="currentColor"
|
|
234
|
+
stroke-width="2.5"
|
|
235
|
+
stroke-linecap="round"
|
|
236
|
+
stroke-linejoin="round"
|
|
237
|
+
aria-hidden="true"
|
|
238
|
+
focusable="false"
|
|
239
|
+
>
|
|
240
|
+
{@html getIconPath('xmark')}
|
|
241
|
+
</svg>
|
|
242
|
+
</button>
|
|
243
|
+
{/snippet}
|
|
244
|
+
|
|
214
245
|
{#if present}
|
|
215
246
|
<div
|
|
216
247
|
class="sheet-backdrop"
|
|
@@ -248,26 +279,18 @@
|
|
|
248
279
|
{/if}
|
|
249
280
|
|
|
250
281
|
{#if title}
|
|
251
|
-
<header class="sheet-header">
|
|
252
|
-
|
|
282
|
+
<header class="sheet-header" data-close-placement={closeLeads ? 'leading' : 'trailing'}>
|
|
283
|
+
{#if closeLeads}
|
|
284
|
+
{@render closeButton()}
|
|
285
|
+
{:else}
|
|
286
|
+
<div class="sheet-spacer"></div>
|
|
287
|
+
{/if}
|
|
253
288
|
<h2 class="sheet-title" id={titleId}>{title}</h2>
|
|
254
|
-
|
|
255
|
-
<
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
viewBox="0 0 24 24"
|
|
260
|
-
fill="none"
|
|
261
|
-
stroke="currentColor"
|
|
262
|
-
stroke-width="2.5"
|
|
263
|
-
stroke-linecap="round"
|
|
264
|
-
stroke-linejoin="round"
|
|
265
|
-
aria-hidden="true"
|
|
266
|
-
focusable="false"
|
|
267
|
-
>
|
|
268
|
-
{@html getIconPath('xmark')}
|
|
269
|
-
</svg>
|
|
270
|
-
</button>
|
|
289
|
+
{#if closeLeads}
|
|
290
|
+
<div class="sheet-spacer"></div>
|
|
291
|
+
{:else}
|
|
292
|
+
{@render closeButton()}
|
|
293
|
+
{/if}
|
|
271
294
|
</header>
|
|
272
295
|
{/if}
|
|
273
296
|
|
|
@@ -350,8 +373,9 @@
|
|
|
350
373
|
border-radius: 3px;
|
|
351
374
|
}
|
|
352
375
|
|
|
353
|
-
/* Title centred between
|
|
354
|
-
title stays centred whatever its length. The header is also a
|
|
376
|
+
/* Title centred between the close button and an empty cell of the same
|
|
377
|
+
width, so the title stays centred whatever its length. The header is also a
|
|
378
|
+
drag region. */
|
|
355
379
|
.sheet-header {
|
|
356
380
|
padding: 0 var(--spacing-md);
|
|
357
381
|
height: 56px;
|
|
@@ -362,6 +386,23 @@
|
|
|
362
386
|
gap: var(--spacing-sm);
|
|
363
387
|
}
|
|
364
388
|
|
|
389
|
+
/* Grid lines are logical: column 1 is the inline start, so a leading close
|
|
390
|
+
button sits on the left in LTR and on the right in RTL. The DOM order
|
|
391
|
+
matches, so Tab reaches the button on the side it is drawn. */
|
|
392
|
+
.sheet-title {
|
|
393
|
+
grid-column: 2;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
.sheet-header[data-close-placement='leading'] .sheet-close-btn,
|
|
397
|
+
.sheet-header[data-close-placement='trailing'] .sheet-spacer {
|
|
398
|
+
grid-column: 1;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
.sheet-header[data-close-placement='leading'] .sheet-spacer,
|
|
402
|
+
.sheet-header[data-close-placement='trailing'] .sheet-close-btn {
|
|
403
|
+
grid-column: 3;
|
|
404
|
+
}
|
|
405
|
+
|
|
365
406
|
.sheet-close-btn {
|
|
366
407
|
display: inline-flex;
|
|
367
408
|
align-items: center;
|
|
@@ -16,6 +16,14 @@ interface Props {
|
|
|
16
16
|
* close button, Escape and the backdrop still close the sheet.
|
|
17
17
|
*/
|
|
18
18
|
interactiveDismissDisabled?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Which side of the header the close button sits on. 'leading' (the
|
|
21
|
+
* default, as on iOS 26 sheets) is the left in LTR and the right in RTL;
|
|
22
|
+
* 'trailing' is the opposite side, the placement before 1.9. The button
|
|
23
|
+
* moves in the DOM too, so it is first in the header's Tab order when it
|
|
24
|
+
* leads.
|
|
25
|
+
*/
|
|
26
|
+
closePlacement?: 'leading' | 'trailing';
|
|
19
27
|
class?: string;
|
|
20
28
|
}
|
|
21
29
|
declare const Sheet: import("svelte").Component<Props, {}, string>;
|