@glasshome/ui 1.21.0 → 1.21.2
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/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/use-is-mobile.d.ts +3 -1
- package/dist/solid/alert-dialog.d.ts +7 -1
- package/dist/solid/bottom-sheet/bottom-sheet.d.ts +7 -1
- package/dist/solid/dialog-parts.d.ts +3 -2
- package/dist/solid/dialog.d.ts +7 -1
- package/dist/solid/docked-panel.d.ts +7 -1
- package/dist/solid/index.d.ts +9 -9
- package/dist/solid/index.js +5456 -5447
- package/dist/solid/media-store.d.ts +4 -1
- package/dist/solid/option-card.d.ts +4 -1
- package/dist/solid/responsive-dialog.d.ts +7 -1
- package/dist/solid/sheet.d.ts +7 -1
- package/dist/{utils-CMk7R3zM.js → utils-D5blHO4O.js} +624 -622
- package/package.json +128 -126
- package/scripts/check-gallery.ts +142 -142
- package/scripts/check-pack.ts +13 -13
- package/scripts/check-structural-classes.ts +20 -20
- package/scripts/check-tokens.ts +27 -27
- package/scripts/check-ui-drift.mjs +103 -103
- package/src/index.ts +75 -80
- package/src/lib/alert-tones.ts +41 -41
- package/src/lib/anchor-placement.ts +21 -21
- package/src/lib/button-variants.ts +28 -28
- package/src/lib/card-classes.ts +9 -9
- package/src/lib/carousel-classes.ts +14 -14
- package/src/lib/glass-tone.ts +11 -11
- package/src/lib/input-classes.ts +6 -6
- package/src/lib/layers.ts +4 -4
- package/src/lib/logo-lockup.ts +8 -8
- package/src/lib/menu-classes.ts +2 -2
- package/src/lib/motion-classes.ts +8 -8
- package/src/lib/motion-window.ts +24 -24
- package/src/lib/overlay-classes.ts +6 -6
- package/src/lib/pill-classes.ts +3 -3
- package/src/lib/position-bar-classes.ts +1 -1
- package/src/lib/spotlight-geometry.ts +67 -67
- package/src/lib/thumb-classes.ts +2 -2
- package/src/lib/tier-badge.ts +16 -16
- package/src/lib/use-is-mobile.ts +17 -14
- package/src/lib/utils.ts +1 -1
- package/src/solid/accordion.tsx +41 -41
- package/src/solid/alert-dialog.tsx +95 -95
- package/src/solid/alert.tsx +88 -88
- package/src/solid/area-picker.tsx +204 -204
- package/src/solid/aspect-ratio.tsx +13 -13
- package/src/solid/avatar.tsx +27 -27
- package/src/solid/badge.tsx +49 -49
- package/src/solid/bottom-sheet/arbitration.ts +22 -22
- package/src/solid/bottom-sheet/bottom-sheet.tsx +394 -394
- package/src/solid/bottom-sheet/drag-controller.ts +201 -201
- package/src/solid/bottom-sheet/focus-trap.ts +51 -47
- package/src/solid/bottom-sheet/index.ts +12 -12
- package/src/solid/bottom-sheet/keyboard.ts +25 -25
- package/src/solid/bottom-sheet/scroll-lock.ts +46 -46
- package/src/solid/bottom-sheet/state-machine.ts +28 -28
- package/src/solid/bottom-sheet/velocity.ts +29 -29
- package/src/solid/breadcrumb.tsx +76 -76
- package/src/solid/button-group.tsx +46 -46
- package/src/solid/button.tsx +19 -19
- package/src/solid/card.tsx +67 -67
- package/src/solid/carousel.tsx +246 -246
- package/src/solid/charts.tsx +253 -253
- package/src/solid/checkbox.tsx +51 -51
- package/src/solid/collapsible.tsx +22 -22
- package/src/solid/color-disc.tsx +213 -213
- package/src/solid/color-slider.tsx +81 -81
- package/src/solid/color-wheel.tsx +61 -61
- package/src/solid/context-menu.tsx +63 -63
- package/src/solid/copy-button.tsx +31 -31
- package/src/solid/count-pill.tsx +11 -11
- package/src/solid/dashboard-preview.tsx +104 -104
- package/src/solid/data-table.tsx +228 -228
- package/src/solid/dialog-parts.tsx +129 -129
- package/src/solid/dialog.tsx +113 -113
- package/src/solid/dock-paging.ts +9 -9
- package/src/solid/dock.tsx +339 -338
- package/src/solid/docked-panel.tsx +35 -35
- package/src/solid/dropdown-menu.tsx +77 -77
- package/src/solid/empty.tsx +70 -70
- package/src/solid/entity-data.ts +38 -38
- package/src/solid/entity-selector.tsx +634 -634
- package/src/solid/field.tsx +205 -205
- package/src/solid/form.tsx +159 -159
- package/src/solid/hero-action.tsx +85 -85
- package/src/solid/hover-card.tsx +11 -11
- package/src/solid/icon-picker.tsx +401 -401
- package/src/solid/icon.tsx +101 -78
- package/src/solid/image-picker.tsx +416 -414
- package/src/solid/index.ts +265 -304
- package/src/solid/input-group.tsx +123 -123
- package/src/solid/input-otp.tsx +143 -143
- package/src/solid/input.tsx +4 -4
- package/src/solid/item.tsx +130 -130
- package/src/solid/kbd.tsx +20 -20
- package/src/solid/label.tsx +12 -12
- package/src/solid/list-reorder.ts +122 -122
- package/src/solid/logo.tsx +60 -60
- package/src/solid/media-copy.ts +21 -21
- package/src/solid/media-store.ts +60 -57
- package/src/solid/media-tile.tsx +85 -85
- package/src/solid/menu-parts.tsx +164 -164
- package/src/solid/number-field.tsx +56 -56
- package/src/solid/option-card.tsx +168 -165
- package/src/solid/ornament.tsx +43 -43
- package/src/solid/overlay.tsx +4 -4
- package/src/solid/page-header.tsx +75 -75
- package/src/solid/pagination.tsx +80 -80
- package/src/solid/password-input.tsx +51 -51
- package/src/solid/picker-row.tsx +83 -83
- package/src/solid/picker-search.tsx +65 -63
- package/src/solid/picker-trigger.tsx +59 -57
- package/src/solid/popover.tsx +54 -54
- package/src/solid/preview-tile.tsx +67 -67
- package/src/solid/progress.tsx +21 -21
- package/src/solid/radio-group.tsx +51 -51
- package/src/solid/resizable.tsx +128 -128
- package/src/solid/responsive-dialog.tsx +134 -134
- package/src/solid/schema-form.tsx +746 -739
- package/src/solid/scope-indicator.tsx +5 -5
- package/src/solid/scroll-area.tsx +16 -16
- package/src/solid/section-card.tsx +281 -281
- package/src/solid/select.tsx +101 -101
- package/src/solid/separator.tsx +25 -25
- package/src/solid/settings-row.tsx +122 -122
- package/src/solid/sheet.tsx +96 -96
- package/src/solid/skeleton.tsx +8 -8
- package/src/solid/slider.tsx +132 -132
- package/src/solid/sliding-indicator.tsx +280 -265
- package/src/solid/sonner.tsx +164 -164
- package/src/solid/spinner.tsx +12 -12
- package/src/solid/spotlight.tsx +140 -140
- package/src/solid/step-indicator.tsx +18 -18
- package/src/solid/swatch-picker.tsx +38 -38
- package/src/solid/switch.tsx +52 -52
- package/src/solid/table.tsx +63 -63
- package/src/solid/tabs.tsx +93 -93
- package/src/solid/textarea.tsx +8 -8
- package/src/solid/toggle-group.tsx +83 -83
- package/src/solid/toggle.tsx +33 -33
- package/src/solid/tooltip.tsx +16 -16
- package/src/solid/widget-card.tsx +90 -90
- package/src/solid/widget-identity.tsx +99 -99
- package/src/solid/widget-trust-badge.tsx +20 -20
- package/src/styles/globals.css +316 -319
- package/src/styles/theme.css +448 -448
- package/src/tokens/hex.ts +29 -29
- package/src/tokens/material.ts +75 -75
- package/src/tokens/presets.ts +303 -303
- package/src/tokens/readability.ts +32 -32
- package/src/tokens/theme-colors.ts +95 -95
- package/src/tokens/theme-css.ts +22 -22
- package/src/tokens/theme-recipe.ts +106 -106
package/src/solid/charts.tsx
CHANGED
|
@@ -15,29 +15,29 @@ const SLIDER_WELL_RADIUS = "rounded-full";
|
|
|
15
15
|
const SLIDER_FILL = "glass glass-tint [--glass-tone:var(--primary)]";
|
|
16
16
|
|
|
17
17
|
function formatDayLabel(day: string): string {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
// `day` is a "YYYY-MM-DD" UTC key; render as e.g. "Jul 1".
|
|
19
|
+
const d = new Date(`${day}T00:00:00Z`);
|
|
20
|
+
if (Number.isNaN(d.getTime())) return day;
|
|
21
|
+
return d.toLocaleDateString("en-US", { month: "short", day: "numeric", timeZone: "UTC" });
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
export function formatCompact(n: number): string {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
if (!Number.isFinite(n)) return "0";
|
|
26
|
+
if (Math.abs(n) >= 1000) return `${(n / 1000).toFixed(1).replace(/\.0$/, "")}k`;
|
|
27
|
+
return numberFmt.format(n);
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
const BYTE_UNITS: [string, number][] = [
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
["GB", 1024 ** 3],
|
|
32
|
+
["MB", 1024 ** 2],
|
|
33
|
+
["KB", 1024],
|
|
34
34
|
];
|
|
35
35
|
|
|
36
36
|
export function formatBytes(bytes: number): string {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
37
|
+
if (!(bytes > 0)) return "0 KB";
|
|
38
|
+
const [unit, size] = BYTE_UNITS.find(([, s]) => bytes >= s) ?? ["KB", 1024];
|
|
39
|
+
const val = bytes / size;
|
|
40
|
+
return `${val.toFixed(Number(val < 10))} ${unit}`;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
/**
|
|
@@ -49,54 +49,54 @@ const CHART_H = 32;
|
|
|
49
49
|
type ChartGeom = { line: string; area: string; max: number; yFrac: number[] };
|
|
50
50
|
|
|
51
51
|
function chartGeom(data: { count: number }[]): ChartGeom | null {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
52
|
+
if (data.length < 2) return null;
|
|
53
|
+
const max = Math.max(1, ...data.map((p) => p.count));
|
|
54
|
+
const step = 100 / (data.length - 1);
|
|
55
|
+
// yFrac: vertical position as a 0..1 fraction of the box (0 = top), reused by
|
|
56
|
+
// the HTML hover marker so it lines up with the SVG.
|
|
57
|
+
const yFrac = data.map((p) => (CHART_H - 1 - (p.count / max) * (CHART_H - 2)) / CHART_H);
|
|
58
|
+
const coords = data.map(
|
|
59
|
+
(_, i) => `${(i * step).toFixed(2)},${((yFrac[i] ?? 0) * CHART_H).toFixed(2)}`,
|
|
60
|
+
);
|
|
61
|
+
return {
|
|
62
|
+
line: coords.join(" "),
|
|
63
|
+
area: `0,${CHART_H} ${coords.join(" ")} 100,${CHART_H}`,
|
|
64
|
+
max,
|
|
65
|
+
yFrac,
|
|
66
|
+
};
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
/** Guide line + marker dot + tooltip for the hovered point, in HTML space. */
|
|
70
70
|
function ChartHover(props: {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
point: { day: string; count: number };
|
|
72
|
+
leftPct: number;
|
|
73
|
+
topPct: number;
|
|
74
|
+
format?: (n: number) => string;
|
|
75
75
|
}) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
76
|
+
const label = () =>
|
|
77
|
+
props.format ? props.format(props.point.count) : numberFmt.format(props.point.count);
|
|
78
|
+
return (
|
|
79
|
+
<>
|
|
80
|
+
<div
|
|
81
|
+
class="bg-primary/30 pointer-events-none absolute inset-y-0 w-px"
|
|
82
|
+
style={{ left: `${props.leftPct}%` }}
|
|
83
|
+
/>
|
|
84
|
+
<div
|
|
85
|
+
class="border-background bg-primary pointer-events-none absolute size-2 -translate-x-1/2 -translate-y-1/2 rounded-full border"
|
|
86
|
+
style={{ left: `${props.leftPct}%`, top: `${props.topPct}%` }}
|
|
87
|
+
/>
|
|
88
|
+
<Overlay
|
|
89
|
+
class="pointer-events-none absolute z-10 -translate-x-1/2 -translate-y-full px-2 py-1 text-xs whitespace-nowrap"
|
|
90
|
+
style={{
|
|
91
|
+
left: `${Math.min(92, Math.max(8, props.leftPct))}%`,
|
|
92
|
+
top: `${Math.max(0, props.topPct - 6)}%`,
|
|
93
|
+
}}
|
|
94
|
+
>
|
|
95
|
+
<span class="font-mono font-semibold tabular-nums">{label()}</span>
|
|
96
|
+
<span class="text-muted-foreground ml-1">{formatDayLabel(props.point.day)}</span>
|
|
97
|
+
</Overlay>
|
|
98
|
+
</>
|
|
99
|
+
);
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
/**
|
|
@@ -104,87 +104,87 @@ function ChartHover(props: {
|
|
|
104
104
|
* [{day,count}]. Renders a scaling SVG; the caller sizes the container.
|
|
105
105
|
*/
|
|
106
106
|
export function AreaChart(props: {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
107
|
+
data: { day: string; count: number }[];
|
|
108
|
+
class?: string;
|
|
109
|
+
height?: number;
|
|
110
|
+
/** Tooltip value formatter (e.g. formatBytes for a size series). */
|
|
111
|
+
format?: (n: number) => string;
|
|
112
112
|
}) {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
113
|
+
const geom = createMemo(() => chartGeom(props.data));
|
|
114
|
+
const height = () => props.height ?? 48;
|
|
115
|
+
const gid = createUniqueId();
|
|
116
|
+
const [hover, setHover] = createSignal<number | null>(null);
|
|
117
117
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
118
|
+
const onMove = (e: PointerEvent & { currentTarget: HTMLDivElement }) => {
|
|
119
|
+
if (props.data.length < 2) return;
|
|
120
|
+
const rect = e.currentTarget.getBoundingClientRect();
|
|
121
|
+
const ratio = Math.min(1, Math.max(0, (e.clientX - rect.left) / rect.width));
|
|
122
|
+
setHover(Math.round(ratio * (props.data.length - 1)));
|
|
123
|
+
};
|
|
124
124
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
125
|
+
const leftPct = () => {
|
|
126
|
+
const h = hover();
|
|
127
|
+
return h == null ? 0 : (h / (props.data.length - 1)) * 100;
|
|
128
|
+
};
|
|
129
129
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
130
|
+
return (
|
|
131
|
+
<Show
|
|
132
|
+
when={geom()}
|
|
133
|
+
fallback={
|
|
134
|
+
<div
|
|
135
|
+
data-slot="area-chart"
|
|
136
|
+
class={cn("text-muted-foreground flex items-center justify-center text-xs", props.class)}
|
|
137
|
+
style={{ height: `${height()}px` }}
|
|
138
|
+
>
|
|
139
|
+
Not enough data yet
|
|
140
|
+
</div>
|
|
141
|
+
}
|
|
142
|
+
>
|
|
143
|
+
{(g) => (
|
|
144
|
+
<div
|
|
145
|
+
data-slot="area-chart"
|
|
146
|
+
class={cn("relative overflow-hidden rounded-xl px-px", SLIDER_WELL)}
|
|
147
|
+
style={{ height: `${height()}px` }}
|
|
148
|
+
onPointerMove={onMove}
|
|
149
|
+
onPointerLeave={() => setHover(null)}
|
|
150
|
+
>
|
|
151
|
+
<svg
|
|
152
|
+
viewBox="0 0 100 32"
|
|
153
|
+
preserveAspectRatio="none"
|
|
154
|
+
class={cn("text-primary h-full w-full", props.class)}
|
|
155
|
+
role="img"
|
|
156
|
+
aria-label={`Peak ${g().max} per day`}
|
|
157
|
+
>
|
|
158
|
+
<defs>
|
|
159
|
+
<linearGradient id={gid} x1="0" y1="0" x2="0" y2="1">
|
|
160
|
+
<stop offset="0%" stop-color="currentColor" stop-opacity="0.28" />
|
|
161
|
+
<stop offset="100%" stop-color="currentColor" stop-opacity="0" />
|
|
162
|
+
</linearGradient>
|
|
163
|
+
</defs>
|
|
164
|
+
<polygon points={g().area} fill={`url(#${gid})`} />
|
|
165
|
+
<polyline
|
|
166
|
+
points={g().line}
|
|
167
|
+
fill="none"
|
|
168
|
+
stroke="currentColor"
|
|
169
|
+
stroke-width="1.5"
|
|
170
|
+
stroke-linejoin="round"
|
|
171
|
+
vector-effect="non-scaling-stroke"
|
|
172
|
+
/>
|
|
173
|
+
</svg>
|
|
174
|
+
<Show when={hover() != null && props.data[hover() as number]}>
|
|
175
|
+
{(point) => (
|
|
176
|
+
<ChartHover
|
|
177
|
+
point={point()}
|
|
178
|
+
leftPct={leftPct()}
|
|
179
|
+
topPct={(g().yFrac[hover() as number] ?? 0) * 100}
|
|
180
|
+
format={props.format}
|
|
181
|
+
/>
|
|
182
|
+
)}
|
|
183
|
+
</Show>
|
|
184
|
+
</div>
|
|
185
|
+
)}
|
|
186
|
+
</Show>
|
|
187
|
+
);
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
/**
|
|
@@ -192,147 +192,147 @@ export function AreaChart(props: {
|
|
|
192
192
|
* `format` renders the trailing value label (defaults to compact number).
|
|
193
193
|
*/
|
|
194
194
|
export function BarList(props: {
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
195
|
+
items: { label: string; value: number; sublabel?: string; href?: string }[];
|
|
196
|
+
format?: (value: number) => string;
|
|
197
|
+
empty?: string;
|
|
198
198
|
}) {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
199
|
+
const max = createMemo(() => Math.max(1, ...props.items.map((i) => i.value)));
|
|
200
|
+
const fmt = (v: number) => (props.format ? props.format(v) : formatCompact(v));
|
|
201
|
+
return (
|
|
202
|
+
<Show
|
|
203
|
+
when={props.items.length > 0}
|
|
204
|
+
fallback={
|
|
205
|
+
<div data-slot="bar-list" class="text-muted-foreground py-2 text-xs">
|
|
206
|
+
{props.empty ?? "No data"}
|
|
207
|
+
</div>
|
|
208
|
+
}
|
|
209
|
+
>
|
|
210
|
+
<div data-slot="bar-list" class="flex flex-col gap-1.5">
|
|
211
|
+
<For each={props.items}>
|
|
212
|
+
{(item) => {
|
|
213
|
+
const pct = () => `${Math.max(2, (item.value / max()) * 100).toFixed(1)}%`;
|
|
214
|
+
const Row = (
|
|
215
|
+
<div class="group flex items-center gap-2 text-xs">
|
|
216
|
+
<div
|
|
217
|
+
class={cn(
|
|
218
|
+
"relative min-w-0 flex-1 overflow-hidden",
|
|
219
|
+
SLIDER_WELL_RADIUS,
|
|
220
|
+
SLIDER_WELL,
|
|
221
|
+
)}
|
|
222
|
+
>
|
|
223
|
+
<div
|
|
224
|
+
class={cn(
|
|
225
|
+
"absolute inset-y-0 left-0 transition-[width]",
|
|
226
|
+
SLIDER_WELL_RADIUS,
|
|
227
|
+
SLIDER_FILL,
|
|
228
|
+
)}
|
|
229
|
+
style={{ width: pct() }}
|
|
230
|
+
/>
|
|
231
|
+
<div class="relative flex items-center justify-between gap-2 px-2 py-1">
|
|
232
|
+
<span class="truncate">{item.label}</span>
|
|
233
|
+
<Show when={item.sublabel}>
|
|
234
|
+
<span class="text-muted-foreground shrink-0 text-xs">{item.sublabel}</span>
|
|
235
|
+
</Show>
|
|
236
|
+
</div>
|
|
237
|
+
</div>
|
|
238
|
+
<span class="w-12 shrink-0 text-right font-mono tabular-nums">
|
|
239
|
+
{fmt(item.value)}
|
|
240
|
+
</span>
|
|
241
|
+
</div>
|
|
242
|
+
);
|
|
243
|
+
return item.href ? (
|
|
244
|
+
<a href={item.href} class="block hover:opacity-80">
|
|
245
|
+
{Row}
|
|
246
|
+
</a>
|
|
247
|
+
) : (
|
|
248
|
+
Row
|
|
249
|
+
);
|
|
250
|
+
}}
|
|
251
|
+
</For>
|
|
252
|
+
</div>
|
|
253
|
+
</Show>
|
|
254
|
+
);
|
|
255
255
|
}
|
|
256
256
|
|
|
257
257
|
const RANGE_OPTIONS = [
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
258
|
+
{ label: "7d", value: 7 },
|
|
259
|
+
{ label: "30d", value: 30 },
|
|
260
|
+
{ label: "90d", value: 90 },
|
|
261
|
+
{ label: "1y", value: 365 },
|
|
262
262
|
];
|
|
263
263
|
|
|
264
264
|
/** Segmented control for the chart time window — the shipped Tabs (sliding
|
|
265
265
|
* `.glass` primary indicator). Values are numeric days; Tabs speaks strings, so
|
|
266
266
|
* map at the edge. */
|
|
267
267
|
export function RangeToggle(props: { value: number; onChange: (days: number) => void }) {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
268
|
+
return (
|
|
269
|
+
<Tabs value={String(props.value)} onChange={(v) => props.onChange(Number(v))}>
|
|
270
|
+
<TabsList class="w-auto">
|
|
271
|
+
<For each={RANGE_OPTIONS}>
|
|
272
|
+
{(opt) => <TabsTrigger value={String(opt.value)}>{opt.label}</TabsTrigger>}
|
|
273
|
+
</For>
|
|
274
|
+
</TabsList>
|
|
275
|
+
</Tabs>
|
|
276
|
+
);
|
|
277
277
|
}
|
|
278
278
|
|
|
279
279
|
type StackedBarSegment = {
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
280
|
+
label: string;
|
|
281
|
+
value: number;
|
|
282
|
+
/** CSS color driving the segment's own glass tint. */
|
|
283
|
+
tone?: string;
|
|
284
|
+
/** @deprecated pass `tone` instead */
|
|
285
|
+
class?: string;
|
|
286
286
|
};
|
|
287
287
|
|
|
288
288
|
function segmentClass(s: StackedBarSegment) {
|
|
289
|
-
|
|
289
|
+
return cn(s.tone && "glass glass-tint", s.class);
|
|
290
290
|
}
|
|
291
291
|
|
|
292
292
|
function segmentStyle(s: StackedBarSegment) {
|
|
293
|
-
|
|
293
|
+
return s.tone ? { "--glass-tone": s.tone } : undefined;
|
|
294
294
|
}
|
|
295
295
|
|
|
296
296
|
/** Segmented proportion bar (e.g. staleness fresh/aging/stale). */
|
|
297
297
|
export function StackedBar(props: { segments: StackedBarSegment[] }) {
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
298
|
+
const total = createMemo(() => props.segments.reduce((a, s) => a + s.value, 0) || 1);
|
|
299
|
+
return (
|
|
300
|
+
<div data-slot="stacked-bar" class="flex flex-col gap-2">
|
|
301
|
+
<div class={cn("relative flex h-2.5 overflow-hidden", SLIDER_WELL_RADIUS, SLIDER_WELL)}>
|
|
302
|
+
<For each={props.segments}>
|
|
303
|
+
{(s) => (
|
|
304
|
+
<Show when={s.value > 0}>
|
|
305
|
+
<div
|
|
306
|
+
class={segmentClass(s)}
|
|
307
|
+
style={{ width: `${(s.value / total()) * 100}%`, ...segmentStyle(s) }}
|
|
308
|
+
title={`${s.label}: ${s.value}`}
|
|
309
|
+
/>
|
|
310
|
+
</Show>
|
|
311
|
+
)}
|
|
312
|
+
</For>
|
|
313
|
+
{/* re-laid over the opaque segments, which paint above the well's own
|
|
314
314
|
box-shadow, so the filled bar still catches light like glass. */}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
315
|
+
<div
|
|
316
|
+
class={cn(
|
|
317
|
+
"pointer-events-none absolute inset-0 shadow-[inset_0_1px_0_oklch(1_0_0/var(--glass-rim))]",
|
|
318
|
+
SLIDER_WELL_RADIUS,
|
|
319
|
+
)}
|
|
320
|
+
/>
|
|
321
|
+
</div>
|
|
322
|
+
<div class="flex flex-wrap gap-x-3 gap-y-1 text-xs">
|
|
323
|
+
<For each={props.segments}>
|
|
324
|
+
{(s) => (
|
|
325
|
+
<span class="text-muted-foreground inline-flex items-center gap-1.5">
|
|
326
|
+
<span
|
|
327
|
+
class={cn("inline-block size-2 rounded-full", segmentClass(s))}
|
|
328
|
+
style={segmentStyle(s)}
|
|
329
|
+
/>
|
|
330
|
+
{s.label}
|
|
331
|
+
<span class="text-foreground font-mono tabular-nums">{s.value}</span>
|
|
332
|
+
</span>
|
|
333
|
+
)}
|
|
334
|
+
</For>
|
|
335
|
+
</div>
|
|
336
|
+
</div>
|
|
337
|
+
);
|
|
338
338
|
}
|