glasslikeui 1.6.0 → 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>;
@@ -184,11 +184,13 @@
184
184
  isolation: isolate;
185
185
  }
186
186
 
187
+ /* Both layers sit at negative z-index inside the isolated button: behind the
188
+ label, which is unpositioned and would otherwise be painted over. */
187
189
  .button.is-glass::before {
188
190
  content: '';
189
191
  position: absolute;
190
192
  inset: 0;
191
- z-index: 0;
193
+ z-index: -1;
192
194
  border-radius: inherit;
193
195
  background: rgba(255, 255, 255, var(--btn-glass-opacity));
194
196
  backdrop-filter: blur(var(--btn-glass-blur)) saturate(var(--btn-glass-saturation));
@@ -200,7 +202,7 @@
200
202
  content: '';
201
203
  position: absolute;
202
204
  inset: 0;
203
- z-index: 1;
205
+ z-index: -1;
204
206
  border-radius: inherit;
205
207
  pointer-events: none;
206
208
  border: var(--glass-border-width) solid var(--glass-border);
@@ -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
  }))}
@@ -158,7 +160,9 @@
158
160
  background: var(--glass-active-subtle);
159
161
  }
160
162
 
161
- :global(.row-content) {
163
+ /* Scoped under .list-row so it outranks HStack's own padding reset
164
+ (.hstack.svelte-x) instead of depending on stylesheet order. */
165
+ .list-row :global(.row-content) {
162
166
  padding: var(--spacing-sm) var(--spacing-md);
163
167
  min-height: 44px;
164
168
  }
@@ -199,7 +203,9 @@
199
203
  color: var(--color-text-tertiary);
200
204
  }
201
205
 
202
- /* 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. */
203
209
  .swipe-row {
204
210
  position: relative;
205
211
  overflow: hidden;
@@ -211,6 +217,9 @@
211
217
  bottom: 0;
212
218
  display: flex;
213
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);
214
223
  }
215
224
 
216
225
  .swipe-actions[data-swipe-edge='trailing'] {
@@ -221,6 +230,17 @@
221
230
  left: 0;
222
231
  }
223
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
+
224
244
  .swipe-content {
225
245
  position: relative;
226
246
  background: var(--color-bg, transparent);
@@ -228,12 +248,15 @@
228
248
  touch-action: pan-y;
229
249
  }
230
250
 
231
- /* Settled positions animate; the drag itself tracks the finger.
232
- data-swipe-state is written by the action, so the compiler cannot see it
233
- in the markup -- :global keeps these rules from being pruned away. */
234
- .swipe-content:global([data-swipe-state='closed']),
235
- .swipe-content:global([data-swipe-state='open']),
236
- .swipe-content:global([data-swipe-state='fullSwipe']) {
237
- 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);
238
261
  }
239
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.0",
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",