glasslikeui 1.6.1 → 1.7.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.
@@ -1,5 +1,5 @@
1
1
  import type { Snippet } from 'svelte';
2
- import { type SheetDetentName } from '../../actions/dragSnap';
2
+ import { type SheetDetentName } from '../../actions/dragSnapMath';
3
3
  interface Props {
4
4
  isOpen?: boolean;
5
5
  title?: string;
@@ -10,6 +10,12 @@ interface Props {
10
10
  initialDetent?: SheetDetentName;
11
11
  showHandle?: boolean;
12
12
  draggable?: boolean;
13
+ /**
14
+ * Turns off drag to dismiss, mirroring SwiftUI's interactiveDismissDisabled.
15
+ * Dragging below the smallest detent then rubber-bands and snaps back. The
16
+ * close button, Escape and the backdrop still close the sheet.
17
+ */
18
+ interactiveDismissDisabled?: boolean;
13
19
  class?: string;
14
20
  }
15
21
  declare const Sheet: import("svelte").Component<Props, {}, string>;
@@ -45,6 +45,7 @@
45
45
  const isInteractive = $derived(interactive || !!href || !!onclick);
46
46
 
47
47
  let actionsElement = $state<HTMLElement | null>(null);
48
+ let swipeRowElement = $state<HTMLElement | null>(null);
48
49
  </script>
49
50
 
50
51
  {#snippet rowInner()}
@@ -106,7 +107,7 @@
106
107
  {/snippet}
107
108
 
108
109
  {#if swipeActions}
109
- <div class="swipe-row">
110
+ <div class="swipe-row" bind:this={swipeRowElement}>
110
111
  <!-- Behind the row until revealed, so it stays out of the reading order. -->
111
112
  <div
112
113
  class="swipe-actions"
@@ -121,6 +122,7 @@
121
122
  {@attach fromAction(swipeGesture, () => ({
122
123
  edge: swipeEdge,
123
124
  actionsElement,
125
+ stateElement: swipeRowElement,
124
126
  allowsFullSwipe,
125
127
  onFullSwipe
126
128
  }))}
@@ -201,7 +203,9 @@
201
203
  color: var(--color-text-tertiary);
202
204
  }
203
205
 
204
- /* Swipe actions */
206
+ /* Swipe actions. The action writes --swipe-x, --swipe-reveal and
207
+ data-swipe-state onto .swipe-row, so the content and the strip read the
208
+ same numbers and cannot drift apart. */
205
209
  .swipe-row {
206
210
  position: relative;
207
211
  overflow: hidden;
@@ -213,6 +217,9 @@
213
217
  bottom: 0;
214
218
  display: flex;
215
219
  align-items: stretch;
220
+ /* Natural width, or the revealed distance when the row is dragged
221
+ further: the strip always reaches the content's edge. */
222
+ min-width: var(--swipe-reveal, 0px);
216
223
  }
217
224
 
218
225
  .swipe-actions[data-swipe-edge='trailing'] {
@@ -223,6 +230,17 @@
223
230
  left: 0;
224
231
  }
225
232
 
233
+ /* The edge-most action absorbs the extra width and keeps its label centred.
234
+ :where() has zero specificity, so a caller's own rules still win. */
235
+ :where(.swipe-actions[data-swipe-edge='trailing'] > :global(:last-child)),
236
+ :where(.swipe-actions[data-swipe-edge='leading'] > :global(:first-child)) {
237
+ flex: 1 0 auto;
238
+ display: flex;
239
+ align-items: center;
240
+ justify-content: center;
241
+ text-align: center;
242
+ }
243
+
226
244
  .swipe-content {
227
245
  position: relative;
228
246
  background: var(--color-bg, transparent);
@@ -230,12 +248,15 @@
230
248
  touch-action: pan-y;
231
249
  }
232
250
 
233
- /* Settled positions animate; the drag itself tracks the finger.
234
- data-swipe-state is written by the action, so the compiler cannot see it
235
- in the markup -- :global keeps these rules from being pruned away. */
236
- .swipe-content:global([data-swipe-state='closed']),
237
- .swipe-content:global([data-swipe-state='open']),
238
- .swipe-content:global([data-swipe-state='fullSwipe']) {
239
- transition: transform var(--transition-fast);
251
+ /* Settled positions animate in step: the content slides and the strip
252
+ shrinks over the same duration. The drag itself tracks the finger, so
253
+ both are left untransitioned while data-swipe-dragging is set. The
254
+ attributes are written by the action, so the compiler cannot see them in
255
+ the markup: :global keeps these rules from being pruned away. */
256
+ .swipe-row:global([data-swipe-state]):not(:global([data-swipe-dragging])) .swipe-content,
257
+ .swipe-row:global([data-swipe-state]):not(:global([data-swipe-dragging])) .swipe-actions {
258
+ transition:
259
+ transform var(--transition-fast),
260
+ min-width var(--transition-fast);
240
261
  }
241
262
  </style>
@@ -9,6 +9,13 @@ import { type CornerRadius } from './sizes';
9
9
  export declare const GLASS_SHAPES: readonly ["rect", "capsule", "circle"];
10
10
  export type GlassShape = (typeof GLASS_SHAPES)[number];
11
11
  export declare const DEFAULT_GLASS_SHAPE: GlassShape;
12
+ /**
13
+ * Elements that count as a lone text-level label. A `rect` Glass whose only
14
+ * child is one of these is centred like a capsule or circle, while a panel
15
+ * holding a div, a stack or several children keeps its normal flow. The CSS in
16
+ * Glass.svelte and lens.css spells this list out, and a test keeps them equal.
17
+ */
18
+ export declare const GLASS_LONE_LABEL_ELEMENTS: readonly ["span", "label", "strong", "b", "em", "small", "svg", "img"];
12
19
  export interface GlassShapeStyle {
13
20
  /** CSS border-radius value. */
14
21
  radius: string;
@@ -8,6 +8,22 @@
8
8
  import { CORNER_RADIUS } from './sizes';
9
9
  export var GLASS_SHAPES = ['rect', 'capsule', 'circle'];
10
10
  export var DEFAULT_GLASS_SHAPE = 'rect';
11
+ /**
12
+ * Elements that count as a lone text-level label. A `rect` Glass whose only
13
+ * child is one of these is centred like a capsule or circle, while a panel
14
+ * holding a div, a stack or several children keeps its normal flow. The CSS in
15
+ * Glass.svelte and lens.css spells this list out, and a test keeps them equal.
16
+ */
17
+ export var GLASS_LONE_LABEL_ELEMENTS = [
18
+ 'span',
19
+ 'label',
20
+ 'strong',
21
+ 'b',
22
+ 'em',
23
+ 'small',
24
+ 'svg',
25
+ 'img'
26
+ ];
11
27
  /** Radius used when a caller passes a corner-radius key that is not a token. */
12
28
  var FALLBACK_RADIUS = CORNER_RADIUS.lg;
13
29
  function rectRadius(cornerRadius) {
@@ -46,6 +46,12 @@
46
46
 
47
47
  /* Sheet chrome */
48
48
  --glass-sheet-bg: rgba(28, 28, 30, 0.80);
49
+ --glass-backdrop-blur: 4px;
50
+
51
+ /* Sheet close button focus ring. The inner ring hugs the button and the
52
+ outer ring sits against the sheet. Override to rebrand. */
53
+ --sheet-focus-ring-inner: #ffffff;
54
+ --sheet-focus-ring-outer: #3b8eea;
49
55
 
50
56
  /* ========================================
51
57
  Accent system
@@ -124,6 +130,9 @@
124
130
 
125
131
  --glass-nav-bg: rgba(255, 255, 255, 0.85);
126
132
  --glass-sheet-bg: rgba(255, 255, 255, 0.88);
133
+
134
+ --sheet-focus-ring-inner: #000000;
135
+ --sheet-focus-ring-outer: #0071e3;
127
136
  }
128
137
 
129
138
  /* ========================================
@@ -138,6 +147,13 @@
138
147
  --glass-blur: 0px;
139
148
  --glass-displacement-scale: 0;
140
149
  --glass-saturation: 1;
150
+ --glass-blur-nav: 0px;
151
+ --glass-backdrop-blur: 0px;
152
+ --glass-sheet-bg: rgba(28, 28, 30, 0.98);
153
+ }
154
+ /* Same specificity as the light theme block above and later, so it wins. */
155
+ :root[data-theme='light'] {
156
+ --glass-sheet-bg: rgba(255, 255, 255, 0.98);
141
157
  }
142
158
  }
143
159
  :root[data-reduced-transparency='true'] {
@@ -145,6 +161,13 @@
145
161
  --glass-blur: 0px;
146
162
  --glass-displacement-scale: 0;
147
163
  --glass-saturation: 1;
164
+ --glass-blur-nav: 0px;
165
+ --glass-backdrop-blur: 0px;
166
+ --glass-sheet-bg: rgba(28, 28, 30, 0.98);
167
+ }
168
+ /* One more attribute than the light theme block, so it beats it whatever the order. */
169
+ :root[data-reduced-transparency='true'][data-theme='light'] {
170
+ --glass-sheet-bg: rgba(255, 255, 255, 0.98);
148
171
  }
149
172
 
150
173
  @media (prefers-contrast: more) {
@@ -190,3 +213,11 @@
190
213
  --glass-blur-nav: 16px;
191
214
  }
192
215
  }
216
+
217
+ /* The small viewport block above comes later and has the same specificity as the
218
+ reduced transparency media block, so repeat the nav blur reset after it. */
219
+ @media (max-width: 768px) and (prefers-reduced-transparency: reduce) {
220
+ :root {
221
+ --glass-blur-nav: 0px;
222
+ }
223
+ }
@@ -55,6 +55,47 @@
55
55
  height: 100%;
56
56
  }
57
57
 
58
+ /* Control shapes centre their content on both axes. The surface does the
59
+ * centring rather than a percentage height on .glass-content: WebKit
60
+ * resolves that percentage against the aspect-ratio box without removing the
61
+ * padding, so a circle label sat one padding-width below centre. Kept in step
62
+ * with the scoped rules in Glass.svelte. */
63
+ :where(.glass-surface[data-glass-shape='capsule']),
64
+ :where(.glass-surface[data-glass-shape='circle']) {
65
+ display: flex;
66
+ align-items: center;
67
+ justify-content: center;
68
+ }
69
+
70
+ :where(.glass-surface[data-glass-shape='capsule']) > .glass-content,
71
+ :where(.glass-surface[data-glass-shape='circle']) > .glass-content {
72
+ height: auto;
73
+ min-width: 0;
74
+ max-width: 100%;
75
+ text-align: center;
76
+ }
77
+
78
+ :where(.glass-surface[data-glass-shape='circle']) > .glass-content {
79
+ display: flex;
80
+ align-items: center;
81
+ justify-content: center;
82
+ }
83
+
84
+ /* A surface holding one text-level child (GLASS_LONE_LABEL_ELEMENTS) centres
85
+ * it too. Panels, cards and stacks are untouched. */
86
+ :where(.glass-surface:has(> .glass-content > :where(span, label, strong, b, em, small, svg, img):only-child)) {
87
+ display: flex;
88
+ align-items: center;
89
+ justify-content: center;
90
+ }
91
+
92
+ :where(.glass-surface:has(> .glass-content > :where(span, label, strong, b, em, small, svg, img):only-child)) > .glass-content {
93
+ height: auto;
94
+ min-width: 0;
95
+ max-width: 100%;
96
+ text-align: center;
97
+ }
98
+
58
99
  .glass-content > :where(h1, h2, h3, h4, h5, h6, p, span, label, a, button) {
59
100
  font-family: var(--font-system);
60
101
  }
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "glasslikeui",
3
- "version": "1.6.1",
3
+ "version": "1.7.0",
4
4
  "description": "Svelte component library with frosted glass materials",
5
- "license": "GPL-3.0-or-later",
5
+ "license": "MPL-2.0",
6
6
  "type": "module",
7
7
  "svelte": "./dist/index.js",
8
8
  "types": "./dist/index.d.ts",