@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
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { Material } from "./material.js";
|
|
2
2
|
import { findUnreadable, fixReadable } from "./readability.js";
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
type BackgroundConfig,
|
|
5
|
+
clamp,
|
|
6
|
+
deriveDarkFromLight,
|
|
7
|
+
parseOklch,
|
|
8
|
+
resolveThemeColors,
|
|
9
|
+
type ThemeBaseColors,
|
|
10
|
+
type ThemeColors,
|
|
11
|
+
type ThemeColorsConfig,
|
|
12
|
+
toOklch,
|
|
13
13
|
} from "./theme-colors.js";
|
|
14
14
|
|
|
15
15
|
export const RECIPE_VERSION = 1;
|
|
@@ -18,79 +18,79 @@ export const RECIPE_VERSION = 1;
|
|
|
18
18
|
export type GlassTint = "auto" | "cool" | "neutral" | "warm";
|
|
19
19
|
|
|
20
20
|
export const TINT_SURFACES: Record<Exclude<GlassTint, "auto">, string> = {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
cool: "oklch(0.965 0.02 240)",
|
|
22
|
+
neutral: "oklch(0.97 0 0)",
|
|
23
|
+
warm: "oklch(0.965 0.025 75)",
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
type Mode = "light" | "dark";
|
|
27
27
|
|
|
28
28
|
/** What was chosen, never what was computed: a stored theme re-derives on read. */
|
|
29
29
|
export interface ThemeRecipe {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
30
|
+
/** Selects the derivation table, so a change to the math never moves a stored theme. */
|
|
31
|
+
v: typeof RECIPE_VERSION;
|
|
32
|
+
accent: string;
|
|
33
|
+
/** Tint and depth of the ground the glass sits on, as chosen for light. */
|
|
34
|
+
surface: string;
|
|
35
|
+
radius: number;
|
|
36
|
+
background: BackgroundConfig;
|
|
37
|
+
/** Dark is derived from the light result instead of from the seeds. */
|
|
38
|
+
darkLinked: boolean;
|
|
39
|
+
/** Hand-set colors only; everything absent is derived. */
|
|
40
|
+
set: { light: Partial<ThemeColors>; dark: Partial<ThemeColors> };
|
|
41
|
+
/** What the studio's tint choice was; `surface` stays the value the math reads. Absent is a hand-set surface. */
|
|
42
|
+
tint?: GlassTint;
|
|
43
|
+
/** The glass material; absent is Frosted, so no stored theme moved when this arrived. */
|
|
44
|
+
material?: Material;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
interface Step {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
l?: number;
|
|
49
|
+
lTo?: number;
|
|
50
|
+
c?: number;
|
|
51
|
+
cMax?: number;
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
const LADDER_V1: Record<
|
|
55
|
-
|
|
56
|
-
|
|
55
|
+
Mode,
|
|
56
|
+
Record<"ground" | "card" | "border" | "secondary" | "primary" | "accent", Step>
|
|
57
57
|
> = {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
58
|
+
light: {
|
|
59
|
+
ground: {},
|
|
60
|
+
card: { l: 0.015, c: 0.6 },
|
|
61
|
+
border: { l: -0.08, c: 1.2, cMax: 0.06 },
|
|
62
|
+
secondary: { l: -0.035 },
|
|
63
|
+
primary: {},
|
|
64
|
+
accent: { l: 0.05, c: 0.85 },
|
|
65
|
+
},
|
|
66
|
+
dark: {
|
|
67
|
+
ground: { lTo: 0.15, c: 2.6, cMax: 0.07 },
|
|
68
|
+
card: { lTo: 0.19, c: 2.6, cMax: 0.07 },
|
|
69
|
+
border: { lTo: 0.27, c: 2.6, cMax: 0.08 },
|
|
70
|
+
secondary: { lTo: 0.22, c: 2.6, cMax: 0.07 },
|
|
71
|
+
primary: { l: 0.08 },
|
|
72
|
+
accent: { l: 0.12, c: 0.85 },
|
|
73
|
+
},
|
|
74
74
|
};
|
|
75
75
|
|
|
76
76
|
function step(color: string, by: Step): string {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
77
|
+
const parsed = parseOklch(color);
|
|
78
|
+
if (!parsed) return color;
|
|
79
|
+
const l = clamp(by.lTo ?? parsed.l + (by.l ?? 0), 0, 1);
|
|
80
|
+
const c = clamp(parsed.c * (by.c ?? 1), 0, by.cMax ?? 0.4);
|
|
81
|
+
return toOklch(l, c, parsed.h);
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
function baseFromSeeds(recipe: ThemeRecipe, mode: Mode): ThemeBaseColors {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
85
|
+
const ladder = LADDER_V1[mode];
|
|
86
|
+
return {
|
|
87
|
+
background: step(recipe.surface, ladder.ground),
|
|
88
|
+
card: step(recipe.surface, ladder.card),
|
|
89
|
+
border: step(recipe.surface, ladder.border),
|
|
90
|
+
secondary: step(recipe.surface, ladder.secondary),
|
|
91
|
+
primary: step(recipe.accent, ladder.primary),
|
|
92
|
+
accent: step(recipe.accent, ladder.accent),
|
|
93
|
+
};
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
// The accent seed stays as chosen; per mode it lands on the nearest lightness that reads on its ground.
|
|
@@ -98,64 +98,64 @@ const SETTLED: (keyof ThemeColors)[] = ["primary", "ring", "mutedForeground", "d
|
|
|
98
98
|
|
|
99
99
|
/** A derived theme reads well without anyone fixing it: these move to the nearest passing lightness. */
|
|
100
100
|
function settle(colors: ThemeColors): ThemeColors {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
101
|
+
const out = { ...colors };
|
|
102
|
+
const failing = new Set(findUnreadable(out).map((issue) => issue.text));
|
|
103
|
+
for (const key of SETTLED) {
|
|
104
|
+
if (failing.has(key)) out[key] = fixReadable(out, key) ?? out[key];
|
|
105
|
+
}
|
|
106
|
+
return out;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
function derive(recipe: ThemeRecipe): ThemeColorsConfig {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
110
|
+
const lightBase = baseFromSeeds(recipe, "light");
|
|
111
|
+
const light = resolveThemeColors(lightBase, "light");
|
|
112
|
+
const dark = recipe.darkLinked
|
|
113
|
+
? deriveDarkFromLight(lightBase)
|
|
114
|
+
: resolveThemeColors(baseFromSeeds(recipe, "dark"), "dark");
|
|
115
|
+
return { light: settle(light), dark: settle(dark) };
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
export function resolveRecipe(recipe: ThemeRecipe): ThemeColorsConfig {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
119
|
+
const derived = derive(recipe);
|
|
120
|
+
return {
|
|
121
|
+
light: { ...derived.light, ...recipe.set.light },
|
|
122
|
+
dark: { ...derived.dark, ...recipe.set.dark },
|
|
123
|
+
};
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
export function isDerived(recipe: ThemeRecipe, mode: Mode, key: keyof ThemeColors): boolean {
|
|
127
|
-
|
|
127
|
+
return recipe.set[mode][key] === undefined;
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
function differing(from: ThemeColors, stored: ThemeColors): Partial<ThemeColors> {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
131
|
+
const out: Partial<ThemeColors> = {};
|
|
132
|
+
for (const key of Object.keys(stored) as (keyof ThemeColors)[]) {
|
|
133
|
+
if (stored[key] !== from[key]) out[key] = stored[key];
|
|
134
|
+
}
|
|
135
|
+
return out;
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
/** A flat theme (a preset, a legacy row) as a recipe that resolves back to the same 24 colors. */
|
|
139
139
|
export function seedsFromColors(
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
140
|
+
colors: ThemeColorsConfig,
|
|
141
|
+
radius: number,
|
|
142
|
+
background: BackgroundConfig,
|
|
143
143
|
): ThemeRecipe {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
144
|
+
const seeds: ThemeRecipe = {
|
|
145
|
+
v: RECIPE_VERSION,
|
|
146
|
+
accent: colors.light.primary,
|
|
147
|
+
surface: colors.light.background,
|
|
148
|
+
radius,
|
|
149
|
+
background,
|
|
150
|
+
darkLinked: false,
|
|
151
|
+
set: { light: {}, dark: {} },
|
|
152
|
+
};
|
|
153
|
+
const derived = derive(seeds);
|
|
154
|
+
return {
|
|
155
|
+
...seeds,
|
|
156
|
+
set: {
|
|
157
|
+
light: differing(derived.light, colors.light),
|
|
158
|
+
dark: differing(derived.dark, colors.dark),
|
|
159
|
+
},
|
|
160
|
+
};
|
|
161
161
|
}
|