@glasshome/ui 1.30.0 → 1.31.1
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 +1 -0
- package/dist/solid/index.d.ts +1 -0
- package/dist/solid/index.js +2135 -2108
- package/dist/solid/preview-tile.d.ts +2 -0
- package/dist/solid/source-marks.d.ts +9 -0
- package/package.json +1 -1
- package/src/solid/index.ts +1 -0
- package/src/solid/preview-tile.tsx +8 -4
- package/src/solid/sliding-indicator.tsx +13 -1
- package/src/solid/source-marks.tsx +24 -0
|
@@ -25,6 +25,8 @@ export declare function PreviewTile(props: {
|
|
|
25
25
|
/** Off for pictures that name themselves; the label still reaches assistive tech. */
|
|
26
26
|
caption?: boolean;
|
|
27
27
|
icon?: string;
|
|
28
|
+
/** Beside the caption, after the label: provenance like `SourceMarks`. */
|
|
29
|
+
marks?: JSX.Element;
|
|
28
30
|
shape?: keyof typeof SHAPE;
|
|
29
31
|
disabled?: boolean;
|
|
30
32
|
class?: string;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a catalog item comes from: the official or community mark, plus Built in when it ships with GlassHome.
|
|
3
|
+
* Inside an `@container/source-marks` narrower than 12rem, Built in steps aside so the name keeps its room.
|
|
4
|
+
*/
|
|
5
|
+
export declare function SourceMarks(props: {
|
|
6
|
+
official: boolean;
|
|
7
|
+
builtIn?: boolean;
|
|
8
|
+
class?: string;
|
|
9
|
+
}): import("solid-js").JSX.Element;
|
package/package.json
CHANGED
package/src/solid/index.ts
CHANGED
|
@@ -9,9 +9,10 @@ const COLUMNS = { 2: "grid-cols-2", 3: "grid-cols-3", 4: "grid-cols-4" } as cons
|
|
|
9
9
|
const SHAPE = { wide: "aspect-[16/10]", tile: "aspect-[5/4]" } as const;
|
|
10
10
|
|
|
11
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.
|
|
12
|
+
* the face carries the picked state, the focus ring rides the same edge.
|
|
13
|
+
* Rings are drawn inside the face, above the picture: an outer ring is cut off where a scroll area clips the grid. */
|
|
13
14
|
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
|
|
15
|
+
"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 after:pointer-events-none after:absolute after:inset-0 after:z-10 after:rounded-[inherit] after:ring-inset after:transition-glass group-data-[checked]/preview-tile:after:ring-2 group-data-[checked]/preview-tile:after:ring-primary group-has-[:focus-visible]/preview-tile:after:ring-[3px] group-has-[:focus-visible]/preview-tile:after:ring-ring/50";
|
|
15
16
|
|
|
16
17
|
export function PreviewTileGroup(props: {
|
|
17
18
|
value: string | null;
|
|
@@ -43,6 +44,8 @@ export function PreviewTile(props: {
|
|
|
43
44
|
/** Off for pictures that name themselves; the label still reaches assistive tech. */
|
|
44
45
|
caption?: boolean;
|
|
45
46
|
icon?: string;
|
|
47
|
+
/** Beside the caption, after the label: provenance like `SourceMarks`. */
|
|
48
|
+
marks?: JSX.Element;
|
|
46
49
|
shape?: keyof typeof SHAPE;
|
|
47
50
|
disabled?: boolean;
|
|
48
51
|
class?: string;
|
|
@@ -58,7 +61,7 @@ export function PreviewTile(props: {
|
|
|
58
61
|
showControl={false}
|
|
59
62
|
onClick={() => !props.disabled && props.onPick?.()}
|
|
60
63
|
class={cn(
|
|
61
|
-
"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",
|
|
64
|
+
"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 [&_[data-slot=radio-group-item-label]]:min-w-0",
|
|
62
65
|
props.class,
|
|
63
66
|
)}
|
|
64
67
|
>
|
|
@@ -68,7 +71,7 @@ export function PreviewTile(props: {
|
|
|
68
71
|
<Show when={props.caption ?? true} fallback={<span class="sr-only">{props.label}</span>}>
|
|
69
72
|
<span
|
|
70
73
|
data-slot="preview-tile-caption"
|
|
71
|
-
class="text-foreground flex min-w-0 items-center gap-1 text-xs font-medium"
|
|
74
|
+
class="text-foreground @container/source-marks flex min-w-0 items-center gap-1 text-xs font-medium"
|
|
72
75
|
>
|
|
73
76
|
<Show when={props.icon}>
|
|
74
77
|
{(icon) => (
|
|
@@ -76,6 +79,7 @@ export function PreviewTile(props: {
|
|
|
76
79
|
)}
|
|
77
80
|
</Show>
|
|
78
81
|
<span class="truncate">{props.label}</span>
|
|
82
|
+
{props.marks}
|
|
79
83
|
</span>
|
|
80
84
|
<Show when={props.meta}>
|
|
81
85
|
<span
|
|
@@ -10,6 +10,15 @@ import {
|
|
|
10
10
|
} from "solid-js";
|
|
11
11
|
import { cn } from "../lib/utils.js";
|
|
12
12
|
|
|
13
|
+
function samePos(a: Pos, b: Pos): boolean {
|
|
14
|
+
return (
|
|
15
|
+
a.offset === b.offset &&
|
|
16
|
+
a.size === b.size &&
|
|
17
|
+
a.cross === b.cross &&
|
|
18
|
+
a.crossOffset === b.crossOffset
|
|
19
|
+
);
|
|
20
|
+
}
|
|
21
|
+
|
|
13
22
|
function readTranslate(el: HTMLElement): [number, number] {
|
|
14
23
|
const t = getComputedStyle(el).translate;
|
|
15
24
|
if (!t || t === "none") return [0, 0];
|
|
@@ -117,6 +126,7 @@ export function SlidingIndicator(props: SlidingIndicatorProps) {
|
|
|
117
126
|
let slideTimer: ReturnType<typeof setTimeout> | undefined;
|
|
118
127
|
const place = (el: HTMLElement, next: Pos) => {
|
|
119
128
|
const prev = pos();
|
|
129
|
+
if (prev !== null && measuredEl === el && samePos(prev, next)) return;
|
|
120
130
|
const moved = measuredEl !== undefined && measuredEl !== el && prev !== null;
|
|
121
131
|
measuredEl = el;
|
|
122
132
|
if (moved) {
|
|
@@ -250,7 +260,9 @@ export function SlidingIndicator(props: SlidingIndicatorProps) {
|
|
|
250
260
|
// Attribute-based selection (e.g. Kobalte's [data-selected]/[data-highlighted]):
|
|
251
261
|
// re-slide when the active child's marker attribute moves, or when items are
|
|
252
262
|
// added/removed, so newly-mounted items land under the same observer.
|
|
253
|
-
const mo = new MutationObserver(() => {
|
|
263
|
+
const mo = new MutationObserver((records) => {
|
|
264
|
+
// Own style writes land in this subtree; Chromium up to 131 reports same-value custom property writes.
|
|
265
|
+
if (records.every((record) => record.attributeName === "style")) return;
|
|
254
266
|
syncObservedItems();
|
|
255
267
|
queueMicrotask(measure);
|
|
256
268
|
});
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Show } from "solid-js";
|
|
2
|
+
import { cn } from "../lib/utils.js";
|
|
3
|
+
import { Badge } from "./badge.js";
|
|
4
|
+
import { WidgetTrustBadge } from "./widget-trust-badge.js";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Where a catalog item comes from: the official or community mark, plus Built in when it ships with GlassHome.
|
|
8
|
+
* Inside an `@container/source-marks` narrower than 12rem, Built in steps aside so the name keeps its room.
|
|
9
|
+
*/
|
|
10
|
+
export function SourceMarks(props: { official: boolean; builtIn?: boolean; class?: string }) {
|
|
11
|
+
return (
|
|
12
|
+
<span
|
|
13
|
+
data-slot="source-marks"
|
|
14
|
+
class={cn("inline-flex shrink-0 items-center gap-1.5", props.class)}
|
|
15
|
+
>
|
|
16
|
+
<WidgetTrustBadge isOfficial={props.official} />
|
|
17
|
+
<Show when={props.builtIn}>
|
|
18
|
+
<Badge tone="var(--muted-foreground)" class="@max-[12rem]/source-marks:hidden">
|
|
19
|
+
Built in
|
|
20
|
+
</Badge>
|
|
21
|
+
</Show>
|
|
22
|
+
</span>
|
|
23
|
+
);
|
|
24
|
+
}
|