@glasshome/ui 1.18.0 → 1.20.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 (78) hide show
  1. package/SPEC.md +84 -2
  2. package/dist/index.js +2 -2
  3. package/dist/lib/anchor-placement.d.ts +5 -0
  4. package/dist/lib/button-variants.d.ts +4 -1
  5. package/dist/lib/card-classes.d.ts +4 -4
  6. package/dist/lib/motion-classes.d.ts +2 -0
  7. package/dist/lib/overlay-classes.d.ts +4 -2
  8. package/dist/lib/spotlight-geometry.d.ts +22 -0
  9. package/dist/solid/button.d.ts +8 -3
  10. package/dist/solid/color-disc.d.ts +33 -0
  11. package/dist/solid/dashboard-preview.d.ts +24 -0
  12. package/dist/solid/dialog-parts.d.ts +1 -0
  13. package/dist/solid/dialog.d.ts +3 -0
  14. package/dist/solid/dock.d.ts +9 -0
  15. package/dist/solid/docked-panel.d.ts +11 -0
  16. package/dist/solid/image-picker.d.ts +3 -0
  17. package/dist/solid/index.d.ts +9 -3
  18. package/dist/solid/index.js +6254 -5475
  19. package/dist/solid/media-store.d.ts +10 -0
  20. package/dist/solid/option-card.d.ts +2 -1
  21. package/dist/solid/page-header.d.ts +2 -2
  22. package/dist/solid/preview-tile.d.ts +35 -0
  23. package/dist/solid/responsive-dialog.d.ts +2 -0
  24. package/dist/solid/schema-form.d.ts +6 -1
  25. package/dist/solid/sliding-indicator.d.ts +2 -0
  26. package/dist/solid/spotlight.d.ts +14 -0
  27. package/dist/solid/swatch-picker.d.ts +12 -0
  28. package/dist/solid/tabs.d.ts +4 -1
  29. package/dist/solid/toggle-group.d.ts +4 -1
  30. package/dist/solid/widget-identity.d.ts +2 -0
  31. package/dist/tokens/index.d.ts +1 -0
  32. package/dist/tokens/index.js +336 -118
  33. package/dist/tokens/material.d.ts +40 -0
  34. package/dist/tokens/presets.d.ts +3 -0
  35. package/dist/tokens/theme-colors.d.ts +13 -3
  36. package/dist/tokens/theme-recipe.d.ts +8 -0
  37. package/dist/{utils-COITV1s9.js → utils-CMk7R3zM.js} +488 -485
  38. package/package.json +2 -2
  39. package/scripts/check-ui-drift.mjs +5 -0
  40. package/src/lib/anchor-placement.ts +30 -0
  41. package/src/lib/button-variants.ts +13 -12
  42. package/src/lib/card-classes.ts +4 -3
  43. package/src/lib/motion-classes.ts +10 -0
  44. package/src/lib/overlay-classes.ts +10 -2
  45. package/src/lib/spotlight-geometry.ts +90 -0
  46. package/src/solid/bottom-sheet/bottom-sheet.tsx +8 -1
  47. package/src/solid/button.tsx +17 -2
  48. package/src/solid/color-disc.tsx +253 -0
  49. package/src/solid/dashboard-preview.tsx +128 -0
  50. package/src/solid/dialog-parts.tsx +5 -1
  51. package/src/solid/dialog.tsx +47 -5
  52. package/src/solid/dock.tsx +67 -9
  53. package/src/solid/docked-panel.tsx +56 -0
  54. package/src/solid/entity-selector.tsx +2 -2
  55. package/src/solid/hero-action.tsx +2 -2
  56. package/src/solid/image-picker.tsx +232 -147
  57. package/src/solid/index.ts +20 -2
  58. package/src/solid/media-store.ts +20 -1
  59. package/src/solid/option-card.tsx +27 -31
  60. package/src/solid/page-header.tsx +9 -16
  61. package/src/solid/preview-tile.tsx +89 -0
  62. package/src/solid/radio-group.tsx +7 -2
  63. package/src/solid/responsive-dialog.tsx +10 -2
  64. package/src/solid/schema-form.tsx +30 -4
  65. package/src/solid/section-card.tsx +4 -2
  66. package/src/solid/sliding-indicator.tsx +34 -17
  67. package/src/solid/spotlight.tsx +179 -0
  68. package/src/solid/swatch-picker.tsx +47 -0
  69. package/src/solid/tabs.tsx +20 -4
  70. package/src/solid/toggle-group.tsx +43 -8
  71. package/src/solid/widget-identity.tsx +3 -1
  72. package/src/styles/globals.css +166 -14
  73. package/src/styles/theme.css +25 -3
  74. package/src/tokens/index.ts +1 -0
  75. package/src/tokens/material.ts +116 -0
  76. package/src/tokens/presets.ts +195 -56
  77. package/src/tokens/theme-colors.ts +15 -3
  78. package/src/tokens/theme-recipe.ts +18 -4
@@ -0,0 +1,179 @@
1
+ import {
2
+ type Component,
3
+ createEffect,
4
+ createSignal,
5
+ type JSX,
6
+ onCleanup,
7
+ onMount,
8
+ Show,
9
+ } from "solid-js";
10
+ import { Portal } from "solid-js/web";
11
+ import { Z_CLASS } from "../lib/layers.js";
12
+ import { SCRIM_MOTION, TRAVEL_MOTION } from "../lib/motion-classes.js";
13
+ import { OVERLAY_SURFACE_OPAQUE, PANEL_TAIL, SCRIM_CLASS } from "../lib/overlay-classes.js";
14
+ import { type Box, holePath, placeBubble } from "../lib/spotlight-geometry.js";
15
+ import { cn } from "../lib/utils.js";
16
+
17
+ const HOLE_PAD = 8;
18
+ const HOLE_RADIUS = 12;
19
+ const BUBBLE_GAP = 12;
20
+ const VIEWPORT_MARGIN = 12;
21
+ const TAIL_SIZE = 20;
22
+ const BUBBLE_DEFAULT_WIDTH = 384;
23
+ /* The gap grows by the tail's half-diagonal so the rotated square never touches the anchor. */
24
+ const BUBBLE_GAP_WITH_TAIL = BUBBLE_GAP + (TAIL_SIZE * Math.SQRT2) / 2;
25
+
26
+ interface SpotlightProps {
27
+ target: Element | undefined;
28
+ /** What the bubble is placed against and the tail points at. Defaults to `target`. */
29
+ anchor?: Element;
30
+ scrim: boolean;
31
+ blocking?: boolean;
32
+ pad?: number;
33
+ onSkip?: () => void;
34
+ class?: string;
35
+ children: JSX.Element;
36
+ }
37
+
38
+ /* Field-by-field so an unchanged measure (same numbers, new object) writes nothing. */
39
+ function sameFields<T extends object>(a: T | null, b: T | null): boolean {
40
+ if (a === b) return true;
41
+ if (!a || !b) return false;
42
+ return (Object.keys(a) as (keyof T)[]).every((key) => a[key] === b[key]);
43
+ }
44
+
45
+ const Spotlight: Component<SpotlightProps> = (props) => {
46
+ const [box, setBox] = createSignal<Box | null>(null, { equals: sameFields });
47
+ const [anchorBox, setAnchorBox] = createSignal<Box | null>(null, { equals: sameFields });
48
+ const [viewport, setViewport] = createSignal(
49
+ { width: window.innerWidth, height: window.innerHeight },
50
+ { equals: sameFields },
51
+ );
52
+ const [bubbleSize, setBubbleSize] = createSignal(
53
+ { width: BUBBLE_DEFAULT_WIDTH, height: 96 },
54
+ { equals: sameFields },
55
+ );
56
+ let bubble: HTMLDivElement | undefined;
57
+
58
+ const anchorEl = () => props.anchor ?? props.target;
59
+
60
+ const rectToBox = (el: Element | undefined) => {
61
+ const r = el?.getBoundingClientRect();
62
+ return r ? { x: r.left, y: r.top, width: r.width, height: r.height } : null;
63
+ };
64
+
65
+ const measure = () => {
66
+ setViewport({ width: window.innerWidth, height: window.innerHeight });
67
+ const targetBox = rectToBox(props.target);
68
+ setBox(targetBox);
69
+ const anchor = anchorEl();
70
+ /* Same element as target: reuse its box instead of measuring it twice a tick. */
71
+ setAnchorBox(anchor === props.target ? targetBox : rectToBox(anchor));
72
+ if (bubble)
73
+ setBubbleSize({
74
+ width: bubble.offsetWidth || BUBBLE_DEFAULT_WIDTH,
75
+ height: bubble.offsetHeight || 96,
76
+ });
77
+ };
78
+
79
+ createEffect(() => {
80
+ const target = props.target;
81
+ const anchor = anchorEl();
82
+ let raf = 0;
83
+ let start: number | undefined;
84
+
85
+ /* A transform-animating target never fires ResizeObserver, and its motion may
86
+ * start a few frames late, so sample the whole window instead of stopping early. */
87
+ const tick = (time: number) => {
88
+ start ??= time;
89
+ measure();
90
+ if (time - start < 600) raf = requestAnimationFrame(tick);
91
+ };
92
+
93
+ measure();
94
+ raf = requestAnimationFrame(tick);
95
+
96
+ const observer = new ResizeObserver(measure);
97
+ if (target) observer.observe(target);
98
+ if (anchor && anchor !== target) observer.observe(anchor);
99
+ if (bubble) observer.observe(bubble);
100
+ onCleanup(() => {
101
+ cancelAnimationFrame(raf);
102
+ observer.disconnect();
103
+ });
104
+ });
105
+
106
+ onMount(() => {
107
+ const onKey = (e: KeyboardEvent) => {
108
+ if (e.key === "Escape") props.onSkip?.();
109
+ };
110
+ window.addEventListener("resize", measure);
111
+ window.addEventListener("scroll", measure, { capture: true, passive: true });
112
+ document.addEventListener("keydown", onKey);
113
+ onCleanup(() => {
114
+ window.removeEventListener("resize", measure);
115
+ window.removeEventListener("scroll", measure, { capture: true });
116
+ document.removeEventListener("keydown", onKey);
117
+ });
118
+ });
119
+
120
+ const place = () =>
121
+ placeBubble(viewport(), anchorBox(), bubbleSize(), BUBBLE_GAP_WITH_TAIL, VIEWPORT_MARGIN);
122
+
123
+ return (
124
+ <Portal>
125
+ <Show when={props.scrim}>
126
+ <div
127
+ data-slot="spotlight-scrim"
128
+ data-expanded=""
129
+ aria-hidden="true"
130
+ class={cn(
131
+ "fixed inset-0",
132
+ SCRIM_CLASS,
133
+ Z_CLASS.overlay,
134
+ SCRIM_MOTION,
135
+ TRAVEL_MOTION,
136
+ !box() && !props.blocking && "pointer-events-none",
137
+ )}
138
+ style={{
139
+ "clip-path": `path(evenodd, "${holePath(viewport(), box(), props.pad ?? HOLE_PAD, HOLE_RADIUS)}")`,
140
+ }}
141
+ />
142
+ </Show>
143
+ <div
144
+ ref={bubble}
145
+ data-slot="spotlight-bubble"
146
+ data-side={place().side}
147
+ class={cn(TRAVEL_MOTION, Z_CLASS.overlay, "fixed top-0 left-0 w-96", props.class)}
148
+ style={{ translate: `${place().x}px ${place().y}px` }}
149
+ >
150
+ <Show when={place().tail}>
151
+ {(tail) => (
152
+ <div
153
+ data-slot="spotlight-tail"
154
+ data-side={place().side}
155
+ aria-hidden="true"
156
+ class={cn(OVERLAY_SURFACE_OPAQUE, "absolute rotate-45 rounded-[2px]")}
157
+ style={{
158
+ width: `${TAIL_SIZE}px`,
159
+ height: `${TAIL_SIZE}px`,
160
+ left: `${tail().x - TAIL_SIZE / 2}px`,
161
+ ...(place().side === "above"
162
+ ? { bottom: `${-TAIL_SIZE / 2}px` }
163
+ : { top: `${-TAIL_SIZE / 2}px` }),
164
+ }}
165
+ />
166
+ )}
167
+ </Show>
168
+ <div
169
+ data-slot="spotlight-panel"
170
+ class={cn(OVERLAY_SURFACE_OPAQUE, PANEL_TAIL, "relative z-auto p-4")}
171
+ >
172
+ {props.children}
173
+ </div>
174
+ </div>
175
+ </Portal>
176
+ );
177
+ };
178
+
179
+ export { Spotlight };
@@ -0,0 +1,47 @@
1
+ import type { JSX } from "solid-js";
2
+ import { For } from "solid-js";
3
+ import { cn } from "../lib/utils.js";
4
+ import { RadioGroup, RadioGroupItem } from "./radio-group.js";
5
+
6
+ /** One colour out of a few, as swatches sharing one row; `children` is the custom slot at the end (a picker). */
7
+ export function SwatchPicker(props: {
8
+ value: string | null;
9
+ colors: readonly string[];
10
+ onChange: (color: string) => void;
11
+ "aria-label": string;
12
+ /** Names each swatch for assistive tech. */
13
+ labelOf?: (color: string, index: number) => string;
14
+ class?: string;
15
+ children?: JSX.Element;
16
+ }) {
17
+ return (
18
+ <RadioGroup
19
+ data-slot="swatch-picker"
20
+ class={cn("grid auto-cols-fr grid-flow-col items-center gap-2", props.class)}
21
+ value={props.value ?? ""}
22
+ onChange={props.onChange}
23
+ aria-label={props["aria-label"]}
24
+ >
25
+ <For each={props.colors}>
26
+ {(color, index) => (
27
+ <RadioGroupItem
28
+ data-slot="swatch-picker-item"
29
+ value={color}
30
+ showControl={false}
31
+ class="group/swatch"
32
+ >
33
+ <span
34
+ data-slot="swatch-picker-swatch"
35
+ class="block aspect-square w-full max-w-9 rounded-full border border-foreground/15 transition-glass duration-200 group-active/swatch:scale-90 group-has-[:focus-visible]/swatch:ring-[3px] group-has-[:focus-visible]/swatch:ring-ring/50 group-data-[checked]/swatch:ring-2 group-data-[checked]/swatch:ring-foreground group-data-[checked]/swatch:ring-offset-2 group-data-[checked]/swatch:ring-offset-transparent"
36
+ style={{ background: color }}
37
+ />
38
+ <span class="sr-only">
39
+ {props.labelOf?.(color, index()) ?? `Colour ${index() + 1}`}
40
+ </span>
41
+ </RadioGroupItem>
42
+ )}
43
+ </For>
44
+ {props.children}
45
+ </RadioGroup>
46
+ );
47
+ }
@@ -4,6 +4,7 @@ import { TRACK_SURFACE } from "../lib/card-classes.js";
4
4
  import { PRESS_DIP, SETTLE_MOTION } from "../lib/motion-classes.js";
5
5
  import { SEGMENT_ITEM } from "../lib/segment-classes.js";
6
6
  import { cn } from "../lib/utils.js";
7
+ import { Icon } from "./icon.js";
7
8
  import { SlidingIndicator } from "./sliding-indicator.js";
8
9
 
9
10
  /** `split`: the root is `display: contents`, so a host (a modal panel) lays the
@@ -67,7 +68,7 @@ const TabsList: Component<ComponentProps<typeof TabsPrimitive.List>> = (props) =
67
68
  ref={listRef}
68
69
  data-slot="tabs-list"
69
70
  class={cn(
70
- `scrollbar-hide inline-flex h-9 w-full items-center overflow-x-auto rounded-lg ${TRACK_SURFACE} p-1 text-muted-foreground`,
71
+ `scrollbar-hide inline-flex h-9 w-full items-center overflow-x-auto rounded-lg has-[[data-slot=tabs-trigger-icon]]:h-auto ${TRACK_SURFACE} p-1 text-muted-foreground`,
71
72
  local.class,
72
73
  )}
73
74
  {...others}
@@ -85,8 +86,11 @@ const TabsList: Component<ComponentProps<typeof TabsPrimitive.List>> = (props) =
85
86
  );
86
87
  };
87
88
 
88
- const TabsTrigger: Component<ComponentProps<typeof TabsPrimitive.Trigger>> = (props) => {
89
- const [local, others] = splitProps(props, ["class"]);
89
+ /** `icon` stacks a glyph over the word, so a tab row reads apart from the toggle groups under it. */
90
+ const TabsTrigger: Component<ComponentProps<typeof TabsPrimitive.Trigger> & { icon?: string }> = (
91
+ props,
92
+ ) => {
93
+ const [local, others] = splitProps(props, ["class", "icon", "children"]);
90
94
  return (
91
95
  <TabsPrimitive.Trigger
92
96
  data-slot="tabs-trigger"
@@ -94,10 +98,22 @@ const TabsTrigger: Component<ComponentProps<typeof TabsPrimitive.Trigger>> = (pr
94
98
  SEGMENT_ITEM,
95
99
  PRESS_DIP,
96
100
  "hover:text-primary/80 data-[selected]:text-primary",
101
+ local.icon && "h-auto flex-1 flex-col gap-1 py-2 text-xs",
97
102
  local.class,
98
103
  )}
99
104
  {...others}
100
- />
105
+ >
106
+ {local.icon && (
107
+ <Icon
108
+ data-slot="tabs-trigger-icon"
109
+ icon={local.icon}
110
+ width={18}
111
+ height={18}
112
+ aria-hidden="true"
113
+ />
114
+ )}
115
+ {local.children}
116
+ </TabsPrimitive.Trigger>
101
117
  );
102
118
  };
103
119
 
@@ -4,6 +4,9 @@ import {
4
4
  type Component,
5
5
  type ComponentProps,
6
6
  createContext,
7
+ createSignal,
8
+ onCleanup,
9
+ onMount,
7
10
  type ParentComponent,
8
11
  Show,
9
12
  splitProps,
@@ -27,20 +30,53 @@ const ToggleGroupContext = createContext<ToggleGroupContextValue>({
27
30
  });
28
31
 
29
32
  const ToggleGroup: ParentComponent<
30
- ComponentProps<typeof ToggleGroupPrimitive> & VariantProps<typeof toggleVariants>
33
+ ComponentProps<typeof ToggleGroupPrimitive> &
34
+ VariantProps<typeof toggleVariants> & {
35
+ /** CSS colour for the selected segment's glass. Default `var(--primary)`. */
36
+ tone?: string;
37
+ }
31
38
  > = (props) => {
32
- const [local, rest] = splitProps(props, ["class", "variant", "size", "children"] as const);
39
+ const [local, rest] = splitProps(props, [
40
+ "class",
41
+ "variant",
42
+ "size",
43
+ "tone",
44
+ "children",
45
+ ] as const);
33
46
  // Read `multiple` without splitting it out: Kobalte's root is a single/multiple
34
47
  // discriminated union, so pulling `multiple` into a separate prop collapses the
35
48
  // union and mistypes `value`. Leave it in `rest` and just peek at it here.
36
49
  const sliding = () => !(props as { multiple?: boolean }).multiple;
50
+ // Items that overflow the width they are given wrap onto rows; measured, so labels of any length work.
51
+ const [wrap, setWrap] = createSignal(false);
52
+ let root: HTMLDivElement | undefined;
53
+ const measure = () => {
54
+ if (!root) return;
55
+ const items = root.querySelectorAll<HTMLElement>('[data-slot="toggle-group-item"]');
56
+ let needed = 8 + 4 * Math.max(0, items.length - 1);
57
+ for (const item of items) needed += item.scrollWidth;
58
+ const room = root.parentElement?.clientWidth ?? root.clientWidth;
59
+ setWrap(needed > room + 1);
60
+ };
61
+ onMount(() => {
62
+ if (!root || typeof ResizeObserver === "undefined") return;
63
+ const ro = new ResizeObserver(measure);
64
+ ro.observe(root);
65
+ if (root.parentElement) ro.observe(root.parentElement);
66
+ onCleanup(() => ro.disconnect());
67
+ });
37
68
  return (
38
69
  <ToggleGroupPrimitive
70
+ ref={(el: HTMLDivElement) => {
71
+ root = el;
72
+ }}
39
73
  data-slot="toggle-group"
40
74
  data-variant={local.variant}
41
75
  data-size={local.size}
76
+ data-wrap={wrap() ? "" : undefined}
42
77
  class={cn(
43
- `group/toggle-group flex w-fit items-center rounded-lg ${TRACK_SURFACE} p-1 data-[variant=outline]:shadow-xs`,
78
+ `group/toggle-group flex w-fit max-w-full items-center rounded-lg ${TRACK_SURFACE} p-1 data-[variant=outline]:shadow-xs`,
79
+ wrap() && "flex-wrap gap-1",
44
80
  local.class,
45
81
  )}
46
82
  {...rest}
@@ -54,7 +90,9 @@ const ToggleGroup: ParentComponent<
54
90
  <SlidingIndicator
55
91
  activeSelector="[data-pressed]"
56
92
  indicatorClass="rounded-md"
57
- class="flex w-full items-center"
93
+ indicatorTone={local.tone}
94
+ wrapped={wrap()}
95
+ class={cn("flex w-full items-center", wrap() && "flex-wrap gap-1")}
58
96
  >
59
97
  {local.children}
60
98
  </SlidingIndicator>
@@ -80,10 +118,7 @@ const ToggleGroupItem: Component<
80
118
  variant: context.variant || local.variant,
81
119
  size: context.size || local.size,
82
120
  }),
83
- // `*-of-type` (not `first:`/`last:`): the sliding indicator is a <div> sibling,
84
- // so `:first-child`/`:last-child` would land on the indicator and drop the end
85
- // segments' rounded corners. Items are <button>, so `-of-type` skips the indicator.
86
- "min-w-0 flex-1 shrink-0 rounded-none px-4 shadow-none first-of-type:rounded-l-md last-of-type:rounded-r-md focus:z-10 focus-visible:z-10 data-[variant=outline]:border-l-0 data-[variant=outline]:first-of-type:border-l",
121
+ "min-w-0 flex-1 shrink-0 rounded-md px-4 shadow-none focus:z-10 focus-visible:z-10 data-[variant=outline]:border-l-0 data-[variant=outline]:first-of-type:border-l group-data-[wrap]/toggle-group:flex-none",
87
122
  // Single-select: the sliding indicator paints the active segment, so the
88
123
  // item needs no pressed fill of its own and hover only tints the text.
89
124
  // Multi-select has no single indicator, so each pressed segment carries
@@ -50,6 +50,8 @@ type WidgetIdentityProps = {
50
50
  widget: WidgetSummary;
51
51
  /** Icon pill size. Rows use sm, tiles use md. */
52
52
  iconSize?: "sm" | "md";
53
+ /** CSS color for the icon pill; neutral when unset. */
54
+ iconTone?: string;
53
55
  /** Append `v{latestVersion}` next to the name. Default true. */
54
56
  showVersionInline?: boolean;
55
57
  /** Show the (personal/org) scope pill after the @scope/name line. */
@@ -61,7 +63,7 @@ export function WidgetIdentity(_props: WidgetIdentityProps) {
61
63
  const props = mergeProps({ iconSize: "sm" as const, showVersionInline: true }, _props);
62
64
  return (
63
65
  <div data-slot="widget-identity" class={cn("flex min-w-0 items-center gap-3", props.class)}>
64
- <SectionIcon size={props.iconSize}>
66
+ <SectionIcon size={props.iconSize} tone={props.iconTone}>
65
67
  <Show when={props.widget.icon} fallback={<Icon icon="lucide:package" />}>
66
68
  {(icon) => <Icon icon={icon()} />}
67
69
  </Show>
@@ -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. */