glasslikeui 1.9.0 → 1.10.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 +892 -24
- package/dist/actions/adaptiveTone.d.ts +50 -0
- package/dist/actions/adaptiveTone.js +569 -0
- package/dist/actions/alertLogic.d.ts +67 -0
- package/dist/actions/alertLogic.js +123 -0
- package/dist/actions/anchorPlacement.d.ts +92 -0
- package/dist/actions/anchorPlacement.js +137 -0
- package/dist/actions/dragSnap.d.ts +1 -1
- package/dist/actions/dragSnapMath.d.ts +70 -0
- package/dist/actions/dragSnapMath.js +115 -0
- package/dist/actions/glassToneLogic.d.ts +182 -0
- package/dist/actions/glassToneLogic.js +513 -0
- package/dist/actions/heightTransition.d.ts +32 -0
- package/dist/actions/heightTransition.js +64 -0
- package/dist/actions/index.d.ts +1 -0
- package/dist/actions/index.js +1 -0
- package/dist/actions/inertSiblings.js +20 -4
- package/dist/actions/menuLogic.d.ts +40 -0
- package/dist/actions/menuLogic.js +68 -0
- package/dist/actions/modalDialog.d.ts +19 -0
- package/dist/actions/modalDialog.js +48 -0
- package/dist/actions/popoverLogic.d.ts +25 -0
- package/dist/actions/popoverLogic.js +48 -0
- package/dist/actions/rovingIndex.d.ts +30 -0
- package/dist/actions/rovingIndex.js +49 -0
- package/dist/actions/scrollRunTracker.d.ts +36 -0
- package/dist/actions/scrollRunTracker.js +77 -0
- package/dist/actions/scrollUnder.d.ts +21 -0
- package/dist/actions/scrollUnder.js +29 -0
- package/dist/actions/segmentedLogic.d.ts +38 -0
- package/dist/actions/segmentedLogic.js +59 -0
- package/dist/actions/sheetLogic.d.ts +43 -0
- package/dist/actions/sheetLogic.js +71 -0
- package/dist/actions/sliderLogic.d.ts +29 -0
- package/dist/actions/sliderLogic.js +53 -0
- package/dist/actions/swipeActions.d.ts +46 -2
- package/dist/actions/swipeActions.js +267 -46
- package/dist/actions/tabBarMinimize.d.ts +31 -0
- package/dist/actions/tabBarMinimize.js +38 -0
- package/dist/actions/tabViewLogic.d.ts +47 -0
- package/dist/actions/tabViewLogic.js +71 -0
- package/dist/actions/toggleKnobLogic.d.ts +57 -0
- package/dist/actions/toggleKnobLogic.js +66 -0
- package/dist/actions/toolbarFocus.d.ts +44 -0
- package/dist/actions/toolbarFocus.js +228 -0
- package/dist/actions/topLayer.d.ts +12 -0
- package/dist/actions/topLayer.js +18 -0
- package/dist/components/dialog/ActionSheet.svelte +457 -0
- package/dist/components/dialog/ActionSheet.svelte.d.ts +25 -0
- package/dist/components/dialog/Alert.svelte +337 -0
- package/dist/components/dialog/Alert.svelte.d.ts +28 -0
- package/dist/components/dialog/index.d.ts +6 -0
- package/dist/components/dialog/index.js +6 -0
- package/dist/components/glass/Glass.svelte +49 -17
- package/dist/components/glass/Glass.svelte.d.ts +8 -0
- package/dist/components/glass/GlassSection.svelte +9 -1
- package/dist/components/glass/LensFilters.svelte +4 -2
- package/dist/components/glass/Popover.svelte +379 -0
- package/dist/components/glass/Popover.svelte.d.ts +30 -0
- package/dist/components/glass/Sheet.svelte +470 -103
- package/dist/components/glass/Sheet.svelte.d.ts +55 -7
- package/dist/components/glass/index.d.ts +3 -0
- package/dist/components/glass/index.js +1 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.js +4 -0
- package/dist/components/interactive/Badge.svelte +97 -6
- package/dist/components/interactive/Badge.svelte.d.ts +13 -2
- package/dist/components/interactive/Button.svelte +162 -20
- package/dist/components/interactive/Button.svelte.d.ts +14 -1
- package/dist/components/interactive/IconButton.svelte +214 -4
- package/dist/components/interactive/IconButton.svelte.d.ts +2 -1
- package/dist/components/interactive/ProgressView.svelte +306 -0
- package/dist/components/interactive/ProgressView.svelte.d.ts +25 -0
- package/dist/components/interactive/Segment.d.ts +14 -0
- package/dist/components/interactive/Segment.js +1 -0
- package/dist/components/interactive/SegmentedControl.svelte +399 -0
- package/dist/components/interactive/SegmentedControl.svelte.d.ts +17 -0
- package/dist/components/interactive/Slider.svelte +299 -0
- package/dist/components/interactive/Slider.svelte.d.ts +23 -0
- package/dist/components/interactive/TabView.svelte +573 -41
- package/dist/components/interactive/TabView.svelte.d.ts +25 -0
- package/dist/components/interactive/Toggle.svelte +287 -16
- package/dist/components/interactive/Toggle.svelte.d.ts +12 -0
- package/dist/components/interactive/index.d.ts +4 -0
- package/dist/components/interactive/index.js +3 -0
- package/dist/components/list/List.svelte +41 -17
- package/dist/components/list/List.svelte.d.ts +1 -0
- package/dist/components/list/ListRow.svelte +208 -47
- package/dist/components/list/ListRow.svelte.d.ts +16 -1
- package/dist/components/menu/Menu.svelte +51 -27
- package/dist/components/menu/Menu.svelte.d.ts +5 -0
- package/dist/components/menu/MenuItem.svelte +82 -25
- package/dist/components/menu/MenuItem.svelte.d.ts +8 -0
- package/dist/components/menu/MenuSection.svelte +95 -0
- package/dist/components/menu/MenuSection.svelte.d.ts +18 -0
- package/dist/components/menu/MenuSubmenu.svelte +196 -0
- package/dist/components/menu/MenuSubmenu.svelte.d.ts +11 -0
- package/dist/components/menu/index.d.ts +4 -1
- package/dist/components/menu/index.js +3 -1
- package/dist/components/navigation/NavigationBar.svelte +97 -15
- package/dist/components/navigation/NavigationBar.svelte.d.ts +6 -0
- package/dist/components/toolbar/Toolbar.svelte +43 -0
- package/dist/components/toolbar/Toolbar.svelte.d.ts +13 -0
- package/dist/components/toolbar/ToolbarItemGroup.svelte +45 -0
- package/dist/components/toolbar/ToolbarItemGroup.svelte.d.ts +14 -0
- package/dist/components/toolbar/ToolbarSpacer.svelte +36 -0
- package/dist/components/toolbar/ToolbarSpacer.svelte.d.ts +12 -0
- package/dist/components/toolbar/index.d.ts +7 -0
- package/dist/components/toolbar/index.js +7 -0
- package/dist/components/typography/Text.svelte +9 -1
- package/dist/constants/alertAction.d.ts +19 -0
- package/dist/constants/alertAction.js +1 -0
- package/dist/constants/badge.d.ts +32 -0
- package/dist/constants/badge.js +47 -0
- package/dist/constants/buttons.d.ts +45 -0
- package/dist/constants/buttons.js +52 -0
- package/dist/constants/colors.d.ts +9 -4
- package/dist/constants/colors.js +9 -4
- package/dist/constants/index.d.ts +3 -0
- package/dist/constants/index.js +3 -0
- package/dist/constants/progress.d.ts +56 -0
- package/dist/constants/progress.js +75 -0
- package/dist/constants/variants.d.ts +6 -2
- package/dist/constants/variants.js +2 -2
- package/dist/styles/glasslikeui.css +135 -1
- package/dist/styles/lens.css +21 -19
- package/dist/styles/squircle.css +17 -7
- package/package.json +1 -1
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { untrack } from 'svelte';
|
|
3
|
+
import type { AlertAction } from '../../constants/alertAction';
|
|
4
|
+
import {
|
|
5
|
+
DEFAULT_ALERT_ACTIONS,
|
|
6
|
+
alertLayout,
|
|
7
|
+
escapeActionIndex,
|
|
8
|
+
initialFocusIndex,
|
|
9
|
+
submitActionIndex,
|
|
10
|
+
warnAlertActions
|
|
11
|
+
} from '../../actions/alertLogic';
|
|
12
|
+
import { openModalDialog } from '../../actions/modalDialog';
|
|
13
|
+
|
|
14
|
+
/** The optional text field of an alert, as in SwiftUI's alert with a TextField action. */
|
|
15
|
+
interface AlertTextField {
|
|
16
|
+
/** The field's accessible name. */
|
|
17
|
+
label: string;
|
|
18
|
+
placeholder?: string | undefined;
|
|
19
|
+
type?: 'text' | 'password' | 'email' | 'url' | 'tel' | 'search' | undefined;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
interface Props {
|
|
23
|
+
/** Whether the alert is on screen. Choosing any action sets it back to false. */
|
|
24
|
+
isOpen?: boolean;
|
|
25
|
+
/** The alert's title, which also names the dialog. */
|
|
26
|
+
title: string;
|
|
27
|
+
/** Text under the title, which also describes the dialog. */
|
|
28
|
+
message?: string | undefined;
|
|
29
|
+
/** The buttons. With none, the alert shows a single OK button. */
|
|
30
|
+
actions?: readonly AlertAction[] | undefined;
|
|
31
|
+
/** Adds a text field above the buttons. Its text is bound through `value`. */
|
|
32
|
+
textField?: AlertTextField | undefined;
|
|
33
|
+
/** The text in the text field. */
|
|
34
|
+
value?: string;
|
|
35
|
+
/** Runs after an action closes the alert. */
|
|
36
|
+
onClose?: (() => void) | undefined;
|
|
37
|
+
class?: string | undefined;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
let {
|
|
41
|
+
isOpen = $bindable(false),
|
|
42
|
+
title,
|
|
43
|
+
message,
|
|
44
|
+
actions = DEFAULT_ALERT_ACTIONS,
|
|
45
|
+
textField,
|
|
46
|
+
value = $bindable(''),
|
|
47
|
+
onClose,
|
|
48
|
+
class: className = ''
|
|
49
|
+
}: Props = $props();
|
|
50
|
+
|
|
51
|
+
const uid = $props.id();
|
|
52
|
+
const titleId = `${uid}-title`;
|
|
53
|
+
const messageId = `${uid}-message`;
|
|
54
|
+
|
|
55
|
+
const shown = $derived(actions.length > 0 ? actions : DEFAULT_ALERT_ACTIONS);
|
|
56
|
+
const layout = $derived(alertLayout(shown));
|
|
57
|
+
|
|
58
|
+
let dialogEl = $state<HTMLElement | undefined>();
|
|
59
|
+
let fieldEl = $state<HTMLInputElement | undefined>();
|
|
60
|
+
const buttonEls: (HTMLButtonElement | undefined)[] = $state([]);
|
|
61
|
+
|
|
62
|
+
$effect(() => warnAlertActions('Alert', actions));
|
|
63
|
+
|
|
64
|
+
function choose(index: number) {
|
|
65
|
+
const action = shown[index];
|
|
66
|
+
if (!action || action.disabled || !isOpen) return;
|
|
67
|
+
isOpen = false;
|
|
68
|
+
action.onclick?.();
|
|
69
|
+
onClose?.();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function handleFieldKeydown(event: KeyboardEvent) {
|
|
73
|
+
if (event.key !== 'Enter' || event.isComposing) return;
|
|
74
|
+
const index = submitActionIndex(shown);
|
|
75
|
+
if (index === null) return;
|
|
76
|
+
event.preventDefault();
|
|
77
|
+
choose(index);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
$effect(() => {
|
|
81
|
+
const dialog = dialogEl;
|
|
82
|
+
if (!dialog) return;
|
|
83
|
+
return untrack(() =>
|
|
84
|
+
openModalDialog(dialog, {
|
|
85
|
+
layer: dialog.parentElement,
|
|
86
|
+
initialFocus: () => {
|
|
87
|
+
if (fieldEl) return fieldEl;
|
|
88
|
+
const index = initialFocusIndex(shown);
|
|
89
|
+
return index === null ? null : (buttonEls[index] ?? null);
|
|
90
|
+
},
|
|
91
|
+
onEscape: () => {
|
|
92
|
+
const index = escapeActionIndex(shown);
|
|
93
|
+
if (index !== null) choose(index);
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
);
|
|
97
|
+
});
|
|
98
|
+
</script>
|
|
99
|
+
|
|
100
|
+
{#if isOpen}
|
|
101
|
+
<div class="glass-alert-backdrop" role="presentation">
|
|
102
|
+
<div
|
|
103
|
+
bind:this={dialogEl}
|
|
104
|
+
class="glass-alert {className}"
|
|
105
|
+
role="alertdialog"
|
|
106
|
+
aria-modal="true"
|
|
107
|
+
aria-labelledby={titleId}
|
|
108
|
+
aria-describedby={message ? messageId : undefined}
|
|
109
|
+
tabindex="-1"
|
|
110
|
+
>
|
|
111
|
+
<div class="glass-alert-text">
|
|
112
|
+
<h2 class="glass-alert-title" id={titleId}>{title}</h2>
|
|
113
|
+
{#if message}
|
|
114
|
+
<p class="glass-alert-message" id={messageId}>{message}</p>
|
|
115
|
+
{/if}
|
|
116
|
+
</div>
|
|
117
|
+
{#if textField}
|
|
118
|
+
<input
|
|
119
|
+
bind:this={fieldEl}
|
|
120
|
+
bind:value
|
|
121
|
+
class="glass-alert-field"
|
|
122
|
+
type={textField.type ?? 'text'}
|
|
123
|
+
aria-label={textField.label}
|
|
124
|
+
placeholder={textField.placeholder}
|
|
125
|
+
onkeydown={handleFieldKeydown}
|
|
126
|
+
/>
|
|
127
|
+
{/if}
|
|
128
|
+
<div class="glass-alert-actions" data-axis={layout.axis}>
|
|
129
|
+
{#each layout.order as index (index)}
|
|
130
|
+
{@const action = shown[index]!}
|
|
131
|
+
<button
|
|
132
|
+
bind:this={buttonEls[index]}
|
|
133
|
+
type="button"
|
|
134
|
+
class="glass-alert-button"
|
|
135
|
+
class:destructive={action.role === 'destructive'}
|
|
136
|
+
class:cancel={action.role === 'cancel'}
|
|
137
|
+
class:preferred={action.preferred}
|
|
138
|
+
disabled={action.disabled}
|
|
139
|
+
onclick={() => choose(index)}
|
|
140
|
+
>
|
|
141
|
+
{action.label}
|
|
142
|
+
</button>
|
|
143
|
+
{/each}
|
|
144
|
+
</div>
|
|
145
|
+
</div>
|
|
146
|
+
</div>
|
|
147
|
+
{/if}
|
|
148
|
+
|
|
149
|
+
<style>
|
|
150
|
+
.glass-alert-backdrop {
|
|
151
|
+
position: fixed;
|
|
152
|
+
inset: 0;
|
|
153
|
+
z-index: 1100;
|
|
154
|
+
/* Reset the browser's popover box, for when the backdrop is shown in the
|
|
155
|
+
top layer (see topLayer.ts). z-index is the fallback elsewhere. */
|
|
156
|
+
margin: 0;
|
|
157
|
+
border: none;
|
|
158
|
+
width: auto;
|
|
159
|
+
height: auto;
|
|
160
|
+
max-width: none;
|
|
161
|
+
max-height: none;
|
|
162
|
+
overflow: visible;
|
|
163
|
+
color: inherit;
|
|
164
|
+
display: flex;
|
|
165
|
+
align-items: center;
|
|
166
|
+
justify-content: center;
|
|
167
|
+
padding: var(--spacing-md, 16px);
|
|
168
|
+
background: rgba(0, 0, 0, 0.4);
|
|
169
|
+
animation: glass-alert-fade var(--glass-alert-duration, 0.25s) ease-out;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
.glass-alert {
|
|
173
|
+
box-sizing: border-box;
|
|
174
|
+
width: min(300px, 100%);
|
|
175
|
+
max-height: calc(100vh - 32px);
|
|
176
|
+
overflow-y: auto;
|
|
177
|
+
display: flex;
|
|
178
|
+
flex-direction: column;
|
|
179
|
+
gap: 16px;
|
|
180
|
+
padding: 22px 18px 18px;
|
|
181
|
+
background: var(--glass-sheet-bg);
|
|
182
|
+
backdrop-filter: blur(var(--glass-blur-nav)) saturate(var(--glass-saturation));
|
|
183
|
+
-webkit-backdrop-filter: blur(var(--glass-blur-nav)) saturate(var(--glass-saturation));
|
|
184
|
+
border: var(--glass-border-width) solid var(--glass-border);
|
|
185
|
+
border-radius: var(--glass-alert-radius, 34px);
|
|
186
|
+
box-shadow:
|
|
187
|
+
0 24px 60px -12px var(--glass-shadow),
|
|
188
|
+
inset 0 1px 0 0 var(--glass-highlight);
|
|
189
|
+
color: var(--glass-fg, var(--color-text, var(--glass-text-color-default, #f5f5f7)));
|
|
190
|
+
font-family: var(--font-system);
|
|
191
|
+
text-align: center;
|
|
192
|
+
outline: none;
|
|
193
|
+
animation: glass-alert-pop var(--glass-alert-duration, 0.25s) cubic-bezier(0.32, 0.72, 0, 1);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/* iOS 26 leads the title and message from the inline start, with a bold
|
|
197
|
+
title (WWDC25 356). start, not left, so RTL mirrors it. */
|
|
198
|
+
.glass-alert-text {
|
|
199
|
+
display: flex;
|
|
200
|
+
flex-direction: column;
|
|
201
|
+
gap: 6px;
|
|
202
|
+
text-align: start;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
.glass-alert-title {
|
|
206
|
+
margin: 0;
|
|
207
|
+
font-size: 17px;
|
|
208
|
+
font-weight: 700;
|
|
209
|
+
line-height: 1.3;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
.glass-alert-message {
|
|
213
|
+
margin: 0;
|
|
214
|
+
font-size: 14px;
|
|
215
|
+
line-height: 1.4;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
.glass-alert-field {
|
|
219
|
+
box-sizing: border-box;
|
|
220
|
+
width: 100%;
|
|
221
|
+
padding: 10px 16px;
|
|
222
|
+
font: inherit;
|
|
223
|
+
font-size: 15px;
|
|
224
|
+
color: inherit;
|
|
225
|
+
background: color-mix(in srgb, currentColor 10%, transparent);
|
|
226
|
+
border: var(--glass-border-width) solid var(--glass-border);
|
|
227
|
+
/* A capsule, like the buttons under it, as in iOS 26. */
|
|
228
|
+
border-radius: var(--glass-radius-full);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
.glass-alert-field::placeholder {
|
|
232
|
+
color: inherit;
|
|
233
|
+
opacity: 0.7;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
.glass-alert-actions {
|
|
237
|
+
display: flex;
|
|
238
|
+
flex-direction: column;
|
|
239
|
+
gap: 8px;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
.glass-alert-actions[data-axis='horizontal'] {
|
|
243
|
+
flex-direction: row;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
.glass-alert-button {
|
|
247
|
+
flex: 1 1 0;
|
|
248
|
+
min-width: 0;
|
|
249
|
+
min-height: 44px;
|
|
250
|
+
padding: 10px 16px;
|
|
251
|
+
font: inherit;
|
|
252
|
+
font-size: 17px;
|
|
253
|
+
font-weight: 500;
|
|
254
|
+
text-align: center;
|
|
255
|
+
color: inherit;
|
|
256
|
+
/* The glass highlight: a faint white lift on a dark alert and a near white
|
|
257
|
+
capsule on a light one, so every label, red included, keeps its contrast. */
|
|
258
|
+
background-color: var(--glass-highlight);
|
|
259
|
+
border: none;
|
|
260
|
+
border-radius: var(--glass-radius-full);
|
|
261
|
+
cursor: pointer;
|
|
262
|
+
transition: background var(--transition-fast), transform var(--transition-fast);
|
|
263
|
+
--_danger-text: var(--color-danger-text, color-mix(in srgb, var(--color-danger) var(--glass-danger-text-strength, 30%), var(--glass-text-toward, white)));
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
.glass-alert-button:hover:not(:disabled) {
|
|
267
|
+
background-image: linear-gradient(var(--glass-hover-bg), var(--glass-hover-bg));
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
.glass-alert-button:active:not(:disabled) {
|
|
271
|
+
transform: scale(0.97);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
.glass-alert-button.destructive {
|
|
275
|
+
color: var(--_danger-text);
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
/* The default action is filled with the accent, white text on it. */
|
|
279
|
+
.glass-alert-button.preferred {
|
|
280
|
+
font-weight: 600;
|
|
281
|
+
color: #ffffff;
|
|
282
|
+
background: var(--color-accent);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
.glass-alert-button.preferred:hover:not(:disabled) {
|
|
286
|
+
background: var(--color-accent-hover);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
.glass-alert-button.preferred.destructive {
|
|
290
|
+
background: var(--color-danger-active);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
.glass-alert-button:disabled {
|
|
294
|
+
cursor: default;
|
|
295
|
+
opacity: 0.45;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/* Shared focus ring. :where keeps it at zero specificity, so a page's own
|
|
299
|
+
focus rules win. */
|
|
300
|
+
:where(.glass-alert-button:focus-visible),
|
|
301
|
+
:where(.glass-alert-field:focus-visible) {
|
|
302
|
+
outline: var(--glass-focus-ring-width, 2px) solid var(--glass-focus-ring-color, var(--glass-focus-ring-color-default, #9ecbff));
|
|
303
|
+
outline-offset: var(--glass-focus-ring-offset, 2px);
|
|
304
|
+
box-shadow: 0 0 0 var(--glass-focus-ring-offset, 2px) var(--glass-focus-ring-halo-color, var(--glass-focus-ring-halo-color-default, #000000));
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
@keyframes glass-alert-pop {
|
|
308
|
+
from {
|
|
309
|
+
opacity: 0;
|
|
310
|
+
transform: scale(1.12);
|
|
311
|
+
}
|
|
312
|
+
to {
|
|
313
|
+
opacity: 1;
|
|
314
|
+
transform: scale(1);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
@keyframes glass-alert-fade {
|
|
319
|
+
from {
|
|
320
|
+
opacity: 0;
|
|
321
|
+
}
|
|
322
|
+
to {
|
|
323
|
+
opacity: 1;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/* Reduced motion: the alert fades in, with no change of size. */
|
|
328
|
+
@media (prefers-reduced-motion: reduce) {
|
|
329
|
+
.glass-alert {
|
|
330
|
+
animation-name: glass-alert-fade;
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
:global([data-reduced-motion='true']) .glass-alert {
|
|
335
|
+
animation-name: glass-alert-fade;
|
|
336
|
+
}
|
|
337
|
+
</style>
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { AlertAction } from '../../constants/alertAction';
|
|
2
|
+
/** The optional text field of an alert, as in SwiftUI's alert with a TextField action. */
|
|
3
|
+
interface AlertTextField {
|
|
4
|
+
/** The field's accessible name. */
|
|
5
|
+
label: string;
|
|
6
|
+
placeholder?: string | undefined;
|
|
7
|
+
type?: 'text' | 'password' | 'email' | 'url' | 'tel' | 'search' | undefined;
|
|
8
|
+
}
|
|
9
|
+
interface Props {
|
|
10
|
+
/** Whether the alert is on screen. Choosing any action sets it back to false. */
|
|
11
|
+
isOpen?: boolean;
|
|
12
|
+
/** The alert's title, which also names the dialog. */
|
|
13
|
+
title: string;
|
|
14
|
+
/** Text under the title, which also describes the dialog. */
|
|
15
|
+
message?: string | undefined;
|
|
16
|
+
/** The buttons. With none, the alert shows a single OK button. */
|
|
17
|
+
actions?: readonly AlertAction[] | undefined;
|
|
18
|
+
/** Adds a text field above the buttons. Its text is bound through `value`. */
|
|
19
|
+
textField?: AlertTextField | undefined;
|
|
20
|
+
/** The text in the text field. */
|
|
21
|
+
value?: string;
|
|
22
|
+
/** Runs after an action closes the alert. */
|
|
23
|
+
onClose?: (() => void) | undefined;
|
|
24
|
+
class?: string | undefined;
|
|
25
|
+
}
|
|
26
|
+
declare const Alert: import("svelte").Component<Props, {}, string>;
|
|
27
|
+
type Alert = ReturnType<typeof Alert>;
|
|
28
|
+
export default Alert;
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
} from '../../constants/shapes';
|
|
17
17
|
import { fromAction } from 'svelte/attachments';
|
|
18
18
|
import { deviceMotion } from '../../actions/deviceMotion';
|
|
19
|
+
import { adaptiveTone, type GlassTone } from '../../actions/adaptiveTone';
|
|
19
20
|
|
|
20
21
|
interface Props {
|
|
21
22
|
children: Snippet;
|
|
@@ -29,6 +30,13 @@
|
|
|
29
30
|
shadow?: boolean;
|
|
30
31
|
interactive?: boolean;
|
|
31
32
|
motion?: boolean;
|
|
33
|
+
/**
|
|
34
|
+
* How the text on the glass picks its colour. `auto` flips it between
|
|
35
|
+
* dark and light to suit the backdrop, as iOS 26 does. `light` and `dark`
|
|
36
|
+
* force the tone for a backdrop of that kind. `theme` keeps the theme's
|
|
37
|
+
* text colours.
|
|
38
|
+
*/
|
|
39
|
+
tone?: GlassTone;
|
|
32
40
|
class?: string;
|
|
33
41
|
style?: string;
|
|
34
42
|
}
|
|
@@ -44,6 +52,7 @@
|
|
|
44
52
|
shadow = true,
|
|
45
53
|
interactive = false,
|
|
46
54
|
motion = false,
|
|
55
|
+
tone = 'auto',
|
|
47
56
|
class: className = '',
|
|
48
57
|
style: customStyle = ''
|
|
49
58
|
}: Props = $props();
|
|
@@ -54,6 +63,9 @@
|
|
|
54
63
|
const vcfg = $derived(VARIANT_CONFIG[variant] ?? VARIANT_CONFIG[DEFAULT_VARIANT]);
|
|
55
64
|
const shapeStyle = $derived(glassShapeStyle(shape, cornerRadius));
|
|
56
65
|
// Marks a surface that shows the tint, not a background of the page's own.
|
|
66
|
+
// A forced tone is in the markup, so it is there before any script runs,
|
|
67
|
+
// ready, as nothing will measure it.
|
|
68
|
+
const forcedTone = $derived(tone === 'light' || tone === 'dark' ? tone : undefined);
|
|
57
69
|
const hasTint = $derived(
|
|
58
70
|
!!tint && !/(^|;)\s*background(-color|-image)?\s*:/i.test(customStyle)
|
|
59
71
|
);
|
|
@@ -63,11 +75,14 @@
|
|
|
63
75
|
<div
|
|
64
76
|
class="glass-surface {variant} {className}"
|
|
65
77
|
data-glass-shape={shape}
|
|
78
|
+
data-glass-tone={forcedTone}
|
|
79
|
+
data-glass-tone-ready={forcedTone ? '' : undefined}
|
|
66
80
|
class:has-lensing={cfg.displacementScale > 0}
|
|
67
81
|
class:has-tint={hasTint}
|
|
68
82
|
class:has-shadow={shadow}
|
|
69
83
|
class:is-interactive={interactive}
|
|
70
84
|
{@attach fromAction(deviceMotion, () => ({}))}
|
|
85
|
+
{@attach fromAction(adaptiveTone, () => ({ tone }))}
|
|
71
86
|
style="
|
|
72
87
|
--glass-blur: {cfg.blur}px;
|
|
73
88
|
--glass-saturation: {cfg.saturation};
|
|
@@ -88,10 +103,13 @@
|
|
|
88
103
|
<div
|
|
89
104
|
class="glass-surface {variant} {className}"
|
|
90
105
|
data-glass-shape={shape}
|
|
106
|
+
data-glass-tone={forcedTone}
|
|
107
|
+
data-glass-tone-ready={forcedTone ? '' : undefined}
|
|
91
108
|
class:has-lensing={cfg.displacementScale > 0}
|
|
92
109
|
class:has-tint={hasTint}
|
|
93
110
|
class:has-shadow={shadow}
|
|
94
111
|
class:is-interactive={interactive}
|
|
112
|
+
{@attach fromAction(adaptiveTone, () => ({ tone }))}
|
|
95
113
|
style="
|
|
96
114
|
--glass-blur: {cfg.blur}px;
|
|
97
115
|
--glass-saturation: {cfg.saturation};
|
|
@@ -111,16 +129,30 @@
|
|
|
111
129
|
{/if}
|
|
112
130
|
|
|
113
131
|
<style>
|
|
114
|
-
|
|
132
|
+
/* Zero specificity, so a class passed to Glass can place the surface, such
|
|
133
|
+
as the TabView bar's position: fixed. */
|
|
134
|
+
:where(.glass-surface) {
|
|
115
135
|
position: relative;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
.glass-surface {
|
|
116
139
|
isolation: isolate;
|
|
117
140
|
background: var(--glass-surface-bg);
|
|
118
141
|
border-radius: var(--glass-radius, var(--glass-radius-lg));
|
|
119
142
|
overflow: hidden;
|
|
120
|
-
|
|
143
|
+
/* The adaptive tone (see adaptiveTone), or the colour around it. On
|
|
144
|
+
the color property currentColor is the inherited colour. The text
|
|
145
|
+
cross-fades as the tone flips, and switches at once under reduced
|
|
146
|
+
motion, where --transition is 0s. */
|
|
147
|
+
color: var(--glass-fg, currentColor);
|
|
121
148
|
font-family: var(--font-system);
|
|
122
149
|
}
|
|
123
150
|
|
|
151
|
+
/* Fades only once the first tone is in (see adaptiveTone). */
|
|
152
|
+
.glass-surface:global([data-glass-tone-ready]) {
|
|
153
|
+
transition: color var(--transition);
|
|
154
|
+
}
|
|
155
|
+
|
|
124
156
|
.glass-surface::before {
|
|
125
157
|
content: '';
|
|
126
158
|
position: absolute;
|
|
@@ -132,10 +164,6 @@
|
|
|
132
164
|
pointer-events: none;
|
|
133
165
|
}
|
|
134
166
|
|
|
135
|
-
.glass-surface.has-lensing::before {
|
|
136
|
-
filter: url(#glass-lens-refract);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
167
|
.glass-surface::after {
|
|
140
168
|
content: '';
|
|
141
169
|
position: absolute;
|
|
@@ -144,17 +172,22 @@
|
|
|
144
172
|
border-radius: inherit;
|
|
145
173
|
pointer-events: none;
|
|
146
174
|
border: var(--glass-border-width) solid var(--glass-border);
|
|
175
|
+
/* The lens rim: a thin specular line and a soft glow inside every edge,
|
|
176
|
+
the same on all four sides. No filter displaces the shape, so the
|
|
177
|
+
silhouette stays crisp, as iOS 26 glass does. */
|
|
147
178
|
box-shadow:
|
|
148
|
-
inset 0
|
|
149
|
-
inset 0
|
|
179
|
+
inset 0 0 0 0.5px var(--glass-highlight),
|
|
180
|
+
inset 0 0 10px 0 rgba(255, 255, 255, 0.06);
|
|
150
181
|
background: linear-gradient(
|
|
151
182
|
var(--glass-highlight-angle),
|
|
152
|
-
rgba(255, 255, 255, calc(0.
|
|
183
|
+
rgba(255, 255, 255, calc(0.05 * var(--glass-motion-enabled))) 0%,
|
|
153
184
|
transparent 40%,
|
|
154
185
|
transparent 60%,
|
|
155
|
-
rgba(0, 0, 0, calc(0.
|
|
186
|
+
rgba(0, 0, 0, calc(0.03 * var(--glass-motion-enabled))) 100%
|
|
156
187
|
);
|
|
157
|
-
|
|
188
|
+
/* Normal blending. An overlay blend here made Chromium treat the surface as
|
|
189
|
+
its own backdrop root, so the backdrop layer blurred only the surface's
|
|
190
|
+
fill: no blur of the page, and the fill painted twice. */
|
|
158
191
|
}
|
|
159
192
|
|
|
160
193
|
.glass-content {
|
|
@@ -215,6 +248,9 @@
|
|
|
215
248
|
cursor: pointer;
|
|
216
249
|
transition: transform var(--transition-fast), box-shadow var(--transition-fast);
|
|
217
250
|
}
|
|
251
|
+
.glass-surface.is-interactive:global([data-glass-tone-ready]) {
|
|
252
|
+
transition: transform var(--transition-fast), box-shadow var(--transition-fast), color var(--transition);
|
|
253
|
+
}
|
|
218
254
|
.glass-surface.is-interactive:hover {
|
|
219
255
|
transform: scale(calc(1 + 0.01 * var(--glass-motion-enabled)));
|
|
220
256
|
box-shadow:
|
|
@@ -241,12 +277,10 @@
|
|
|
241
277
|
backdrop-filter: none;
|
|
242
278
|
-webkit-backdrop-filter: none;
|
|
243
279
|
}
|
|
244
|
-
.glass-surface.has-lensing::before {
|
|
245
|
-
filter: none;
|
|
246
|
-
}
|
|
247
280
|
.glass-surface::after {
|
|
248
281
|
background: none;
|
|
249
282
|
mix-blend-mode: normal;
|
|
283
|
+
box-shadow: inset 0 0 0 0.5px var(--glass-highlight);
|
|
250
284
|
}
|
|
251
285
|
.glass-surface:where(.has-tint) {
|
|
252
286
|
background: rgb(var(--glass-surface-color, 28, 28, 30));
|
|
@@ -262,12 +296,10 @@
|
|
|
262
296
|
backdrop-filter: none;
|
|
263
297
|
-webkit-backdrop-filter: none;
|
|
264
298
|
}
|
|
265
|
-
:global(:where([data-reduced-transparency='true'])) .glass-surface.has-lensing::before {
|
|
266
|
-
filter: none;
|
|
267
|
-
}
|
|
268
299
|
:global(:where([data-reduced-transparency='true'])) .glass-surface::after {
|
|
269
300
|
background: none;
|
|
270
301
|
mix-blend-mode: normal;
|
|
302
|
+
box-shadow: inset 0 0 0 0.5px var(--glass-highlight);
|
|
271
303
|
}
|
|
272
304
|
:global(:where([data-reduced-transparency='true'])) .glass-surface:where(.has-tint) {
|
|
273
305
|
background: rgb(var(--glass-surface-color, 28, 28, 30));
|
|
@@ -2,6 +2,7 @@ import type { Snippet } from 'svelte';
|
|
|
2
2
|
import { type GlassVariant, type GlassIntensity } from '../../constants/variants';
|
|
3
3
|
import { type CornerRadius, type Padding } from '../../constants';
|
|
4
4
|
import { type GlassShape } from '../../constants/shapes';
|
|
5
|
+
import { type GlassTone } from '../../actions/adaptiveTone';
|
|
5
6
|
interface Props {
|
|
6
7
|
children: Snippet;
|
|
7
8
|
variant?: GlassVariant;
|
|
@@ -14,6 +15,13 @@ interface Props {
|
|
|
14
15
|
shadow?: boolean;
|
|
15
16
|
interactive?: boolean;
|
|
16
17
|
motion?: boolean;
|
|
18
|
+
/**
|
|
19
|
+
* How the text on the glass picks its colour. `auto` flips it between
|
|
20
|
+
* dark and light to suit the backdrop, as iOS 26 does. `light` and `dark`
|
|
21
|
+
* force the tone for a backdrop of that kind. `theme` keeps the theme's
|
|
22
|
+
* text colours.
|
|
23
|
+
*/
|
|
24
|
+
tone?: GlassTone;
|
|
17
25
|
class?: string;
|
|
18
26
|
style?: string;
|
|
19
27
|
}
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
font-weight: 600;
|
|
68
68
|
letter-spacing: -0.02em;
|
|
69
69
|
margin-bottom: var(--spacing-xs);
|
|
70
|
-
background: var(--glass-text-gradient);
|
|
70
|
+
background: var(--glass-text-gradient, linear-gradient(currentColor, currentColor));
|
|
71
71
|
-webkit-background-clip: text;
|
|
72
72
|
-webkit-text-fill-color: transparent;
|
|
73
73
|
background-clip: text;
|
|
@@ -79,4 +79,12 @@
|
|
|
79
79
|
max-width: 600px;
|
|
80
80
|
margin: 0 auto;
|
|
81
81
|
}
|
|
82
|
+
|
|
83
|
+
/* Forced colours drop the background image, so paint the text plainly. */
|
|
84
|
+
@media (forced-colors: active) {
|
|
85
|
+
.section-title {
|
|
86
|
+
background: none;
|
|
87
|
+
-webkit-text-fill-color: currentColor;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
82
90
|
</style>
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
<!--
|
|
2
|
-
Mount once at app root. Provides
|
|
3
|
-
|
|
2
|
+
Mount once at app root. Provides the squircle clip path used by .glass-squircle,
|
|
3
|
+
and the deprecated #glass-lens-refract filter for pages that apply it
|
|
4
|
+
themselves. Glass no longer applies the filter: its noise displacement warped
|
|
5
|
+
the surface edge. The filter will be removed in the next major version.
|
|
4
6
|
-->
|
|
5
7
|
<script lang="ts"></script>
|
|
6
8
|
|