glasslikeui 1.5.0 → 1.6.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.
Files changed (37) hide show
  1. package/README.md +53 -2
  2. package/dist/actions/deviceMotion.js +2 -3
  3. package/dist/actions/dragSnap.d.ts +31 -1
  4. package/dist/actions/dragSnap.js +68 -50
  5. package/dist/actions/index.d.ts +2 -0
  6. package/dist/actions/index.js +2 -0
  7. package/dist/actions/refreshable.d.ts +36 -0
  8. package/dist/actions/refreshable.js +157 -0
  9. package/dist/actions/swipeActions.d.ts +61 -0
  10. package/dist/actions/swipeActions.js +201 -0
  11. package/dist/components/glass/Glass.svelte +28 -6
  12. package/dist/components/glass/Glass.svelte.d.ts +3 -0
  13. package/dist/components/glass/Sheet.svelte +3 -0
  14. package/dist/components/interactive/Button.svelte +81 -1
  15. package/dist/components/interactive/Button.svelte.d.ts +2 -1
  16. package/dist/components/interactive/Toggle.svelte +110 -0
  17. package/dist/components/interactive/Toggle.svelte.d.ts +11 -0
  18. package/dist/components/interactive/index.d.ts +1 -0
  19. package/dist/components/interactive/index.js +1 -0
  20. package/dist/components/layout/ScrollView.svelte +83 -15
  21. package/dist/components/layout/ScrollView.svelte.d.ts +3 -0
  22. package/dist/components/layout/ZStack.svelte +3 -1
  23. package/dist/components/list/ListRow.svelte +135 -77
  24. package/dist/components/list/ListRow.svelte.d.ts +6 -0
  25. package/dist/components/typography/Label.svelte +82 -0
  26. package/dist/components/typography/Label.svelte.d.ts +11 -0
  27. package/dist/components/typography/index.d.ts +1 -0
  28. package/dist/components/typography/index.js +1 -0
  29. package/dist/constants/index.d.ts +2 -0
  30. package/dist/constants/index.js +2 -0
  31. package/dist/constants/label.d.ts +15 -0
  32. package/dist/constants/label.js +14 -0
  33. package/dist/constants/shapes.d.ts +18 -0
  34. package/dist/constants/shapes.js +26 -0
  35. package/dist/constants/variants.d.ts +28 -0
  36. package/dist/constants/variants.js +26 -0
  37. package/package.json +6 -2
@@ -0,0 +1,201 @@
1
+ /**
2
+ * Svelte action: swipe a row aside to reveal actions, mirroring SwiftUI's
3
+ * `.swipeActions(edge:allowsFullSwipe:)`.
4
+ *
5
+ * The node is translated by the `--swipe-x` custom property and tagged with
6
+ * `data-swipe-state`; the action strip itself is the caller's markup.
7
+ *
8
+ * Usage:
9
+ * <div use:swipeActions={{
10
+ * edge: 'trailing',
11
+ * actionsWidth: 160,
12
+ * allowsFullSwipe: true,
13
+ * onFullSwipe: () => remove(item)
14
+ * }}>...</div>
15
+ */
16
+ var __assign = (this && this.__assign) || function () {
17
+ __assign = Object.assign || function(t) {
18
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
19
+ s = arguments[i];
20
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
21
+ t[p] = s[p];
22
+ }
23
+ return t;
24
+ };
25
+ return __assign.apply(this, arguments);
26
+ };
27
+ // The velocity helpers are axis-agnostic -- `y` is simply "position along the
28
+ // drag axis", so the x-axis gesture reuses them rather than cloning them.
29
+ import { computeVelocity, pushSample } from './dragSnap';
30
+ /** Fraction of the row that must be crossed to arm a full swipe. */
31
+ export var DEFAULT_FULL_SWIPE_THRESHOLD = 0.5;
32
+ /** How much of an overshoot past the limit is tracked. */
33
+ export var DEFAULT_SWIPE_RUBBER_BAND = 0.35;
34
+ /** px/s past which a release counts as a flick. */
35
+ export var DEFAULT_SWIPE_VELOCITY = 500;
36
+ /** px of travel before the gesture is claimed from the scroller. */
37
+ export var SWIPE_SLOP = 4;
38
+ /** Direction the content travels to reveal this edge's actions. */
39
+ export function edgeSign(edge) {
40
+ // Unknown edges fall back to trailing, matching SwiftUI's default.
41
+ return edge === 'leading' ? 1 : -1;
42
+ }
43
+ /**
44
+ * Constrain a raw pointer delta to the row's travel: one-to-one up to the
45
+ * limit, damped beyond it, and zero against the configured edge.
46
+ */
47
+ export function clampSwipeOffset(rawDx, geo) {
48
+ if (!Number.isFinite(rawDx))
49
+ return 0;
50
+ var sign = edgeSign(geo.edge);
51
+ var magnitude = rawDx * sign;
52
+ // Negative magnitude means the drag opposes this edge.
53
+ if (magnitude <= 0)
54
+ return 0;
55
+ if (geo.actionsWidth <= 0)
56
+ return 0;
57
+ // A full swipe may travel the whole row; otherwise the strip is the limit.
58
+ // rowWidth 0 means unmeasured, so it cannot raise the limit.
59
+ var limit = geo.allowsFullSwipe && geo.rowWidth > 0
60
+ ? Math.max(geo.actionsWidth, geo.rowWidth)
61
+ : geo.actionsWidth;
62
+ var travel = magnitude <= limit ? magnitude : limit + (magnitude - limit) * DEFAULT_SWIPE_RUBBER_BAND;
63
+ return travel * sign;
64
+ }
65
+ /** Where the row settles once the pointer is released. */
66
+ export function resolveSwipeState(offset, velocity, geo) {
67
+ if (geo.actionsWidth <= 0)
68
+ return 'closed';
69
+ var sign = edgeSign(geo.edge);
70
+ var magnitude = offset * sign;
71
+ if (magnitude <= 0)
72
+ return 'closed';
73
+ var flick = Number.isFinite(velocity) && Math.abs(velocity) > DEFAULT_SWIPE_VELOCITY;
74
+ var flickingOpen = flick && Math.sign(velocity) === sign;
75
+ // A flick back cancels a pending full swipe: dragging past the trigger and
76
+ // pulling away is a cancel, not a confirmation.
77
+ if (geo.allowsFullSwipe &&
78
+ geo.rowWidth > 0 &&
79
+ !(flick && !flickingOpen) &&
80
+ magnitude >= geo.rowWidth * DEFAULT_FULL_SWIPE_THRESHOLD) {
81
+ return 'fullSwipe';
82
+ }
83
+ if (flick)
84
+ return flickingOpen ? 'open' : 'closed';
85
+ return magnitude >= geo.actionsWidth / 2 ? 'open' : 'closed';
86
+ }
87
+ /** The resting offset for a settled state. */
88
+ export function offsetForState(state, geo) {
89
+ var sign = edgeSign(geo.edge);
90
+ if (state === 'open')
91
+ return geo.actionsWidth * sign;
92
+ if (state === 'fullSwipe')
93
+ return geo.rowWidth * sign;
94
+ return 0;
95
+ }
96
+ function measureWidth(el) {
97
+ return el ? el.getBoundingClientRect().width : 0;
98
+ }
99
+ export function swipeActions(node, initialOptions) {
100
+ var options = __assign({}, initialOptions);
101
+ var state = 'closed';
102
+ var pointerId = null;
103
+ var startX = 0;
104
+ var startY = 0;
105
+ var claimed = false;
106
+ var abandoned = false;
107
+ var samples = [];
108
+ function geometry() {
109
+ var _a, _b, _c, _d;
110
+ return {
111
+ edge: (_a = options.edge) !== null && _a !== void 0 ? _a : 'trailing',
112
+ actionsWidth: (_b = options.actionsWidth) !== null && _b !== void 0 ? _b : measureWidth(options.actionsElement),
113
+ rowWidth: (_c = options.rowWidth) !== null && _c !== void 0 ? _c : node.getBoundingClientRect().width,
114
+ allowsFullSwipe: (_d = options.allowsFullSwipe) !== null && _d !== void 0 ? _d : false
115
+ };
116
+ }
117
+ function applyOffset(offset) {
118
+ node.style.setProperty('--swipe-x', "".concat(offset, "px"));
119
+ }
120
+ function settle(next) {
121
+ state = next;
122
+ node.setAttribute('data-swipe-state', next);
123
+ applyOffset(offsetForState(next, geometry()));
124
+ }
125
+ function onPointerDown(event) {
126
+ if (options.disabled)
127
+ return;
128
+ if (event.button !== undefined && event.button !== 0)
129
+ return;
130
+ pointerId = event.pointerId;
131
+ startX = event.clientX;
132
+ startY = event.clientY;
133
+ claimed = false;
134
+ abandoned = false;
135
+ samples = [{ y: event.clientX, t: performance.now() }];
136
+ }
137
+ function onPointerMove(event) {
138
+ if (pointerId === null || event.pointerId !== pointerId || abandoned)
139
+ return;
140
+ var dx = event.clientX - startX;
141
+ var dy = event.clientY - startY;
142
+ if (!claimed) {
143
+ // Let a vertical drag belong to the scroller.
144
+ if (Math.abs(dy) > Math.abs(dx)) {
145
+ abandoned = true;
146
+ return;
147
+ }
148
+ if (Math.abs(dx) < SWIPE_SLOP)
149
+ return;
150
+ claimed = true;
151
+ }
152
+ var resting = offsetForState(state, geometry());
153
+ applyOffset(clampSwipeOffset(resting + dx, geometry()));
154
+ samples = pushSample(samples, { y: event.clientX, t: performance.now() });
155
+ if (event.cancelable)
156
+ event.preventDefault();
157
+ }
158
+ function onPointerUp(event) {
159
+ var _a, _b;
160
+ if (pointerId === null || event.pointerId !== pointerId)
161
+ return;
162
+ var wasClaimed = claimed;
163
+ pointerId = null;
164
+ claimed = false;
165
+ if (!wasClaimed || abandoned)
166
+ return;
167
+ var geo = geometry();
168
+ var offset = clampSwipeOffset(offsetForState(state, geo) + (event.clientX - startX), geo);
169
+ var next = resolveSwipeState(offset, computeVelocity(samples), geo);
170
+ settle(next);
171
+ (_a = options.onStateChange) === null || _a === void 0 ? void 0 : _a.call(options, next);
172
+ if (next === 'fullSwipe')
173
+ (_b = options.onFullSwipe) === null || _b === void 0 ? void 0 : _b.call(options);
174
+ }
175
+ function onPointerCancel(event) {
176
+ if (pointerId === null || event.pointerId !== pointerId)
177
+ return;
178
+ pointerId = null;
179
+ claimed = false;
180
+ settle(state);
181
+ }
182
+ node.addEventListener('pointerdown', onPointerDown);
183
+ node.addEventListener('pointermove', onPointerMove);
184
+ node.addEventListener('pointerup', onPointerUp);
185
+ node.addEventListener('pointercancel', onPointerCancel);
186
+ settle('closed');
187
+ return {
188
+ update: function (newOptions) {
189
+ options = __assign({}, newOptions);
190
+ settle(state);
191
+ },
192
+ destroy: function () {
193
+ node.removeEventListener('pointerdown', onPointerDown);
194
+ node.removeEventListener('pointermove', onPointerMove);
195
+ node.removeEventListener('pointerup', onPointerUp);
196
+ node.removeEventListener('pointercancel', onPointerCancel);
197
+ node.style.removeProperty('--swipe-x');
198
+ node.removeAttribute('data-swipe-state');
199
+ }
200
+ };
201
+ }
@@ -8,7 +8,12 @@
8
8
  type GlassVariant,
9
9
  type GlassIntensity
10
10
  } from '../../constants/variants';
11
- import { CORNER_RADIUS, PADDING, type CornerRadius, type Padding } from '../../constants';
11
+ import { PADDING, type CornerRadius, type Padding } from '../../constants';
12
+ import {
13
+ glassShapeStyle,
14
+ DEFAULT_GLASS_SHAPE,
15
+ type GlassShape
16
+ } from '../../constants/shapes';
12
17
  import { fromAction } from 'svelte/attachments';
13
18
  import { deviceMotion } from '../../actions/deviceMotion';
14
19
 
@@ -18,6 +23,8 @@
18
23
  intensity?: GlassIntensity;
19
24
  tint?: string;
20
25
  cornerRadius?: CornerRadius;
26
+ /** Overrides cornerRadius entirely. Mirrors SwiftUI's glassEffect(in:). */
27
+ shape?: GlassShape;
21
28
  padding?: Padding;
22
29
  shadow?: boolean;
23
30
  interactive?: boolean;
@@ -32,6 +39,7 @@
32
39
  intensity = DEFAULT_INTENSITY,
33
40
  tint = '',
34
41
  cornerRadius = 'lg',
42
+ shape = DEFAULT_GLASS_SHAPE,
35
43
  padding = 'md',
36
44
  shadow = true,
37
45
  interactive = false,
@@ -40,23 +48,28 @@
40
48
  style: customStyle = ''
41
49
  }: Props = $props();
42
50
 
43
- const cfg = $derived(INTENSITY_CONFIG[intensity]);
44
- const vcfg = $derived(VARIANT_CONFIG[variant]);
51
+ // Fall back to the documented defaults: an unrecognised variant or intensity
52
+ // would otherwise read a property of undefined and crash the render.
53
+ const cfg = $derived(INTENSITY_CONFIG[intensity] ?? INTENSITY_CONFIG[DEFAULT_INTENSITY]);
54
+ const vcfg = $derived(VARIANT_CONFIG[variant] ?? VARIANT_CONFIG[DEFAULT_VARIANT]);
55
+ const shapeStyle = $derived(glassShapeStyle(shape, cornerRadius));
45
56
  </script>
46
57
 
47
58
  {#if motion}
48
59
  <div
49
60
  class="glass-surface {variant} {className}"
61
+ data-glass-shape={shape}
50
62
  class:has-lensing={cfg.displacementScale > 0}
51
63
  class:has-shadow={shadow}
52
64
  class:is-interactive={interactive}
53
- {@attach fromAction(deviceMotion)}
65
+ {@attach fromAction(deviceMotion, () => ({}))}
54
66
  style="
55
67
  --glass-blur: {cfg.blur}px;
56
68
  --glass-saturation: {cfg.saturation};
57
69
  --glass-displacement-scale: {cfg.displacementScale};
58
70
  --glass-opacity: {vcfg.opacityDark};
59
- --glass-radius: {CORNER_RADIUS[cornerRadius]};
71
+ --glass-radius: {shapeStyle.radius};
72
+ {shapeStyle.aspectRatio ? `aspect-ratio: ${shapeStyle.aspectRatio};` : ''}
60
73
  {tint ? `--glass-surface-bg: ${tint};` : ''}
61
74
  padding: {PADDING[padding]};
62
75
  {customStyle}
@@ -69,6 +82,7 @@
69
82
  {:else}
70
83
  <div
71
84
  class="glass-surface {variant} {className}"
85
+ data-glass-shape={shape}
72
86
  class:has-lensing={cfg.displacementScale > 0}
73
87
  class:has-shadow={shadow}
74
88
  class:is-interactive={interactive}
@@ -77,7 +91,8 @@
77
91
  --glass-saturation: {cfg.saturation};
78
92
  --glass-displacement-scale: {cfg.displacementScale};
79
93
  --glass-opacity: {vcfg.opacityDark};
80
- --glass-radius: {CORNER_RADIUS[cornerRadius]};
94
+ --glass-radius: {shapeStyle.radius};
95
+ {shapeStyle.aspectRatio ? `aspect-ratio: ${shapeStyle.aspectRatio};` : ''}
81
96
  {tint ? `--glass-surface-bg: ${tint};` : ''}
82
97
  padding: {PADDING[padding]};
83
98
  {customStyle}
@@ -136,6 +151,13 @@
136
151
  mix-blend-mode: overlay;
137
152
  }
138
153
 
154
+ /* A circular surface centres its content; a square box would not. */
155
+ .glass-surface[data-glass-shape='circle'] .glass-content {
156
+ display: flex;
157
+ align-items: center;
158
+ justify-content: center;
159
+ }
160
+
139
161
  .glass-content {
140
162
  position: relative;
141
163
  z-index: 2;
@@ -1,12 +1,15 @@
1
1
  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
+ import { type GlassShape } from '../../constants/shapes';
4
5
  interface Props {
5
6
  children: Snippet;
6
7
  variant?: GlassVariant;
7
8
  intensity?: GlassIntensity;
8
9
  tint?: string;
9
10
  cornerRadius?: CornerRadius;
11
+ /** Overrides cornerRadius entirely. Mirrors SwiftUI's glassEffect(in:). */
12
+ shape?: GlassShape;
10
13
  padding?: Padding;
11
14
  shadow?: boolean;
12
15
  interactive?: boolean;
@@ -51,6 +51,9 @@
51
51
  }
52
52
 
53
53
  function handleKeydown(e: KeyboardEvent) {
54
+ // The window listener is always attached, so a closed sheet would
55
+ // otherwise fire onClose - and clear body overflow - on every Escape.
56
+ if (!isOpen) return;
54
57
  if (e.key === 'Escape') {
55
58
  close();
56
59
  }
@@ -1,9 +1,10 @@
1
1
  <script lang="ts">
2
2
  import type { Snippet } from 'svelte';
3
+ import { glassButtonVars, type ButtonVariant } from '../../constants/variants';
3
4
 
4
5
  interface Props {
5
6
  children: Snippet;
6
- variant?: 'filled' | 'outlined' | 'plain' | 'tinted' | 'destructive';
7
+ variant?: ButtonVariant;
7
8
  size?: 'sm' | 'md' | 'lg';
8
9
  fullWidth?: boolean;
9
10
  disabled?: boolean;
@@ -38,6 +39,16 @@
38
39
  };
39
40
 
40
41
  const styles = $derived(sizeStyles[size]);
42
+
43
+ // null for the solid variants, so they emit no backdrop-filter layer.
44
+ const glass = $derived(glassButtonVars(variant));
45
+ const glassStyle = $derived(
46
+ glass
47
+ ? `--btn-glass-blur: ${glass.blur}px;
48
+ --btn-glass-saturation: ${glass.saturation};
49
+ --btn-glass-opacity: ${glass.opacity};`
50
+ : ''
51
+ );
41
52
  </script>
42
53
 
43
54
  {#if href}
@@ -48,10 +59,13 @@
48
59
  class="button variant-{variant} size-{size} {className}"
49
60
  class:full-width={fullWidth}
50
61
  class:disabled
62
+ class:is-glass={!!glass}
63
+ class:is-tinted={glass?.tinted}
51
64
  onclick={onclick}
52
65
  style="
53
66
  --btn-padding: {styles.padding};
54
67
  --btn-font-size: {styles.fontSize};
68
+ {glassStyle}
55
69
  "
56
70
  >
57
71
  {@render children()}
@@ -60,12 +74,15 @@
60
74
  <button
61
75
  class="button variant-{variant} size-{size} {className}"
62
76
  class:full-width={fullWidth}
77
+ class:is-glass={!!glass}
78
+ class:is-tinted={glass?.tinted}
63
79
  {disabled}
64
80
  {onclick}
65
81
  {type}
66
82
  style="
67
83
  --btn-padding: {styles.padding};
68
84
  --btn-font-size: {styles.fontSize};
85
+ {glassStyle}
69
86
  "
70
87
  >
71
88
  {@render children()}
@@ -160,6 +177,69 @@
160
177
  background: var(--color-accent-10);
161
178
  }
162
179
 
180
+ /* Glass variants (SwiftUI .glass / .glassProminent) */
181
+ .button.is-glass {
182
+ background: transparent;
183
+ color: var(--color-text);
184
+ isolation: isolate;
185
+ }
186
+
187
+ .button.is-glass::before {
188
+ content: '';
189
+ position: absolute;
190
+ inset: 0;
191
+ z-index: 0;
192
+ border-radius: inherit;
193
+ background: rgba(255, 255, 255, var(--btn-glass-opacity));
194
+ backdrop-filter: blur(var(--btn-glass-blur)) saturate(var(--btn-glass-saturation));
195
+ -webkit-backdrop-filter: blur(var(--btn-glass-blur)) saturate(var(--btn-glass-saturation));
196
+ pointer-events: none;
197
+ }
198
+
199
+ .button.is-glass::after {
200
+ content: '';
201
+ position: absolute;
202
+ inset: 0;
203
+ z-index: 1;
204
+ border-radius: inherit;
205
+ pointer-events: none;
206
+ border: var(--glass-border-width) solid var(--glass-border);
207
+ box-shadow: inset 0 1px 0 0 var(--glass-highlight);
208
+ }
209
+
210
+ .button.is-glass > :global(*) {
211
+ position: relative;
212
+ z-index: 2;
213
+ }
214
+
215
+ .button.is-glass:hover::before {
216
+ background: rgba(255, 255, 255, calc(var(--btn-glass-opacity) * 1.35));
217
+ }
218
+
219
+ .button.is-glass:active::before {
220
+ background: rgba(255, 255, 255, calc(var(--btn-glass-opacity) * 0.8));
221
+ }
222
+
223
+ .button.is-glass.is-tinted {
224
+ color: var(--color-accent);
225
+ }
226
+
227
+ .button.is-glass.is-tinted::before {
228
+ background: color-mix(
229
+ in srgb,
230
+ var(--color-accent) calc(var(--btn-glass-opacity) * 100%),
231
+ transparent
232
+ );
233
+ }
234
+
235
+ .button.is-glass.is-tinted:hover::before {
236
+ background: color-mix(
237
+ in srgb,
238
+ var(--color-accent) calc(var(--btn-glass-opacity) * 135%),
239
+ transparent
240
+ );
241
+ }
242
+
163
243
  /* Destructive variant */
164
244
  .button.variant-destructive {
165
245
  background: var(--color-danger);
@@ -1,7 +1,8 @@
1
1
  import type { Snippet } from 'svelte';
2
+ import { type ButtonVariant } from '../../constants/variants';
2
3
  interface Props {
3
4
  children: Snippet;
4
- variant?: 'filled' | 'outlined' | 'plain' | 'tinted' | 'destructive';
5
+ variant?: ButtonVariant;
5
6
  size?: 'sm' | 'md' | 'lg';
6
7
  fullWidth?: boolean;
7
8
  disabled?: boolean;
@@ -0,0 +1,110 @@
1
+ <script lang="ts">
2
+ interface Props {
3
+ /** Two-way bound on/off state. */
4
+ checked?: boolean;
5
+ label: string;
6
+ disabled?: boolean;
7
+ onchange?: ((checked: boolean) => void) | undefined;
8
+ class?: string;
9
+ }
10
+
11
+ let {
12
+ checked = $bindable(false),
13
+ label,
14
+ disabled = false,
15
+ onchange,
16
+ class: className = ''
17
+ }: Props = $props();
18
+
19
+ function handleChange(event: Event) {
20
+ const input = event.currentTarget as HTMLInputElement;
21
+ // A disabled control must never report a value the user could not set.
22
+ // Browsers suppress the event; a programmatic dispatch does not.
23
+ if (disabled) {
24
+ input.checked = checked;
25
+ return;
26
+ }
27
+ checked = input.checked;
28
+ onchange?.(checked);
29
+ }
30
+ </script>
31
+
32
+ <label class="toggle {className}" class:is-disabled={disabled}>
33
+ <span class="toggle-label">{label}</span>
34
+ <input
35
+ type="checkbox"
36
+ role="switch"
37
+ class="toggle-input"
38
+ checked={checked}
39
+ aria-checked={checked}
40
+ {disabled}
41
+ onchange={handleChange}
42
+ />
43
+ <span class="toggle-track" aria-hidden="true">
44
+ <span class="toggle-thumb"></span>
45
+ </span>
46
+ </label>
47
+
48
+ <style>
49
+ .toggle {
50
+ display: inline-flex;
51
+ align-items: center;
52
+ justify-content: space-between;
53
+ gap: var(--spacing-sm);
54
+ font-family: var(--font-system);
55
+ font-size: 1rem;
56
+ color: var(--color-text);
57
+ cursor: pointer;
58
+ }
59
+
60
+ .toggle.is-disabled {
61
+ opacity: 0.5;
62
+ cursor: default;
63
+ }
64
+
65
+ /* The native input stays in the layout for focus and hit-testing; the track
66
+ below is the visible control. */
67
+ .toggle-input {
68
+ position: absolute;
69
+ width: 51px;
70
+ height: 31px;
71
+ margin: 0;
72
+ opacity: 0;
73
+ cursor: inherit;
74
+ }
75
+
76
+ .toggle-track {
77
+ position: relative;
78
+ flex-shrink: 0;
79
+ width: 51px;
80
+ height: 31px;
81
+ border-radius: var(--glass-radius-full);
82
+ background: var(--glass-track, rgba(120, 120, 128, 0.32));
83
+ transition: background var(--transition-fast);
84
+ }
85
+
86
+ .toggle-thumb {
87
+ position: absolute;
88
+ top: 2px;
89
+ left: 2px;
90
+ width: 27px;
91
+ height: 27px;
92
+ border-radius: 50%;
93
+ background: #ffffff;
94
+ box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
95
+ transition: transform var(--transition-fast);
96
+ }
97
+
98
+ .toggle-input:checked ~ .toggle-track {
99
+ background: var(--color-accent);
100
+ }
101
+
102
+ .toggle-input:checked ~ .toggle-track .toggle-thumb {
103
+ transform: translateX(20px);
104
+ }
105
+
106
+ .toggle-input:focus-visible ~ .toggle-track {
107
+ outline: 2px solid var(--color-accent);
108
+ outline-offset: 2px;
109
+ }
110
+ </style>
@@ -0,0 +1,11 @@
1
+ interface Props {
2
+ /** Two-way bound on/off state. */
3
+ checked?: boolean;
4
+ label: string;
5
+ disabled?: boolean;
6
+ onchange?: ((checked: boolean) => void) | undefined;
7
+ class?: string;
8
+ }
9
+ declare const Toggle: import("svelte").Component<Props, {}, string>;
10
+ type Toggle = ReturnType<typeof Toggle>;
11
+ export default Toggle;
@@ -6,3 +6,4 @@ export { default as Button } from './Button.svelte';
6
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
+ export { default as Toggle } from './Toggle.svelte';
@@ -6,3 +6,4 @@ export { default as Button } from './Button.svelte';
6
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
+ export { default as Toggle } from './Toggle.svelte';