@glasshome/ui 1.18.0 → 1.19.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 (53) hide show
  1. package/SPEC.md +82 -1
  2. package/dist/index.js +2 -2
  3. package/dist/lib/button-variants.d.ts +3 -0
  4. package/dist/lib/card-classes.d.ts +4 -4
  5. package/dist/lib/motion-classes.d.ts +1 -0
  6. package/dist/lib/overlay-classes.d.ts +4 -2
  7. package/dist/lib/spotlight-geometry.d.ts +22 -0
  8. package/dist/solid/button.d.ts +8 -3
  9. package/dist/solid/dock.d.ts +9 -0
  10. package/dist/solid/docked-panel.d.ts +11 -0
  11. package/dist/solid/index.d.ts +6 -2
  12. package/dist/solid/index.js +4387 -4022
  13. package/dist/solid/option-card.d.ts +1 -1
  14. package/dist/solid/preview-tile.d.ts +33 -0
  15. package/dist/solid/spotlight.d.ts +14 -0
  16. package/dist/solid/swatch-picker.d.ts +12 -0
  17. package/dist/solid/tabs.d.ts +4 -1
  18. package/dist/solid/widget-identity.d.ts +2 -0
  19. package/dist/tokens/index.d.ts +1 -0
  20. package/dist/tokens/index.js +336 -118
  21. package/dist/tokens/material.d.ts +40 -0
  22. package/dist/tokens/presets.d.ts +3 -0
  23. package/dist/tokens/theme-colors.d.ts +13 -3
  24. package/dist/tokens/theme-recipe.d.ts +8 -0
  25. package/dist/{utils-COITV1s9.js → utils-CV6G6fr8.js} +618 -615
  26. package/package.json +2 -2
  27. package/src/lib/button-variants.ts +4 -3
  28. package/src/lib/card-classes.ts +4 -3
  29. package/src/lib/motion-classes.ts +5 -0
  30. package/src/lib/overlay-classes.ts +10 -2
  31. package/src/lib/spotlight-geometry.ts +90 -0
  32. package/src/solid/button.tsx +17 -2
  33. package/src/solid/dock.tsx +67 -9
  34. package/src/solid/docked-panel.tsx +56 -0
  35. package/src/solid/hero-action.tsx +2 -2
  36. package/src/solid/index.ts +11 -2
  37. package/src/solid/option-card.tsx +25 -31
  38. package/src/solid/preview-tile.tsx +79 -0
  39. package/src/solid/radio-group.tsx +7 -2
  40. package/src/solid/section-card.tsx +4 -2
  41. package/src/solid/sliding-indicator.tsx +13 -12
  42. package/src/solid/spotlight.tsx +179 -0
  43. package/src/solid/swatch-picker.tsx +47 -0
  44. package/src/solid/tabs.tsx +20 -4
  45. package/src/solid/toggle-group.tsx +1 -4
  46. package/src/solid/widget-identity.tsx +3 -1
  47. package/src/styles/globals.css +166 -14
  48. package/src/styles/theme.css +13 -0
  49. package/src/tokens/index.ts +1 -0
  50. package/src/tokens/material.ts +116 -0
  51. package/src/tokens/presets.ts +195 -56
  52. package/src/tokens/theme-colors.ts +15 -3
  53. package/src/tokens/theme-recipe.ts +18 -4
@@ -83,6 +83,66 @@
83
83
  inherits: false;
84
84
  }
85
85
 
86
+ /* Tier 2, the material: inheriting, theme-written, multiplied into every
87
+ * surface's own knobs. A knob is a surface's identity; these scale all of them. */
88
+ @property --material-blur {
89
+ syntax: "<length>";
90
+ inherits: true;
91
+ initial-value: 24px;
92
+ }
93
+ @property --material-clarity {
94
+ syntax: "<percentage>";
95
+ inherits: true;
96
+ initial-value: 60%;
97
+ }
98
+ @property --material-depth {
99
+ syntax: "<number>";
100
+ inherits: true;
101
+ initial-value: 1;
102
+ }
103
+ @property --material-tint {
104
+ syntax: "<number>";
105
+ inherits: true;
106
+ initial-value: 1;
107
+ }
108
+ /* Preset terms, inert at their defaults: Paper and Neon raise the edge. */
109
+ @property --material-edge-width {
110
+ syntax: "<length>";
111
+ inherits: true;
112
+ initial-value: 1px;
113
+ }
114
+ /* 0..1, how far the edge colour moves toward the foreground ink. */
115
+ @property --material-edge-ink {
116
+ syntax: "<number>";
117
+ inherits: true;
118
+ initial-value: 0;
119
+ }
120
+ /* 0..1, how far the edge moves toward the surface's own hue (its tone, else
121
+ * the accent). */
122
+ @property --material-edge-accent {
123
+ syntax: "<number>";
124
+ inherits: true;
125
+ initial-value: 0;
126
+ }
127
+ /* An outer bloom in the surface's own hue. */
128
+ @property --material-glow {
129
+ syntax: "<length>";
130
+ inherits: true;
131
+ initial-value: 0px;
132
+ }
133
+ /* 0..1, how far the Ink line moves toward the foreground (Chalk 1). */
134
+ @property --material-ink-lift {
135
+ syntax: "<number>";
136
+ inherits: true;
137
+ initial-value: 0;
138
+ }
139
+ /* Registered so the Ink body's style query compares a computed number. */
140
+ @property --material-ink-level {
141
+ syntax: "<number>";
142
+ inherits: true;
143
+ initial-value: 0;
144
+ }
145
+
86
146
  /* --glass-base and --glass-edge need var() defaults, which @property forbids,
87
147
  * so they reset here instead. MUST stay in @layer base so [--glass-*] utilities
88
148
  * and inline style knobs still win. Rim shadows are declared on .glass (not
@@ -91,8 +151,9 @@
91
151
  /* biome-ignore-start lint/correctness/noMissingVarFunction: transition-property takes property names, and these are the registered knobs */
92
152
  --glass-transition:
93
153
  --glass-tone, --glass-wash, --glass-light, --glass-shade, --glass-rim, --glass-lift,
94
- --glass-glow, --glass-drop, --glass-text, color, background-color, border-color, box-shadow,
95
- opacity, transform, translate, scale, width, height;
154
+ --glass-glow, --glass-drop, --glass-text, --material-depth, --material-tint,
155
+ --material-edge-width, --material-edge-ink, --material-edge-accent, --material-glow, color,
156
+ background-color, border-color, box-shadow, opacity, transform, translate, scale, width, height;
96
157
  /* biome-ignore-end lint/correctness/noMissingVarFunction: see above */
97
158
  }
98
159
 
@@ -115,13 +176,13 @@
115
176
  --glass-base: var(--card);
116
177
  --glass-edge: color-mix(in srgb, var(--border) 60%, transparent);
117
178
  --glass-rim-raise:
118
- inset 0 1px 0 oklch(1 0 0 / calc(0.22 * var(--glass-rim))),
119
- inset 2px 2px 5px -3px oklch(1 0 0 / calc(0.5 * var(--glass-rim))),
120
- inset -2px -2px 4px -2px oklch(0 0 0 / calc(0.12 * var(--glass-rim)));
179
+ inset 0 1px 0 oklch(1 0 0 / calc(0.22 * var(--glass-rim) * var(--material-depth))),
180
+ inset 2px 2px 5px -3px oklch(1 0 0 / calc(0.5 * var(--glass-rim) * var(--material-depth))),
181
+ inset -2px -2px 4px -2px oklch(0 0 0 / calc(0.12 * var(--glass-rim) * var(--material-depth)));
121
182
  --glass-rim-sink:
122
- inset 0 2px 3px -1px oklch(0 0 0 / calc(0.28 * var(--glass-rim))),
123
- inset 2px 2px 5px -3px oklch(0 0 0 / calc(0.22 * var(--glass-rim))),
124
- inset 0 -1px 0 oklch(1 0 0 / calc(0.12 * var(--glass-rim)));
183
+ inset 0 2px 3px -1px oklch(0 0 0 / calc(0.28 * var(--glass-rim) * var(--material-depth))),
184
+ inset 2px 2px 5px -3px oklch(0 0 0 / calc(0.22 * var(--glass-rim) * var(--material-depth))),
185
+ inset 0 -1px 0 oklch(1 0 0 / calc(0.12 * var(--glass-rim) * var(--material-depth)));
125
186
  --glass-rim-shine: var(--glass-rim-raise);
126
187
  }
127
188
  :where(.glass-tint) {
@@ -161,7 +222,20 @@
161
222
  --glass-tone-2: var(--glass-tone);
162
223
  --glass-wash-2: calc(var(--glass-wash) / 3);
163
224
  --glass-wash-angle: 135deg;
164
- border: 1px solid var(--glass-edge);
225
+ --surface-wash: calc(var(--glass-wash) * var(--material-tint));
226
+ /* The surface's own hue, opaque: its tone when it has one, the accent otherwise
227
+ * (a transparent tone mixes to the accent at low alpha; the /1 restores it). */
228
+ --material-hue: oklch(from color-mix(in srgb, var(--glass-tone) 99%, var(--primary)) l c h / 1);
229
+ border: var(--material-edge-width) solid
230
+ color-mix(
231
+ in srgb,
232
+ var(--material-hue) calc(var(--material-edge-accent) * 100%),
233
+ color-mix(
234
+ in srgb,
235
+ var(--material-ink) calc(var(--material-edge-ink) * 100%),
236
+ var(--glass-edge)
237
+ )
238
+ );
165
239
  /* Base is a gradient layer (not background-color) so the frost slice can sit
166
240
  * BELOW it — background-color always paints under every image layer, which
167
241
  * would put the frost above the fill. Layer order top→bottom: grain, light,
@@ -170,21 +244,38 @@
170
244
  var(--glass-grain, none),
171
245
  radial-gradient(
172
246
  var(--glass-sheen, 120% 120%) at 22% 8%,
173
- oklch(1 0 0 / var(--glass-light)),
247
+ oklch(1 0 0 / calc(var(--glass-light) * var(--material-depth))),
248
+ transparent 58%
249
+ ),
250
+ radial-gradient(
251
+ 120% 120% at 82% 100%,
252
+ oklch(0 0 0 / calc(var(--glass-shade) * var(--material-depth))),
174
253
  transparent 58%
175
254
  ),
176
- radial-gradient(120% 120% at 82% 100%, oklch(0 0 0 / var(--glass-shade)), transparent 58%),
177
255
  linear-gradient(
178
256
  var(--glass-wash-angle),
179
- color-mix(in srgb, var(--glass-tone) var(--glass-wash), transparent),
180
- color-mix(in srgb, var(--glass-tone-2) var(--glass-wash-2), transparent)
257
+ color-mix(
258
+ in srgb,
259
+ var(--glass-tone) calc(var(--glass-wash) * var(--material-tint)),
260
+ transparent
261
+ ),
262
+ color-mix(
263
+ in srgb,
264
+ var(--glass-tone-2) calc(var(--glass-wash-2) * var(--material-tint)),
265
+ transparent
266
+ )
181
267
  ),
182
268
  linear-gradient(var(--glass-base), var(--glass-base)), var(--glass-frost, none);
269
+ /* Glow scales with --glass-lift, the knob that already says how big a surface
270
+ * floats: a card (0.45) takes the full bloom, a chip or button (0) about a third. */
271
+ --material-reach: calc(0.35 + var(--glass-lift) * 1.45);
183
272
  box-shadow:
184
273
  var(--glass-rim-shine, 0 0 #0000),
185
274
  inset 0 -2px 4px color-mix(in srgb, var(--glass-tone) var(--glass-glow), transparent),
186
275
  0 1px 3px color-mix(in srgb, var(--glass-tone) var(--glass-drop), transparent),
187
- 0 10px 30px -16px oklch(0 0 0 / var(--glass-lift));
276
+ 0 10px 30px -16px oklch(0 0 0 / calc(var(--glass-lift) * var(--material-depth))),
277
+ 0 0 calc(var(--material-glow) * var(--material-reach))
278
+ oklch(from var(--material-hue) l c h / 0.65);
188
279
  }
189
280
 
190
281
  /* Two-tone edge: border-color cannot gradient, so the border goes transparent
@@ -213,6 +304,67 @@
213
304
  pointer-events: none;
214
305
  }
215
306
 
307
+ /* Ink: a hand-drawn line over a hand-laid fill that strays over and under it.
308
+ * Uneven radii make each corner bow differently; the fill takes its own radii and
309
+ * a nudge, so it misses the line. Both are pseudos because a negative-z child
310
+ * paints above its parent's own background and border; contain: layout anchors
311
+ * them and makes the stacking context without repositioning the surface. */
312
+ @container not style(--material-ink-level: 0) {
313
+ :where(.glass) {
314
+ --ink-r: var(--radius);
315
+ --ink-line: color-mix(
316
+ in oklch,
317
+ var(--foreground) calc(var(--material-ink-lift) * 100%),
318
+ var(--material-ink)
319
+ );
320
+ contain: layout;
321
+ background: none;
322
+ border-color: transparent;
323
+ box-shadow: none;
324
+ border-radius:
325
+ calc(var(--ink-r) * 1.7) calc(var(--ink-r) * 0.5) calc(var(--ink-r) * 1.35)
326
+ calc(var(--ink-r) * 0.65) / calc(var(--ink-r) * 0.55) calc(var(--ink-r) * 1.45)
327
+ calc(var(--ink-r) * 0.7) calc(var(--ink-r) * 1.6);
328
+ }
329
+ :where(.glass)::before,
330
+ :where(.glass)::after {
331
+ content: "";
332
+ position: absolute;
333
+ z-index: -1;
334
+ pointer-events: none;
335
+ }
336
+ :where(.glass)::before {
337
+ inset: -5px -3px -2px -6px;
338
+ padding: 0;
339
+ mask: none;
340
+ translate: 3px 2px;
341
+ border-radius:
342
+ calc(var(--ink-r) * 0.6) calc(var(--ink-r) * 1.6) calc(var(--ink-r) * 0.75)
343
+ calc(var(--ink-r) * 1.5) / calc(var(--ink-r) * 1.4) calc(var(--ink-r) * 0.6)
344
+ calc(var(--ink-r) * 1.5) calc(var(--ink-r) * 0.65);
345
+ background:
346
+ linear-gradient(color-mix(in srgb, var(--surface-tone) var(--surface-wash), transparent) 0 0),
347
+ linear-gradient(var(--glass-base) 0 0);
348
+ }
349
+ /* Above every widget layer (the SDK stacks to 30): full-bleed media would bury the line. */
350
+ :where(.glass)::after {
351
+ z-index: 40;
352
+ inset: 0;
353
+ border: 3px solid var(--ink-line);
354
+ border-radius: inherit;
355
+ rotate: -0.2deg;
356
+ /* Chalk: grain tiled at 1:1, so no browser stretches it; no-clip keeps the passes. */
357
+ mask:
358
+ url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='c' x='0' y='0' width='100%' height='100%'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' seed='5' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -3.4 2.55'/></filter><rect width='120' height='120' filter='url(%23c)'/></svg>")
359
+ 0 0 / 120px 120px repeat;
360
+ mask-clip: no-clip;
361
+ opacity: var(--material-ink-level);
362
+ box-shadow:
363
+ -2px 2px 0 -1.2px color-mix(in srgb, var(--ink-line) 55%, transparent),
364
+ 2px -1.5px 0 -1.4px color-mix(in srgb, var(--ink-line) 45%, transparent);
365
+ }
366
+ }
367
+
216
368
  /* A mode's rim: the masked ring of .glass-edge-gradient, but the gradient orbits,
217
369
  * so a surface can say a mode is on for as long as it lasts. The mask sits on the
218
370
  * parent and the gradient rotates as a child, or the ring would rotate with it. */
@@ -232,6 +232,18 @@
232
232
  --font-caveat: "Caveat Variable", cursive;
233
233
  --font-bebas: "Bebas Neue", ui-sans-serif, system-ui, sans-serif;
234
234
  --radius: 1.4rem;
235
+ /* The material tier; the studio writes these per theme (Frosted defaults). */
236
+ --material-blur: 24px;
237
+ --material-clarity: 60%;
238
+ --material-depth: 1;
239
+ --material-tint: 1;
240
+ --material-edge-width: 1px;
241
+ --material-edge-ink: 0;
242
+ --material-edge-accent: 0;
243
+ --material-glow: 0px;
244
+ --material-ink-level: 0;
245
+ --material-ink-lift: 0;
246
+ --material-ink: oklch(0.16 0 0);
235
247
  --shadow-x: 0px;
236
248
  --shadow-y: 2px;
237
249
  --shadow-blur: 3px;
@@ -342,6 +354,7 @@ html[data-motion="live"] {
342
354
  --shadow-lg: 0px 2px 3px 0px hsl(0 0% 0% / 0.16), 0px 4px 6px -1px hsl(0 0% 0% / 0.16);
343
355
  --shadow-xl: 0px 2px 3px 0px hsl(0 0% 0% / 0.16), 0px 8px 10px -1px hsl(0 0% 0% / 0.16);
344
356
  --shadow-2xl: 0px 2px 3px 0px hsl(0 0% 0% / 0.4);
357
+ --material-ink: oklch(0.68 0 0);
345
358
  }
346
359
 
347
360
  @layer base {
@@ -4,6 +4,7 @@
4
4
  */
5
5
 
6
6
  export * from "./hex.js";
7
+ export * from "./material.js";
7
8
  export * from "./presets.js";
8
9
  export * from "./readability.js";
9
10
  export * from "./theme-colors.js";
@@ -0,0 +1,116 @@
1
+ import { clamp } from "./theme-colors.js";
2
+
3
+ export const MATERIAL_VERSION = 1;
4
+
5
+ export type MaterialPresetId = "frosted" | "paper" | "neon" | "chalk";
6
+
7
+ /** Tier 2 of the glass formula: what every surface's knobs are multiplied by. The homeowner's dials. */
8
+ export interface MaterialDials {
9
+ /** Backdrop blur radius, px. */
10
+ blur: number;
11
+ /** How much of the card colour a surface keeps, %; the rest is the wallpaper. */
12
+ clarity: number;
13
+ /** Scales sheen, shade, rim and lift together. */
14
+ depth: number;
15
+ /** Scales the tone wash. */
16
+ tint: number;
17
+ /** Outer bloom radius in the surface's own hue, px. */
18
+ glow: number;
19
+ /** 0..1; above 0 every surface is hand-inked: a drawn line over a hand-laid fill. */
20
+ ink: number;
21
+ }
22
+
23
+ /** Terms a preset turns on; inert at zero, never a homeowner dial. */
24
+ export interface MaterialTerms {
25
+ /** Edge width, px. */
26
+ edgeWidth: number;
27
+ /** 0..1, how far the edge moves toward the material ink. */
28
+ edgeInk: number;
29
+ /** 0..1, how far the edge moves toward the surface's own hue (its tone, else the accent). */
30
+ edgeAccent: number;
31
+ /** 0..1, how far the Ink line moves from the mode's ink toward the foreground: chalk on a dark board. */
32
+ inkLift: number;
33
+ }
34
+
35
+ export type MaterialSpec = MaterialDials & MaterialTerms;
36
+
37
+ /** What was chosen, never what was computed. */
38
+ export interface Material {
39
+ v: typeof MATERIAL_VERSION;
40
+ preset: MaterialPresetId;
41
+ dials?: Partial<MaterialDials>;
42
+ }
43
+
44
+ export type BlurMode = "dynamic" | "performant" | "none";
45
+
46
+ const PLAIN: MaterialTerms = { edgeWidth: 1, edgeInk: 0, edgeAccent: 0, inkLift: 0 };
47
+
48
+ export const MATERIAL_PRESETS: Record<MaterialPresetId, MaterialSpec> = {
49
+ /** Today's glass: translucent, blurred, lit rim. */
50
+ frosted: { blur: 24, clarity: 60, depth: 1, tint: 1, glow: 0, ink: 0, ...PLAIN },
51
+ /** Opaque matte stock, a faint inked cut edge, calm tint; the Ink dial draws on it. */
52
+ paper: { blur: 0, clarity: 100, depth: 0.5, tint: 0.85, glow: 0, ink: 0, ...PLAIN, edgeInk: 0.3 },
53
+ /** Near-opaque dark tile, thin tube of its own hue at the edge, bloom around it. */
54
+ neon: {
55
+ blur: 8,
56
+ clarity: 92,
57
+ depth: 0.4,
58
+ tint: 0.9,
59
+ edgeWidth: 1.5,
60
+ edgeInk: 0,
61
+ edgeAccent: 1,
62
+ inkLift: 0,
63
+ glow: 18,
64
+ ink: 0,
65
+ },
66
+ /** Matte board, the Ink body drawn in the foreground colour. */
67
+ chalk: { blur: 0, clarity: 100, depth: 0.3, tint: 0.7, glow: 0, ink: 1, ...PLAIN, inkLift: 1 },
68
+ };
69
+
70
+ export const FROSTED: Material = { v: 1, preset: "frosted" };
71
+
72
+ const RANGE: Record<keyof MaterialDials, [number, number]> = {
73
+ blur: [0, 48],
74
+ clarity: [0, 100],
75
+ depth: [0, 2],
76
+ tint: [0, 2],
77
+ glow: [0, 40],
78
+ ink: [0, 1],
79
+ };
80
+
81
+ /** Below this the text floor fails over a busy wallpaper with nothing blurred behind it. */
82
+ const NO_BLUR_CLARITY_FLOOR = 85;
83
+
84
+ export function materialDials(material: Material): MaterialDials {
85
+ const merged = { ...MATERIAL_PRESETS[material.preset], ...material.dials };
86
+ return {
87
+ blur: clamp(merged.blur, ...RANGE.blur),
88
+ clarity: clamp(merged.clarity, ...RANGE.clarity),
89
+ depth: clamp(merged.depth, ...RANGE.depth),
90
+ tint: clamp(merged.tint, ...RANGE.tint),
91
+ glow: clamp(merged.glow, ...RANGE.glow),
92
+ ink: clamp(merged.ink, ...RANGE.ink),
93
+ };
94
+ }
95
+
96
+ export function resolveMaterial(
97
+ material: Material,
98
+ blurMode: BlurMode,
99
+ ): Record<`--material-${string}`, string> {
100
+ const d = materialDials(material);
101
+ const t = MATERIAL_PRESETS[material.preset];
102
+ const blur = blurMode === "none" ? 0 : d.blur;
103
+ const clarity = blurMode === "none" ? Math.max(d.clarity, NO_BLUR_CLARITY_FLOOR) : d.clarity;
104
+ return {
105
+ "--material-blur": `${blur}px`,
106
+ "--material-clarity": `${clarity}%`,
107
+ "--material-depth": `${d.depth}`,
108
+ "--material-tint": `${d.tint}`,
109
+ "--material-edge-width": `${t.edgeWidth}px`,
110
+ "--material-edge-ink": `${t.edgeInk}`,
111
+ "--material-edge-accent": `${t.edgeAccent}`,
112
+ "--material-glow": `${d.glow}px`,
113
+ "--material-ink-level": `${d.ink}`,
114
+ "--material-ink-lift": `${t.inkLift}`,
115
+ };
116
+ }