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
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
+
import { type TabBarMinimizeBehavior } from '../../actions/tabBarMinimize';
|
|
3
|
+
import { type BadgeValue } from '../../constants/badge';
|
|
2
4
|
interface Tab {
|
|
3
5
|
id: string;
|
|
4
6
|
label: string;
|
|
5
7
|
icon?: Snippet;
|
|
8
|
+
/** A badge on the tab: a count, a short text, or `true` for a dot. Below 1, empty or false shows none. */
|
|
9
|
+
badge?: BadgeValue;
|
|
10
|
+
/** The words read for the badge, such as "3 unread". Defaults to the badge text, or "New" for a dot. */
|
|
11
|
+
badgeLabel?: string;
|
|
12
|
+
/** `'search'` sets the tab apart at the trailing end of the bar, in its own circle. */
|
|
13
|
+
role?: 'search';
|
|
6
14
|
}
|
|
15
|
+
/** Where the bottom accessory sits: above the bar, or inline with a minimised bar. */
|
|
16
|
+
type AccessoryPlacement = 'expanded' | 'inline';
|
|
7
17
|
interface Props {
|
|
8
18
|
tabs: Tab[];
|
|
9
19
|
activeTab?: string;
|
|
@@ -11,6 +21,21 @@ interface Props {
|
|
|
11
21
|
position?: 'top' | 'bottom';
|
|
12
22
|
inline?: boolean;
|
|
13
23
|
onchange?: (id: string) => void;
|
|
24
|
+
/** Accessible name for the tab list, read before the tabs. */
|
|
25
|
+
label?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Content in its own glass capsule above the bar, such as a now playing
|
|
28
|
+
* control. It moves inline between the collapsed tab and the search tab
|
|
29
|
+
* when the bar minimises, and gets the placement to adapt its layout.
|
|
30
|
+
*/
|
|
31
|
+
bottomAccessory?: Snippet<[{
|
|
32
|
+
placement: AccessoryPlacement;
|
|
33
|
+
}]>;
|
|
34
|
+
/**
|
|
35
|
+
* When the bar minimises to the selected tab as the page or the tab
|
|
36
|
+
* content scrolls. Defaults to `'never'`.
|
|
37
|
+
*/
|
|
38
|
+
minimizeBehavior?: TabBarMinimizeBehavior;
|
|
14
39
|
class?: string;
|
|
15
40
|
}
|
|
16
41
|
declare const TabView: import("svelte").Component<Props, {}, string>;
|
|
@@ -1,11 +1,33 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import { fitFocusRing } from '../../actions/focusRingFit';
|
|
3
|
+
import {
|
|
4
|
+
isKnobDrag,
|
|
5
|
+
isOnAtRelease,
|
|
6
|
+
isPressPointer,
|
|
7
|
+
knobOffset,
|
|
8
|
+
knobTravel,
|
|
9
|
+
toggleAppearance,
|
|
10
|
+
toggleKnob,
|
|
11
|
+
towardOn
|
|
12
|
+
} from '../../actions/toggleKnobLogic';
|
|
3
13
|
|
|
4
14
|
interface Props {
|
|
5
15
|
/** Two-way bound on/off state. */
|
|
6
16
|
checked?: boolean;
|
|
7
17
|
label: string;
|
|
8
18
|
disabled?: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* The switch's look. `glass` (default) is the iOS 26 switch: a 63 by 28
|
|
21
|
+
* track with a capsule knob. `classic` is the 51 by 31 switch with a round
|
|
22
|
+
* knob from before iOS 26.
|
|
23
|
+
*/
|
|
24
|
+
appearance?: 'glass' | 'classic';
|
|
25
|
+
/**
|
|
26
|
+
* The knob's press. `glass` turns it into a clear glass lens while pressed
|
|
27
|
+
* and lets it be dragged across, as on iOS 26. `solid` keeps the white knob.
|
|
28
|
+
* Defaults to `glass`, or `solid` with `appearance="classic"`.
|
|
29
|
+
*/
|
|
30
|
+
knob?: 'solid' | 'glass';
|
|
9
31
|
onchange?: ((checked: boolean) => void) | undefined;
|
|
10
32
|
class?: string;
|
|
11
33
|
}
|
|
@@ -14,6 +36,8 @@
|
|
|
14
36
|
checked = $bindable(false),
|
|
15
37
|
label,
|
|
16
38
|
disabled = false,
|
|
39
|
+
appearance = 'glass',
|
|
40
|
+
knob,
|
|
17
41
|
onchange,
|
|
18
42
|
class: className = ''
|
|
19
43
|
}: Props = $props();
|
|
@@ -29,9 +53,102 @@
|
|
|
29
53
|
checked = input.checked;
|
|
30
54
|
onchange?.(checked);
|
|
31
55
|
}
|
|
56
|
+
|
|
57
|
+
const look = $derived(toggleAppearance(appearance));
|
|
58
|
+
const knobLook = $derived(toggleKnob(knob, look));
|
|
59
|
+
|
|
60
|
+
// The glass knob's press and drag. Null while no pointer is down. The
|
|
61
|
+
// direction and travel are read once per press.
|
|
62
|
+
let press = $state<{ x: number; startedOn: boolean; pointerId: number; rtl: boolean; travel: number } | null>(
|
|
63
|
+
null
|
|
64
|
+
);
|
|
65
|
+
let dragOffset = $state<number | null>(null);
|
|
66
|
+
// The click that ends a drag must not flip the switch a second time. That
|
|
67
|
+
// click comes in the same task as the pointerup, so the flag only lasts until
|
|
68
|
+
// the next task: a drag let go off the label sends no click, and a later
|
|
69
|
+
// Space press must still work.
|
|
70
|
+
let swallowClick = false;
|
|
71
|
+
let swallowTimer: ReturnType<typeof setTimeout> | undefined;
|
|
72
|
+
|
|
73
|
+
function stopSwallowing() {
|
|
74
|
+
clearTimeout(swallowTimer);
|
|
75
|
+
swallowTimer = undefined;
|
|
76
|
+
swallowClick = false;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function handlePointerDown(event: PointerEvent) {
|
|
80
|
+
if (disabled || !event.isPrimary || event.button !== 0) return;
|
|
81
|
+
const rtl = getComputedStyle(event.currentTarget as Element).direction === 'rtl';
|
|
82
|
+
press = { x: event.clientX, startedOn: checked, pointerId: event.pointerId, rtl, travel: knobTravel(look) };
|
|
83
|
+
dragOffset = null;
|
|
84
|
+
stopSwallowing();
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
function handlePointerMove(event: PointerEvent) {
|
|
88
|
+
if (!press || !isPressPointer(press.pointerId, event)) return;
|
|
89
|
+
const dx = event.clientX - press.x;
|
|
90
|
+
if (dragOffset === null && !isKnobDrag(dx)) return;
|
|
91
|
+
dragOffset = knobOffset(press.startedOn, towardOn(dx, press.rtl), press.travel);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function handlePointerUp(event: PointerEvent) {
|
|
95
|
+
if (!press || !isPressPointer(press.pointerId, event)) return;
|
|
96
|
+
if (dragOffset !== null) {
|
|
97
|
+
swallowClick = true;
|
|
98
|
+
clearTimeout(swallowTimer);
|
|
99
|
+
swallowTimer = setTimeout(stopSwallowing, 0);
|
|
100
|
+
const next = isOnAtRelease(dragOffset, press.travel);
|
|
101
|
+
if (next !== checked) {
|
|
102
|
+
checked = next;
|
|
103
|
+
onchange?.(checked);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
press = null;
|
|
107
|
+
dragOffset = null;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function handlePointerCancel(event: PointerEvent) {
|
|
111
|
+
if (!press || !isPressPointer(press.pointerId, event)) return;
|
|
112
|
+
press = null;
|
|
113
|
+
dragOffset = null;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function handleClick(event: MouseEvent) {
|
|
117
|
+
if (!swallowClick) return;
|
|
118
|
+
stopSwallowing();
|
|
119
|
+
event.preventDefault();
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** Wires the press and drag of the glass knob. A solid knob gets no listeners. */
|
|
123
|
+
function glassKnob(label: HTMLLabelElement) {
|
|
124
|
+
label.addEventListener('pointerdown', handlePointerDown);
|
|
125
|
+
label.addEventListener('click', handleClick);
|
|
126
|
+
// The pointer can move and come up anywhere on the page once a drag is under way.
|
|
127
|
+
window.addEventListener('pointermove', handlePointerMove);
|
|
128
|
+
window.addEventListener('pointerup', handlePointerUp);
|
|
129
|
+
window.addEventListener('pointercancel', handlePointerCancel);
|
|
130
|
+
return () => {
|
|
131
|
+
label.removeEventListener('pointerdown', handlePointerDown);
|
|
132
|
+
label.removeEventListener('click', handleClick);
|
|
133
|
+
window.removeEventListener('pointermove', handlePointerMove);
|
|
134
|
+
window.removeEventListener('pointerup', handlePointerUp);
|
|
135
|
+
window.removeEventListener('pointercancel', handlePointerCancel);
|
|
136
|
+
press = null;
|
|
137
|
+
dragOffset = null;
|
|
138
|
+
stopSwallowing();
|
|
139
|
+
};
|
|
140
|
+
}
|
|
32
141
|
</script>
|
|
33
142
|
|
|
34
|
-
<label
|
|
143
|
+
<label
|
|
144
|
+
class="toggle {className}"
|
|
145
|
+
data-appearance={look}
|
|
146
|
+
class:is-disabled={disabled}
|
|
147
|
+
class:is-glass-knob={knobLook === 'glass'}
|
|
148
|
+
class:is-pressed={press !== null}
|
|
149
|
+
class:is-dragging={dragOffset !== null}
|
|
150
|
+
{@attach knobLook === 'glass' ? glassKnob : undefined}
|
|
151
|
+
>
|
|
35
152
|
<span class="toggle-label">{label}</span>
|
|
36
153
|
<input
|
|
37
154
|
type="checkbox"
|
|
@@ -44,22 +161,57 @@
|
|
|
44
161
|
{@attach (input: HTMLInputElement) => fitFocusRing(input, (node) => node.nextElementSibling)}
|
|
45
162
|
/>
|
|
46
163
|
<span class="toggle-track" aria-hidden="true">
|
|
47
|
-
<span
|
|
164
|
+
<span
|
|
165
|
+
class="toggle-thumb"
|
|
166
|
+
style={dragOffset === null ? undefined : `--_offset: ${dragOffset}px;`}
|
|
167
|
+
></span>
|
|
48
168
|
</span>
|
|
49
169
|
</label>
|
|
50
170
|
|
|
51
171
|
<style>
|
|
172
|
+
/* The glass switch is the iOS 26 UISwitch: a 63 by 28 track and a 37 by 24
|
|
173
|
+
capsule knob, 2px in. actions/toggleKnobLogic.ts holds the same numbers
|
|
174
|
+
for the drag. */
|
|
52
175
|
.toggle {
|
|
176
|
+
--_track-width: 63px;
|
|
177
|
+
--_track-height: 28px;
|
|
178
|
+
--_knob-width: 37px;
|
|
179
|
+
--_knob-height: 24px;
|
|
180
|
+
--_inset: 2px;
|
|
181
|
+
/* UIKit's pressed knob is 58 by 38.33, about 5px past each track edge. */
|
|
182
|
+
--_lens-scale: 1.57 1.6;
|
|
183
|
+
--_slide: var(--transition-spring);
|
|
184
|
+
--_knob-shadow: 0 3px 8px rgba(0, 0, 0, 0.15), 0 0.5px 1px rgba(0, 0, 0, 0.1);
|
|
185
|
+
--_track-off: var(--glass-track, rgba(235, 235, 245, 0.3));
|
|
53
186
|
display: inline-flex;
|
|
54
187
|
align-items: center;
|
|
55
188
|
justify-content: space-between;
|
|
56
189
|
gap: var(--spacing-sm);
|
|
57
190
|
font-family: var(--font-system);
|
|
58
191
|
font-size: 1rem;
|
|
59
|
-
|
|
192
|
+
/* A toggle row can sit on glass. --glass-fg flips the label with the
|
|
193
|
+
backdrop there, and is unset elsewhere, so the theme text stays. */
|
|
194
|
+
color: var(--glass-fg, var(--color-text));
|
|
60
195
|
cursor: pointer;
|
|
61
196
|
}
|
|
62
197
|
|
|
198
|
+
/* The off track is the iOS tertiary label grey of each theme. */
|
|
199
|
+
:global(:where(:root[data-theme='light'])) .toggle {
|
|
200
|
+
--_track-off: var(--glass-track, rgba(60, 60, 67, 0.3));
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/* The switch before iOS 26, with appearance="classic". */
|
|
204
|
+
.toggle[data-appearance='classic'] {
|
|
205
|
+
--_track-width: 51px;
|
|
206
|
+
--_track-height: 31px;
|
|
207
|
+
--_knob-width: 27px;
|
|
208
|
+
--_knob-height: 27px;
|
|
209
|
+
--_lens-scale: 1.4 1.2;
|
|
210
|
+
--_slide: var(--transition-fast);
|
|
211
|
+
--_knob-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
|
|
212
|
+
--_track-off: var(--glass-track, rgba(120, 120, 128, 0.32));
|
|
213
|
+
}
|
|
214
|
+
|
|
63
215
|
.toggle.is-disabled {
|
|
64
216
|
opacity: 0.5;
|
|
65
217
|
cursor: default;
|
|
@@ -69,8 +221,8 @@
|
|
|
69
221
|
below is the visible control. */
|
|
70
222
|
.toggle-input {
|
|
71
223
|
position: absolute;
|
|
72
|
-
width:
|
|
73
|
-
height:
|
|
224
|
+
width: var(--_track-width);
|
|
225
|
+
height: var(--_track-height);
|
|
74
226
|
margin: 0;
|
|
75
227
|
opacity: 0;
|
|
76
228
|
cursor: inherit;
|
|
@@ -79,23 +231,25 @@
|
|
|
79
231
|
.toggle-track {
|
|
80
232
|
position: relative;
|
|
81
233
|
flex-shrink: 0;
|
|
82
|
-
width:
|
|
83
|
-
height:
|
|
234
|
+
width: var(--_track-width);
|
|
235
|
+
height: var(--_track-height);
|
|
84
236
|
border-radius: var(--glass-radius-full);
|
|
85
|
-
background: var(--
|
|
237
|
+
background: var(--_track-off);
|
|
86
238
|
transition: background var(--transition-fast);
|
|
87
239
|
}
|
|
88
240
|
|
|
241
|
+
/* The knob is placed from the leading edge, so under dir="rtl" it starts at
|
|
242
|
+
the right and slides left to turn on, as on iOS. */
|
|
89
243
|
.toggle-thumb {
|
|
90
244
|
position: absolute;
|
|
91
|
-
top:
|
|
92
|
-
|
|
93
|
-
width:
|
|
94
|
-
height:
|
|
95
|
-
border-radius:
|
|
245
|
+
top: var(--_inset);
|
|
246
|
+
inset-inline-start: var(--_inset);
|
|
247
|
+
width: var(--_knob-width);
|
|
248
|
+
height: var(--_knob-height);
|
|
249
|
+
border-radius: var(--glass-radius-full);
|
|
96
250
|
background: #ffffff;
|
|
97
|
-
box-shadow:
|
|
98
|
-
transition:
|
|
251
|
+
box-shadow: var(--_knob-shadow);
|
|
252
|
+
transition: inset-inline-start var(--_slide);
|
|
99
253
|
}
|
|
100
254
|
|
|
101
255
|
.toggle-input:checked ~ .toggle-track {
|
|
@@ -103,7 +257,81 @@
|
|
|
103
257
|
}
|
|
104
258
|
|
|
105
259
|
.toggle-input:checked ~ .toggle-track .toggle-thumb {
|
|
106
|
-
|
|
260
|
+
inset-inline-start: calc(var(--_inset) + var(--_track-width) - var(--_knob-width) - 2 * var(--_inset));
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
/* A dragged knob sits where the pointer put it, on or off. */
|
|
264
|
+
.toggle.is-dragging .toggle-input ~ .toggle-track .toggle-thumb {
|
|
265
|
+
inset-inline-start: calc(var(--_inset) + var(--_offset));
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/* The glass knob. While pressed it widens into a clear glass lens, taller
|
|
269
|
+
than the track, as on iOS 26. scale is its own property, so it does not
|
|
270
|
+
fight the slide. */
|
|
271
|
+
/* A sideways drag on the glass knob belongs to the switch. Without this the
|
|
272
|
+
browser takes the touch for a pan and cancels the pointer. Vertical
|
|
273
|
+
scrolling still works. */
|
|
274
|
+
.toggle.is-glass-knob {
|
|
275
|
+
touch-action: pan-y;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
.toggle.is-glass-knob .toggle-thumb {
|
|
279
|
+
transition:
|
|
280
|
+
inset-inline-start var(--_slide),
|
|
281
|
+
scale var(--transition-fast),
|
|
282
|
+
background-color var(--transition-fast),
|
|
283
|
+
box-shadow var(--transition-fast);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
.toggle.is-glass-knob.is-pressed .toggle-thumb {
|
|
287
|
+
scale: var(--_lens-scale);
|
|
288
|
+
background: rgba(255, 255, 255, 0.16);
|
|
289
|
+
backdrop-filter: blur(1px) saturate(var(--glass-saturation, 1.8));
|
|
290
|
+
-webkit-backdrop-filter: blur(1px) saturate(var(--glass-saturation, 1.8));
|
|
291
|
+
box-shadow:
|
|
292
|
+
inset 0 0 0 0.5px rgba(255, 255, 255, 0.7),
|
|
293
|
+
inset 0 1px 3px rgba(255, 255, 255, 0.6),
|
|
294
|
+
inset 0 -1px 3px rgba(0, 0, 0, 0.12),
|
|
295
|
+
0 4px 12px rgba(0, 0, 0, 0.18);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/* A dragged knob follows the pointer with no lag. */
|
|
299
|
+
.toggle.is-glass-knob.is-dragging .toggle-thumb {
|
|
300
|
+
transition:
|
|
301
|
+
scale var(--transition-fast),
|
|
302
|
+
background-color var(--transition-fast),
|
|
303
|
+
box-shadow var(--transition-fast);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
/* More contrast: a darker off track, at least 3:1 against the page and the
|
|
307
|
+
knob in both themes. [data-appearance] lifts it over the classic grey. */
|
|
308
|
+
@media (prefers-contrast: more) {
|
|
309
|
+
.toggle[data-appearance] {
|
|
310
|
+
--_track-off: var(--glass-track, rgba(235, 235, 245, 0.5));
|
|
311
|
+
}
|
|
312
|
+
:global(:where(:root[data-theme='light'])) .toggle[data-appearance] {
|
|
313
|
+
--_track-off: var(--glass-track, rgba(60, 60, 67, 0.62));
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
:global(:where(:root[data-contrast='more'])) .toggle[data-appearance] {
|
|
317
|
+
--_track-off: var(--glass-track, rgba(235, 235, 245, 0.5));
|
|
318
|
+
}
|
|
319
|
+
:global(:where(:root[data-theme='light'][data-contrast='more'])) .toggle[data-appearance] {
|
|
320
|
+
--_track-off: var(--glass-track, rgba(60, 60, 67, 0.62));
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
/* Reduced transparency: the pressed knob widens but stays solid. */
|
|
324
|
+
@media (prefers-reduced-transparency: reduce) {
|
|
325
|
+
.toggle.is-glass-knob.is-pressed .toggle-thumb {
|
|
326
|
+
background: #ffffff;
|
|
327
|
+
backdrop-filter: none;
|
|
328
|
+
-webkit-backdrop-filter: none;
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
:global(:where([data-reduced-transparency='true'])) .toggle.is-glass-knob.is-pressed .toggle-thumb {
|
|
332
|
+
background: #ffffff;
|
|
333
|
+
backdrop-filter: none;
|
|
334
|
+
-webkit-backdrop-filter: none;
|
|
107
335
|
}
|
|
108
336
|
|
|
109
337
|
/* Shared focus ring. :where keeps it at zero specificity, so a page's own
|
|
@@ -125,4 +353,47 @@
|
|
|
125
353
|
.toggle-input:where(:focus-visible) ~ .toggle-track:global([data-focus-ring='inset']) {
|
|
126
354
|
outline-offset: calc(-2 * var(--glass-focus-ring-width, 2px));
|
|
127
355
|
}
|
|
356
|
+
|
|
357
|
+
/* Forced colours (Windows High Contrast) drop backgrounds and shadows, and the
|
|
358
|
+
native input is invisible, so draw the parts with system colours. The
|
|
359
|
+
border sits outside the track, so the knob keeps its place. */
|
|
360
|
+
@media (forced-colors: active) {
|
|
361
|
+
.toggle-track {
|
|
362
|
+
background: Canvas;
|
|
363
|
+
border: 1px solid CanvasText;
|
|
364
|
+
forced-color-adjust: none;
|
|
365
|
+
}
|
|
366
|
+
.toggle-input:checked ~ .toggle-track {
|
|
367
|
+
background: Highlight;
|
|
368
|
+
border-color: Highlight;
|
|
369
|
+
}
|
|
370
|
+
.toggle-thumb,
|
|
371
|
+
.toggle.is-glass-knob.is-pressed .toggle-thumb {
|
|
372
|
+
background: CanvasText;
|
|
373
|
+
box-shadow: none;
|
|
374
|
+
backdrop-filter: none;
|
|
375
|
+
-webkit-backdrop-filter: none;
|
|
376
|
+
forced-color-adjust: none;
|
|
377
|
+
}
|
|
378
|
+
.toggle-input:checked ~ .toggle-track .toggle-thumb {
|
|
379
|
+
background: HighlightText;
|
|
380
|
+
}
|
|
381
|
+
.toggle.is-disabled {
|
|
382
|
+
opacity: 1;
|
|
383
|
+
}
|
|
384
|
+
/* Heavier than the checked rules, so a disabled switch is grey on or off.
|
|
385
|
+
The knob's place still tells the two apart. */
|
|
386
|
+
.toggle.is-disabled .toggle-input ~ .toggle-track {
|
|
387
|
+
background: Canvas;
|
|
388
|
+
border-color: GrayText;
|
|
389
|
+
}
|
|
390
|
+
.toggle.is-disabled .toggle-input ~ .toggle-track .toggle-thumb {
|
|
391
|
+
background: GrayText;
|
|
392
|
+
}
|
|
393
|
+
/* The track opts out of forced colours, so its ring must use a system
|
|
394
|
+
colour itself. */
|
|
395
|
+
:where(.toggle-input:focus-visible ~ .toggle-track) {
|
|
396
|
+
outline-color: Highlight;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
128
399
|
</style>
|
|
@@ -3,6 +3,18 @@ interface Props {
|
|
|
3
3
|
checked?: boolean;
|
|
4
4
|
label: string;
|
|
5
5
|
disabled?: boolean;
|
|
6
|
+
/**
|
|
7
|
+
* The switch's look. `glass` (default) is the iOS 26 switch: a 63 by 28
|
|
8
|
+
* track with a capsule knob. `classic` is the 51 by 31 switch with a round
|
|
9
|
+
* knob from before iOS 26.
|
|
10
|
+
*/
|
|
11
|
+
appearance?: 'glass' | 'classic';
|
|
12
|
+
/**
|
|
13
|
+
* The knob's press. `glass` turns it into a clear glass lens while pressed
|
|
14
|
+
* and lets it be dragged across, as on iOS 26. `solid` keeps the white knob.
|
|
15
|
+
* Defaults to `glass`, or `solid` with `appearance="classic"`.
|
|
16
|
+
*/
|
|
17
|
+
knob?: 'solid' | 'glass';
|
|
6
18
|
onchange?: ((checked: boolean) => void) | undefined;
|
|
7
19
|
class?: string;
|
|
8
20
|
}
|
|
@@ -7,3 +7,7 @@ export { default as IconButton } from './IconButton.svelte';
|
|
|
7
7
|
export { default as Badge } from './Badge.svelte';
|
|
8
8
|
export { default as TabView } from './TabView.svelte';
|
|
9
9
|
export { default as Toggle } from './Toggle.svelte';
|
|
10
|
+
export { default as ProgressView } from './ProgressView.svelte';
|
|
11
|
+
export { default as SegmentedControl } from './SegmentedControl.svelte';
|
|
12
|
+
export type { Segment } from './Segment';
|
|
13
|
+
export { default as Slider } from './Slider.svelte';
|
|
@@ -7,3 +7,6 @@ export { default as IconButton } from './IconButton.svelte';
|
|
|
7
7
|
export { default as Badge } from './Badge.svelte';
|
|
8
8
|
export { default as TabView } from './TabView.svelte';
|
|
9
9
|
export { default as Toggle } from './Toggle.svelte';
|
|
10
|
+
export { default as ProgressView } from './ProgressView.svelte';
|
|
11
|
+
export { default as SegmentedControl } from './SegmentedControl.svelte';
|
|
12
|
+
export { default as Slider } from './Slider.svelte';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
|
-
import { Glass } from '../glass';
|
|
4
3
|
|
|
5
4
|
interface Props {
|
|
6
5
|
children: Snippet;
|
|
6
|
+
/** Mirrors SwiftUI's list styles. Every style but `plain` draws its rows on an opaque card. */
|
|
7
7
|
style?: 'plain' | 'inset' | 'grouped' | 'insetGrouped';
|
|
8
8
|
class?: string;
|
|
9
9
|
}
|
|
@@ -15,36 +15,60 @@
|
|
|
15
15
|
}: Props = $props();
|
|
16
16
|
</script>
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
{
|
|
23
|
-
|
|
24
|
-
{@render children()}
|
|
25
|
-
</Glass>
|
|
26
|
-
{/if}
|
|
18
|
+
<!-- Rows are content, so they sit on the opaque grouped card iOS uses
|
|
19
|
+
(secondarySystemGroupedBackground), not on Liquid Glass: the HIG keeps
|
|
20
|
+
glass for the controls and navigation layer above the content. -->
|
|
21
|
+
<div class="list list-{listStyle} {className}" class:list-card={listStyle !== 'plain'}>
|
|
22
|
+
{@render children()}
|
|
23
|
+
</div>
|
|
27
24
|
|
|
28
25
|
<style>
|
|
29
|
-
|
|
26
|
+
.list {
|
|
27
|
+
--_list-bg: var(--glass-list-background, #1c1c1e);
|
|
30
28
|
display: flex;
|
|
31
29
|
flex-direction: column;
|
|
32
30
|
width: 100%;
|
|
31
|
+
box-sizing: border-box;
|
|
33
32
|
}
|
|
34
33
|
|
|
35
|
-
:global(
|
|
34
|
+
:global(:where(:root[data-theme='light'])) .list {
|
|
35
|
+
--_list-bg: var(--glass-list-background, #ffffff);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/* --_row-bg tells a swipeable ListRow which colour to slide on. */
|
|
39
|
+
.list-card {
|
|
40
|
+
--_row-bg: var(--_list-bg);
|
|
41
|
+
background: var(--_list-bg);
|
|
42
|
+
overflow: hidden;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.list-plain {
|
|
46
|
+
--_row-bg: initial;
|
|
36
47
|
background: transparent;
|
|
37
48
|
}
|
|
38
49
|
|
|
39
|
-
|
|
40
|
-
|
|
50
|
+
/* Width auto, so the margins come out of the container, not on top of it. */
|
|
51
|
+
.list-inset {
|
|
52
|
+
width: auto;
|
|
53
|
+
margin-inline: var(--glass-list-inset, 16px);
|
|
54
|
+
border-radius: var(--glass-radius-sm);
|
|
41
55
|
}
|
|
42
56
|
|
|
43
|
-
|
|
57
|
+
.list-grouped {
|
|
58
|
+
margin-inline: 0;
|
|
44
59
|
border-radius: 0;
|
|
45
60
|
}
|
|
46
61
|
|
|
47
|
-
|
|
48
|
-
|
|
62
|
+
.list-insetGrouped {
|
|
63
|
+
width: auto;
|
|
64
|
+
margin-inline: var(--glass-list-inset, 16px);
|
|
65
|
+
border-radius: var(--glass-list-radius, 26px);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/* The card fill is dropped when colours are forced, so outline it. */
|
|
69
|
+
@media (forced-colors: active) {
|
|
70
|
+
.list-card {
|
|
71
|
+
border: 1px solid CanvasText;
|
|
72
|
+
}
|
|
49
73
|
}
|
|
50
74
|
</style>
|