@glasshome/ui 1.17.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 (66) hide show
  1. package/SPEC.md +83 -2
  2. package/dist/index.js +2 -2
  3. package/dist/lib/button-variants.d.ts +4 -1
  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/pill-classes.d.ts +1 -1
  8. package/dist/lib/spotlight-geometry.d.ts +22 -0
  9. package/dist/lib/thumb-classes.d.ts +1 -0
  10. package/dist/lib/tier-badge.d.ts +1 -1
  11. package/dist/solid/button.d.ts +8 -3
  12. package/dist/solid/dock.d.ts +9 -0
  13. package/dist/solid/docked-panel.d.ts +11 -0
  14. package/dist/solid/index.d.ts +6 -2
  15. package/dist/solid/index.js +4399 -4034
  16. package/dist/solid/option-card.d.ts +1 -1
  17. package/dist/solid/preview-tile.d.ts +33 -0
  18. package/dist/solid/spotlight.d.ts +14 -0
  19. package/dist/solid/swatch-picker.d.ts +12 -0
  20. package/dist/solid/tabs.d.ts +4 -1
  21. package/dist/solid/widget-identity.d.ts +2 -0
  22. package/dist/tokens/index.d.ts +3 -0
  23. package/dist/tokens/index.js +481 -67
  24. package/dist/tokens/material.d.ts +40 -0
  25. package/dist/tokens/presets.d.ts +3 -0
  26. package/dist/tokens/readability.d.ts +21 -0
  27. package/dist/tokens/theme-colors.d.ts +13 -3
  28. package/dist/tokens/theme-recipe.d.ts +33 -0
  29. package/dist/{utils-DMaksjvy.js → utils-CV6G6fr8.js} +343 -340
  30. package/package.json +2 -2
  31. package/src/lib/button-variants.ts +10 -7
  32. package/src/lib/card-classes.ts +4 -3
  33. package/src/lib/motion-classes.ts +5 -0
  34. package/src/lib/overlay-classes.ts +10 -2
  35. package/src/lib/pill-classes.ts +4 -3
  36. package/src/lib/spotlight-geometry.ts +90 -0
  37. package/src/lib/thumb-classes.ts +7 -0
  38. package/src/lib/tier-badge.ts +1 -1
  39. package/src/solid/button.tsx +17 -2
  40. package/src/solid/carousel.tsx +2 -2
  41. package/src/solid/data-table.tsx +2 -2
  42. package/src/solid/dock.tsx +67 -9
  43. package/src/solid/docked-panel.tsx +56 -0
  44. package/src/solid/hero-action.tsx +2 -2
  45. package/src/solid/icon-picker.tsx +1 -1
  46. package/src/solid/index.ts +11 -2
  47. package/src/solid/media-tile.tsx +1 -1
  48. package/src/solid/option-card.tsx +25 -31
  49. package/src/solid/preview-tile.tsx +79 -0
  50. package/src/solid/radio-group.tsx +7 -2
  51. package/src/solid/section-card.tsx +4 -2
  52. package/src/solid/sliding-indicator.tsx +13 -12
  53. package/src/solid/spotlight.tsx +179 -0
  54. package/src/solid/swatch-picker.tsx +47 -0
  55. package/src/solid/switch.tsx +5 -2
  56. package/src/solid/tabs.tsx +20 -4
  57. package/src/solid/toggle-group.tsx +1 -4
  58. package/src/solid/widget-identity.tsx +3 -1
  59. package/src/styles/globals.css +166 -14
  60. package/src/styles/theme.css +22 -3
  61. package/src/tokens/index.ts +3 -0
  62. package/src/tokens/material.ts +116 -0
  63. package/src/tokens/presets.ts +201 -62
  64. package/src/tokens/readability.ts +67 -0
  65. package/src/tokens/theme-colors.ts +15 -3
  66. package/src/tokens/theme-recipe.ts +161 -0
@@ -10,7 +10,6 @@ import {
10
10
  useContext,
11
11
  } from "solid-js";
12
12
  import { CARD_SURFACE } from "../lib/card-classes.js";
13
- import { isNeutralTone, NEUTRAL_KNOBS } from "../lib/glass-tone.js";
14
13
  import { STAGGER } from "../lib/motion-classes.js";
15
14
  import { cn } from "../lib/utils.js";
16
15
  import { Icon } from "./icon.js";
@@ -18,13 +17,8 @@ import { Ornament } from "./ornament.js";
18
17
  import { PickerRow } from "./picker-row.js";
19
18
  import { RadioGroup, RadioGroupItem } from "./radio-group.js";
20
19
 
21
- /* The card is the affordance, so the radio's own control is suppressed and the
22
- * toned surface plus the check ornament carry the picked state; an accented card keeps its own tone at rest. Tone alone (no
23
- * .glass-tint) because a card is body copy: .glass-tint would mix the label
24
- * colour toward the tone, and toward `transparent` while nothing is picked.
25
- * Padding lives inside the label, not on the item, so the whole card is a
26
- * click target. */
27
- const OPTION_CARD_CHROME = `${CARD_SURFACE} group/option-card relative cursor-pointer overflow-hidden rounded-md transition-glass duration-200 hover:[--glass-base:color-mix(in_srgb,var(--card)_80%,transparent)] has-[:focus-visible]:[--glass-edge:var(--ring)] has-[:focus-visible]:ring-[3px] has-[:focus-visible]:ring-ring/50 [&:not([style*=--glass-tone])]:data-[checked]:[--glass-tone:var(--primary)] data-[checked]:[--glass-edge:color-mix(in_srgb,var(--primary)_45%,transparent)] data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50`;
20
+ /* Tone without .glass-tint: the card holds body copy, which must stay foreground-coloured. */
21
+ const OPTION_CARD_CHROME = `${CARD_SURFACE} group/option-card relative cursor-pointer overflow-hidden rounded-xl transition-glass duration-200 [&:not([style*=--glass-tone])]:[--glass-tone:var(--primary)] [--glass-wash:9%] hover:[--glass-wash:16%] has-[:focus-visible]:[--glass-edge:var(--ring)] has-[:focus-visible]:ring-[3px] has-[:focus-visible]:ring-ring/50 data-[checked]:[--glass-wash:30%] data-[checked]:[--glass-edge:oklch(from_var(--glass-tone)_l_c_h/0.75)] data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50`;
28
22
 
29
23
  /* Sub-options live inside the card: the card grows (a grid row morphing
30
24
  * 0fr -> 1fr on the morph token) while it is picked, and the content settles
@@ -37,7 +31,7 @@ const OPTION_CHOICE_ROW =
37
31
  "rounded-sm text-foreground/75 transition-colors hover:bg-foreground/5 aria-checked:text-foreground";
38
32
 
39
33
  const OPTION_CARD_DRAWER_CONTENT =
40
- "-translate-y-2 flex flex-col gap-0.5 pr-1 pb-2 pl-[calc(var(--spacing)*4+20px)] opacity-0 transition-[opacity,translate] duration-(--duration-expand) ease-(--ease-morph) group-data-[checked]/option-card:translate-y-0 group-data-[checked]/option-card:opacity-100 group-data-[checked]/option-card:delay-[80ms]";
34
+ "-translate-y-2 flex flex-col gap-0.5 pr-1 pb-2 pl-[calc(var(--spacing)*3.5+54px)] opacity-0 transition-[opacity,translate] duration-(--duration-expand) ease-(--ease-morph) group-data-[checked]/option-card:translate-y-0 group-data-[checked]/option-card:opacity-100 group-data-[checked]/option-card:delay-[80ms]";
41
35
 
42
36
  /* Sub-options are rows of the card, chosen in place: the same row a picker
43
37
  * list shows, flat on the card (a glass pill on a glass card is a layer too
@@ -106,7 +100,7 @@ export function OptionCard(props: {
106
100
  description?: string;
107
101
  icon?: string;
108
102
  iconImage?: string;
109
- /** Per-option tone at rest (setup's brand colours); neutral by default. */
103
+ /** Per-option tone (setup's brand colours); the theme primary when absent. */
110
104
  accentVar?: string;
111
105
  /** Drop the check when picking the card is itself the next step. */
112
106
  ornament?: "check" | "none";
@@ -140,7 +134,8 @@ export function OptionCard(props: {
140
134
  <div
141
135
  data-slot="option-card"
142
136
  data-checked={checked() ? "" : undefined}
143
- class={cn(OPTION_CARD_CHROME, isNeutralTone(props.accentVar) && NEUTRAL_KNOBS, props.class)}
137
+ data-disabled={props.disabled ? "" : undefined}
138
+ class={cn(OPTION_CARD_CHROME, props.class)}
144
139
  style={
145
140
  props.accentVar ? ({ "--glass-tone": props.accentVar } as JSX.CSSProperties) : undefined
146
141
  }
@@ -154,14 +149,10 @@ export function OptionCard(props: {
154
149
  >
155
150
  {/* On the header row, not the card: a grown card keeps its rows clear. */}
156
151
  <Ornament kind={props.ornament ?? "check"} />
157
- <div data-slot="option-card-row" class="flex w-full items-start gap-3 p-3">
158
- <Show when={props.iconImage} fallback={<OptionIcon icon={props.icon} />}>
159
- {(src) => (
160
- <img src={src()} alt="" aria-hidden="true" class="size-5 shrink-0 object-contain" />
161
- )}
162
- </Show>
152
+ <div data-slot="option-card-row" class="flex w-full items-center gap-3.5 p-3.5">
153
+ <OptionIconWell icon={props.icon} image={props.iconImage} />
163
154
  <div class="flex min-w-0 flex-1 flex-col gap-0.5">
164
- <span data-slot="option-card-title" class="font-medium text-sm leading-snug">
155
+ <span data-slot="option-card-title" class="font-semibold text-[15px] leading-snug">
165
156
  {props.title}
166
157
  </span>
167
158
  <Show when={props.description}>
@@ -196,20 +187,23 @@ export function OptionCard(props: {
196
187
  );
197
188
  }
198
189
 
199
- /* The icon sits on the title line, the mini form of HeroAction's big glyph,
200
- * in text colour: the tone belongs to the surface and the ornament. */
201
- function OptionIcon(props: { icon?: string }) {
190
+ function OptionIconWell(props: { icon?: string; image?: string }) {
202
191
  return (
203
- <Show when={props.icon}>
204
- {(icon) => (
205
- <Icon
206
- icon={icon()}
207
- width={20}
208
- height={20}
209
- aria-hidden="true"
210
- class="mt-px shrink-0 text-muted-foreground"
211
- />
212
- )}
192
+ <Show when={props.icon || props.image}>
193
+ <span
194
+ data-slot="option-card-icon"
195
+ aria-hidden="true"
196
+ class="grid size-10 shrink-0 place-items-center rounded-[14px] bg-[color-mix(in_oklab,var(--surface-tone)_80%,black)] [color:oklch(from_var(--surface-tone)_calc((0.75_-_l)*100)_0_0)]"
197
+ >
198
+ <Show
199
+ when={props.image}
200
+ fallback={
201
+ <Show when={props.icon}>{(icon) => <Icon icon={icon()} width={20} height={20} />}</Show>
202
+ }
203
+ >
204
+ {(src) => <img src={src()} alt="" class="size-5 object-contain" />}
205
+ </Show>
206
+ </span>
213
207
  </Show>
214
208
  );
215
209
  }
@@ -0,0 +1,79 @@
1
+ import type { JSX } from "solid-js";
2
+ import { Show } from "solid-js";
3
+ import { cn } from "../lib/utils.js";
4
+ import { Icon } from "./icon.js";
5
+ import { RadioGroup, RadioGroupItem } from "./radio-group.js";
6
+
7
+ const COLUMNS = { 2: "grid-cols-2", 3: "grid-cols-3", 4: "grid-cols-4" } as const;
8
+
9
+ const SHAPE = { wide: "aspect-[16/10]", tile: "aspect-[5/4]" } as const;
10
+
11
+ /* The face is the affordance: the radio control is suppressed and a ring on
12
+ * the face carries the picked state, the focus ring rides the same edge. */
13
+ const TILE_FACE =
14
+ "relative w-full overflow-hidden rounded-lg border border-border/60 transition-glass duration-200 group-active/preview-tile:scale-[0.97] group-data-[checked]/preview-tile:border-transparent group-data-[checked]/preview-tile:ring-2 group-data-[checked]/preview-tile:ring-primary group-data-[checked]/preview-tile:ring-offset-2 group-data-[checked]/preview-tile:ring-offset-transparent group-has-[:focus-visible]/preview-tile:ring-[3px] group-has-[:focus-visible]/preview-tile:ring-ring/50";
15
+
16
+ export function PreviewTileGroup(props: {
17
+ value: string | null;
18
+ onChange: (value: string) => void;
19
+ "aria-label": string;
20
+ columns?: keyof typeof COLUMNS;
21
+ class?: string;
22
+ children: JSX.Element;
23
+ }) {
24
+ return (
25
+ <RadioGroup
26
+ data-slot="preview-tile-group"
27
+ class={cn("grid gap-2.5", COLUMNS[props.columns ?? 2], props.class)}
28
+ value={props.value ?? ""}
29
+ onChange={props.onChange}
30
+ aria-label={props["aria-label"]}
31
+ >
32
+ {props.children}
33
+ </RadioGroup>
34
+ );
35
+ }
36
+
37
+ /** A choice shown as what it produces: a picture, a preview card, a shape. */
38
+ export function PreviewTile(props: {
39
+ value: string;
40
+ label: string;
41
+ /** Off for pictures that name themselves; the label still reaches assistive tech. */
42
+ caption?: boolean;
43
+ icon?: string;
44
+ shape?: keyof typeof SHAPE;
45
+ disabled?: boolean;
46
+ class?: string;
47
+ /** Fires on every click, including a re-pick of the checked tile. */
48
+ onPick?: () => void;
49
+ children: JSX.Element;
50
+ }) {
51
+ return (
52
+ <RadioGroupItem
53
+ data-slot="preview-tile"
54
+ value={props.value}
55
+ disabled={props.disabled}
56
+ showControl={false}
57
+ onClick={() => !props.disabled && props.onPick?.()}
58
+ class={cn(
59
+ "group/preview-tile min-w-0 [&_[data-slot=radio-group-item-content]]:flex [&_[data-slot=radio-group-item-content]]:flex-col [&_[data-slot=radio-group-item-content]]:gap-1.5",
60
+ props.class,
61
+ )}
62
+ >
63
+ <div data-slot="preview-tile-face" class={cn(TILE_FACE, SHAPE[props.shape ?? "wide"])}>
64
+ {props.children}
65
+ </div>
66
+ <Show when={props.caption ?? true} fallback={<span class="sr-only">{props.label}</span>}>
67
+ <span
68
+ data-slot="preview-tile-caption"
69
+ class="flex items-center justify-center gap-1 text-muted-foreground text-xs group-data-[checked]/preview-tile:text-foreground"
70
+ >
71
+ <Show when={props.icon}>
72
+ {(icon) => <Icon icon={icon()} width={12} height={12} aria-hidden="true" />}
73
+ </Show>
74
+ {props.label}
75
+ </span>
76
+ </Show>
77
+ </RadioGroupItem>
78
+ );
79
+ }
@@ -43,8 +43,13 @@ const RadioGroupItem: Component<
43
43
  that animates in. */}
44
44
  <RadioGroupPrimitive.ItemIndicator
45
45
  data-slot="radio-group-item-indicator"
46
- class="glass glass-tint zoom-in-50 fade-in absolute inset-0 animate-in rounded-full duration-200 [--glass-tone:var(--primary)]"
47
- />
46
+ class="glass glass-tint zoom-in-50 fade-in absolute inset-0 grid animate-in place-items-center rounded-full duration-200 [--glass-tone:var(--primary)] [--glass-wash:90%]"
47
+ >
48
+ <span
49
+ data-slot="radio-group-item-dot"
50
+ class="size-[36%] rounded-full [background:oklch(from_var(--primary)_calc((0.42_-_l)*100)_0_0)] dark:[background:oklch(from_var(--primary)_calc((0.6_-_l)*100)_0_0)]"
51
+ />
52
+ </RadioGroupPrimitive.ItemIndicator>
48
53
  </RadioGroupPrimitive.ItemControl>
49
54
  </Show>
50
55
  {local.children && (
@@ -73,7 +73,9 @@ export function SectionCard(props: SectionCardProps) {
73
73
  data-slot="section-card-header"
74
74
  class={cn("flex items-center gap-2 sm:gap-3", props.headerClass)}
75
75
  >
76
- <Show when={props.icon}>{(icon) => <SectionIcon icon={icon()} />}</Show>
76
+ <Show when={props.icon}>
77
+ {(icon) => <SectionIcon icon={icon()} tone="var(--primary)" />}
78
+ </Show>
77
79
  <div data-slot="section-card-headings" class="flex min-w-0 flex-1 flex-col gap-0.5">
78
80
  <div data-slot="section-card-headline" class="flex min-w-0 items-center gap-2 sm:gap-3">
79
81
  <Show when={props.title}>
@@ -323,7 +325,7 @@ export function SectionGroup(props: {
323
325
  class="mb-2 flex flex-wrap items-center justify-between gap-2"
324
326
  >
325
327
  <div data-slot="section-group-heading" class="flex min-w-0 items-center gap-2">
326
- <SectionIcon icon={props.icon} size="sm" />
328
+ <SectionIcon icon={props.icon} size="sm" tone="var(--primary)" />
327
329
  <SectionHeading>{props.label}</SectionHeading>
328
330
  <Show when={props.count}>
329
331
  <CountPill>{props.count}</CountPill>
@@ -145,12 +145,8 @@ export function SlidingIndicator(props: SlidingIndicatorProps) {
145
145
  setPos(null);
146
146
  return;
147
147
  }
148
- // Not laid out yet: a hidden/collapsing popover, a display:none tab panel, a
149
- // portal measured before Kobalte positions it, or a dialog still running its
150
- // open transform. Measuring then would fling the indicator to a bogus offset
151
- // (a stray tinted blob a screenshot catches mid-open) or scale it by the
152
- // ancestor's in-flight transform, so hide until there is real geometry.
153
- // Rects, not clientWidth: a transformed ancestor leaves layout size intact.
148
+ // Not laid out yet: a hidden/collapsing popover, a display:none tab panel, or
149
+ // a portal measured before Kobalte positions it. Hide until real geometry.
154
150
  const er = el.getBoundingClientRect();
155
151
  const cr = containerRef.getBoundingClientRect();
156
152
  if (er.width === 0 || er.height === 0 || cr.width === 0 || cr.height === 0) {
@@ -166,18 +162,23 @@ export function SlidingIndicator(props: SlidingIndicatorProps) {
166
162
  // border so it aligns to the padding box (where the absolute indicator anchors).
167
163
  // A row arriving through gh-stagger is still translated: bounding rects
168
164
  // include that travel, its resting place does not.
165
+ // An ancestor mid-zoom (a dialog opening) scales every rect and ends without
166
+ // a resize, so rects convert back to layout pixels by the container's ratio.
167
+ const sx = containerRef.offsetWidth > 0 ? cr.width / containerRef.offsetWidth : 1;
168
+ const sy = containerRef.offsetHeight > 0 ? cr.height / containerRef.offsetHeight : 1;
169
169
  const [tx, ty] = readTranslate(el);
170
170
  setPos(
171
171
  horizontal()
172
172
  ? {
173
- offset: er.left - tx - cr.left - containerRef.clientLeft + containerRef.scrollLeft,
174
- size: er.width,
175
- cross: er.height,
173
+ offset:
174
+ (er.left - cr.left) / sx - tx - containerRef.clientLeft + containerRef.scrollLeft,
175
+ size: er.width / sx,
176
+ cross: er.height / sy,
176
177
  }
177
178
  : {
178
- offset: er.top - ty - cr.top - containerRef.clientTop + containerRef.scrollTop,
179
- size: er.height,
180
- cross: er.width,
179
+ offset: (er.top - cr.top) / sy - ty - containerRef.clientTop + containerRef.scrollTop,
180
+ size: er.height / sy,
181
+ cross: er.width / sx,
181
182
  },
182
183
  );
183
184
  };
@@ -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
+ }
@@ -1,6 +1,6 @@
1
1
  import { type Component, type ComponentProps, createSignal, splitProps } from "solid-js";
2
2
  import { FIELD_CHROME, FOCUS_RING } from "../lib/input-classes.js";
3
- import { THUMB_CLASS } from "../lib/thumb-classes.js";
3
+ import { THUMB_CLASS, THUMB_FACE_ON } from "../lib/thumb-classes.js";
4
4
  import { cn } from "../lib/utils.js";
5
5
 
6
6
  type SwitchProps = Omit<ComponentProps<"button">, "onChange" | "children"> & {
@@ -52,7 +52,10 @@ const Switch: Component<SwitchProps> = (props) => {
52
52
  )}
53
53
  // Off must read quieter than on: the knob dims with the track rather
54
54
  // than staying one bright material in both states.
55
- style={{ background: checked() ? "var(--thumb-face-on)" : "var(--thumb-face-off)" }}
55
+ style={{
56
+ "--thumb-face-on": THUMB_FACE_ON,
57
+ background: checked() ? "var(--thumb-face-on)" : "var(--thumb-face-off)",
58
+ }}
56
59
  />
57
60
  {local.name && <input type="hidden" name={local.name} value={checked() ? "on" : "off"} />}
58
61
  </button>
@@ -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
 
@@ -80,10 +80,7 @@ const ToggleGroupItem: Component<
80
80
  variant: context.variant || local.variant,
81
81
  size: context.size || local.size,
82
82
  }),
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",
83
+ "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",
87
84
  // Single-select: the sliding indicator paints the active segment, so the
88
85
  // item needs no pressed fill of its own and hover only tints the text.
89
86
  // 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>