@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.
- package/SPEC.md +82 -1
- package/dist/index.js +2 -2
- package/dist/lib/button-variants.d.ts +3 -0
- package/dist/lib/card-classes.d.ts +4 -4
- package/dist/lib/motion-classes.d.ts +1 -0
- package/dist/lib/overlay-classes.d.ts +4 -2
- package/dist/lib/spotlight-geometry.d.ts +22 -0
- package/dist/solid/button.d.ts +8 -3
- package/dist/solid/dock.d.ts +9 -0
- package/dist/solid/docked-panel.d.ts +11 -0
- package/dist/solid/index.d.ts +6 -2
- package/dist/solid/index.js +4387 -4022
- package/dist/solid/option-card.d.ts +1 -1
- package/dist/solid/preview-tile.d.ts +33 -0
- package/dist/solid/spotlight.d.ts +14 -0
- package/dist/solid/swatch-picker.d.ts +12 -0
- package/dist/solid/tabs.d.ts +4 -1
- package/dist/solid/widget-identity.d.ts +2 -0
- package/dist/tokens/index.d.ts +1 -0
- package/dist/tokens/index.js +336 -118
- package/dist/tokens/material.d.ts +40 -0
- package/dist/tokens/presets.d.ts +3 -0
- package/dist/tokens/theme-colors.d.ts +13 -3
- package/dist/tokens/theme-recipe.d.ts +8 -0
- package/dist/{utils-COITV1s9.js → utils-CV6G6fr8.js} +618 -615
- package/package.json +2 -2
- package/src/lib/button-variants.ts +4 -3
- package/src/lib/card-classes.ts +4 -3
- package/src/lib/motion-classes.ts +5 -0
- package/src/lib/overlay-classes.ts +10 -2
- package/src/lib/spotlight-geometry.ts +90 -0
- package/src/solid/button.tsx +17 -2
- package/src/solid/dock.tsx +67 -9
- package/src/solid/docked-panel.tsx +56 -0
- package/src/solid/hero-action.tsx +2 -2
- package/src/solid/index.ts +11 -2
- package/src/solid/option-card.tsx +25 -31
- package/src/solid/preview-tile.tsx +79 -0
- package/src/solid/radio-group.tsx +7 -2
- package/src/solid/section-card.tsx +4 -2
- package/src/solid/sliding-indicator.tsx +13 -12
- package/src/solid/spotlight.tsx +179 -0
- package/src/solid/swatch-picker.tsx +47 -0
- package/src/solid/tabs.tsx +20 -4
- package/src/solid/toggle-group.tsx +1 -4
- package/src/solid/widget-identity.tsx +3 -1
- package/src/styles/globals.css +166 -14
- package/src/styles/theme.css +13 -0
- package/src/tokens/index.ts +1 -0
- package/src/tokens/material.ts +116 -0
- package/src/tokens/presets.ts +195 -56
- package/src/tokens/theme-colors.ts +15 -3
- package/src/tokens/theme-recipe.ts +18 -4
|
@@ -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}>
|
|
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,
|
|
149
|
-
// portal measured before Kobalte positions it
|
|
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:
|
|
174
|
-
|
|
175
|
-
|
|
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 -
|
|
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
|
+
}
|
package/src/solid/tabs.tsx
CHANGED
|
@@ -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
|
-
|
|
89
|
-
|
|
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
|
-
|
|
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>
|