basalt-ui 1.1.1 → 1.2.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/AGENTS.md +2 -2
- package/CHANGELOG.md +30 -0
- package/README.md +47 -5
- package/agent/rules/basalt-app.md +126 -0
- package/agent/rules/basalt-content.md +3 -1
- package/agent/skills/basalt-app/SKILL.md +28 -7
- package/dist/agent/part-list.d.ts.map +1 -1
- package/dist/agent/part-list.js +17 -7
- package/dist/agent/stick-to-bottom.js +2 -2
- package/dist/agent-chat/thread-detail-panel.d.ts.map +1 -1
- package/dist/agent-chat/thread-detail-panel.js +37 -33
- package/dist/agent-chat/thread-message.d.ts.map +1 -1
- package/dist/agent-chat/thread-message.js +8 -5
- package/dist/agent-chat/thread-outcome-card.js +3 -3
- package/dist/agent-chat/thread-workspace.js +1 -1
- package/dist/charts/primitives/ChartLegend.js +2 -0
- package/dist/charts/primitives/ChartTooltip.js +2 -1
- package/dist/cli/index.d.ts +15 -0
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +29 -7
- package/dist/connectivity/connectivity-indicator.d.ts.map +1 -1
- package/dist/connectivity/connectivity-indicator.js +3 -3
- package/dist/content/article-card.module.css +7 -5
- package/dist/content/article-layout.module.css +16 -12
- package/dist/content/callout.module.css +4 -4
- package/dist/content/code-block.module.css +8 -7
- package/dist/content/guide.module.css +3 -3
- package/dist/content/mermaid.module.css +2 -2
- package/dist/content/prose.module.css +59 -29
- package/dist/content/reading-progress.module.css +2 -0
- package/dist/content/toc.module.css +6 -3
- package/dist/dashboard/delta-badge.d.ts.map +1 -1
- package/dist/dashboard/delta-badge.js +10 -2
- package/dist/dashboard/empty-state.d.ts.map +1 -1
- package/dist/dashboard/empty-state.js +3 -16
- package/dist/dashboard/settings-section.js +2 -2
- package/dist/dashboard/settings-section.module.css +2 -2
- package/dist/dashboard/stat-card.js +2 -1
- package/dist/data/virtual-list.d.ts.map +1 -1
- package/dist/data/virtual-list.js +12 -2
- package/dist/forms/FormErrorSummary.js +2 -2
- package/dist/guard/index.d.ts +20 -4
- package/dist/guard/index.d.ts.map +1 -1
- package/dist/guard/index.js +250 -37
- package/dist/guard/types.d.ts +24 -3
- package/dist/guard/types.d.ts.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/provider/index.d.ts +30 -1
- package/dist/provider/index.d.ts.map +1 -1
- package/dist/provider/index.js +32 -7
- package/dist/provider/lab-theme.d.ts +39 -0
- package/dist/provider/lab-theme.d.ts.map +1 -0
- package/dist/provider/lab-theme.js +52 -0
- package/dist/shell/app-header.module.css +2 -2
- package/dist/shell/app-mobile-nav.module.css +1 -1
- package/dist/shell/app-sidebar-account.d.ts.map +1 -1
- package/dist/shell/app-sidebar-account.js +4 -2
- package/dist/shell/app-sidebar.d.ts.map +1 -1
- package/dist/shell/app-sidebar.js +4 -2
- package/dist/shell/app-sidebar.module.css +36 -26
- package/dist/shell/index.d.ts.map +1 -1
- package/dist/shell/index.js +11 -4
- package/dist/shell/sidebar-search.module.css +16 -4
- package/dist/styles.css +1 -1
- package/dist/surfaces.d.ts +15 -11
- package/dist/surfaces.d.ts.map +1 -1
- package/dist/surfaces.js +4 -3
- package/dist/theme/controls.module.css +1 -1
- package/dist/theme/floating.module.css +1 -1
- package/dist/theme/index.d.ts +116 -11
- package/dist/theme/index.d.ts.map +1 -1
- package/dist/theme/index.js +703 -566
- package/dist/theme/nav-link.module.css +1 -1
- package/dist/theme/use-basalt-spacing.d.ts +3 -0
- package/dist/theme/use-basalt-spacing.d.ts.map +1 -0
- package/dist/theme/use-basalt-spacing.js +8 -0
- package/dist/theme-lab/derive-controls.d.ts +13 -0
- package/dist/theme-lab/derive-controls.d.ts.map +1 -0
- package/dist/theme-lab/derive-controls.js +137 -0
- package/dist/theme-lab/derive-state.d.ts +55 -0
- package/dist/theme-lab/derive-state.d.ts.map +1 -0
- package/dist/theme-lab/derive-state.js +81 -0
- package/dist/theme-lab/index.d.ts +12 -2
- package/dist/theme-lab/index.d.ts.map +1 -1
- package/dist/theme-lab/index.js +13 -62
- package/dist/theme-toggle/index.d.ts.map +1 -1
- package/dist/theme-toggle/index.js +3 -2
- package/dist/tokens/derive.d.ts +89 -0
- package/dist/tokens/derive.d.ts.map +1 -0
- package/dist/tokens/derive.js +250 -0
- package/dist/tokens/hct.d.ts +34 -0
- package/dist/tokens/hct.d.ts.map +1 -0
- package/dist/tokens/hct.js +159 -0
- package/dist/tokens/index.d.ts +71 -7
- package/dist/tokens/index.d.ts.map +1 -1
- package/dist/tokens/index.js +284 -46
- package/dist/tokens/palette.d.ts +984 -167
- package/dist/tokens/palette.d.ts.map +1 -1
- package/dist/tokens/palette.js +617 -119
- package/dist/vite-color-mix.d.ts +30 -0
- package/dist/vite-color-mix.d.ts.map +1 -0
- package/dist/vite-color-mix.js +80 -0
- package/dist/vite.d.ts +82 -1
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js +312 -0
- package/llms.txt +5 -4
- package/package.json +24 -9
- package/src/agent/part-list.tsx +13 -7
- package/src/agent/stick-to-bottom.tsx +2 -2
- package/src/agent-chat/thread-detail-panel.tsx +13 -10
- package/src/agent-chat/thread-message.tsx +8 -5
- package/src/agent-chat/thread-outcome-card.tsx +2 -2
- package/src/agent-chat/thread-workspace.tsx +2 -2
- package/src/charts/primitives/ChartLegend.tsx +2 -2
- package/src/charts/primitives/ChartTooltip.tsx +2 -2
- package/src/cli/check-theme.test.ts +18 -0
- package/src/cli/index.ts +55 -5
- package/src/connectivity/connectivity-indicator.tsx +8 -2
- package/src/content/article-card.module.css +7 -5
- package/src/content/article-layout.module.css +16 -12
- package/src/content/callout.module.css +4 -4
- package/src/content/code-block.module.css +8 -7
- package/src/content/guide.module.css +3 -3
- package/src/content/mermaid.module.css +2 -2
- package/src/content/prose.module.css +59 -29
- package/src/content/prose.module.css.test.ts +55 -0
- package/src/content/reading-progress.module.css +2 -0
- package/src/content/toc.module.css +6 -3
- package/src/dashboard/delta-badge.tsx +10 -4
- package/src/dashboard/empty-state.tsx +3 -16
- package/src/dashboard/settings-section.module.css +2 -2
- package/src/dashboard/settings-section.tsx +2 -2
- package/src/dashboard/stat-card.tsx +2 -2
- package/src/data/virtual-list.tsx +12 -2
- package/src/forms/FormErrorSummary.tsx +1 -1
- package/src/guard/check-source.test.ts +416 -5
- package/src/guard/index.ts +367 -45
- package/src/guard/types.ts +24 -2
- package/src/index.ts +1 -0
- package/src/provider/index.test.tsx +100 -0
- package/src/provider/index.tsx +79 -7
- package/src/provider/lab-theme.test.ts +147 -0
- package/src/provider/lab-theme.ts +166 -0
- package/src/shell/app-header.module.css +2 -2
- package/src/shell/app-mobile-nav.module.css +1 -1
- package/src/shell/app-sidebar-account.tsx +9 -2
- package/src/shell/app-sidebar.module.css +36 -26
- package/src/shell/app-sidebar.tsx +12 -2
- package/src/shell/index.tsx +14 -3
- package/src/shell/sidebar-search.module.css +16 -4
- package/src/styles.css +1 -1
- package/src/surfaces.ts +17 -10
- package/src/theme/contrast.test.ts +19 -3
- package/src/theme/controls.module.css +1 -1
- package/src/theme/density-option.test.ts +96 -0
- package/src/theme/density-relations.test.ts +428 -0
- package/src/theme/derive-theme.test.ts +101 -0
- package/src/theme/floating.module.css +1 -1
- package/src/theme/fonts-option.test.ts +69 -0
- package/src/theme/index.ts +930 -563
- package/src/theme/nav-link.module.css +1 -1
- package/src/theme/radius-option.test.ts +86 -0
- package/src/theme/radius.test.ts +132 -0
- package/src/theme/spacing.test.ts +432 -0
- package/src/theme/use-basalt-spacing.test.tsx +51 -0
- package/src/theme/use-basalt-spacing.ts +38 -0
- package/src/theme-lab/derive-controls.test.ts +94 -0
- package/src/theme-lab/derive-controls.tsx +227 -0
- package/src/theme-lab/derive-state.test.ts +71 -0
- package/src/theme-lab/derive-state.ts +163 -0
- package/src/theme-lab/index.tsx +29 -68
- package/src/theme-lab/theme-lab.test.ts +4 -18
- package/src/theme-toggle/index.tsx +9 -4
- package/src/tokens/build-fonts-css.test.ts +51 -0
- package/src/tokens/build-radius-css.test.ts +25 -0
- package/src/tokens/density.test.ts +274 -0
- package/src/tokens/derive-radius.test.ts +62 -0
- package/src/tokens/derive.test.ts +30 -0
- package/src/tokens/derive.ts +481 -0
- package/src/tokens/hct.ts +231 -0
- package/src/tokens/index.ts +395 -45
- package/src/tokens/palette.test.ts +114 -0
- package/src/tokens/palette.ts +1118 -180
- package/src/vite-color-mix.test.ts +46 -0
- package/src/vite-color-mix.ts +137 -0
- package/src/vite.test.ts +192 -0
- package/src/vite.ts +502 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-basalt-spacing.d.ts","sourceRoot":"","sources":["../../src/theme/use-basalt-spacing.ts"],"names":[],"mappings":"AAiCA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAEpD,wBAAgB,gBAAgB,IAAI,WAAW,CAE9C"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
export { DEFAULT_STATE, parsePersistedDeriveState, type PersistedDeriveState } from './derive-state.js';
|
|
3
|
+
export type DeriveControlsProps = {
|
|
4
|
+
/** Icon for the "Reset" action. Passed as a node — the framework ships no icon dep. */
|
|
5
|
+
resetIcon?: ReactNode;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* The derive-config panel — accent seed, neutral family, light/dark surface levels, vibrancy, and
|
|
9
|
+
* accent brightness, with an "Apply" switch and a "Reset" action. See the module doc comment for
|
|
10
|
+
* the dev-vs-production split.
|
|
11
|
+
*/
|
|
12
|
+
export declare function DeriveControls({ resetIcon }: DeriveControlsProps): import("react").JSX.Element;
|
|
13
|
+
//# sourceMappingURL=derive-controls.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"derive-controls.d.ts","sourceRoot":"","sources":["../../src/theme-lab/derive-controls.tsx"],"names":[],"mappings":"AA8DA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAiBtC,OAAO,EAAE,aAAa,EAAE,yBAAyB,EAAE,KAAK,oBAAoB,EAAE,MAAM,gBAAgB,CAAA;AAiDpG,MAAM,MAAM,mBAAmB,GAAG;IAChC,uFAAuF;IACvF,SAAS,CAAC,EAAE,SAAS,CAAA;CACtB,CAAA;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,EAAE,SAAS,EAAE,EAAE,mBAAmB,+BAwFhE"}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import {
|
|
3
|
+
Button,
|
|
4
|
+
ColorInput,
|
|
5
|
+
Group,
|
|
6
|
+
SegmentedControl,
|
|
7
|
+
Slider,
|
|
8
|
+
Stack,
|
|
9
|
+
Switch,
|
|
10
|
+
Text
|
|
11
|
+
} from "@mantine/core";
|
|
12
|
+
import { useEffect, useState } from "react";
|
|
13
|
+
import { buildDensityCss, buildPaletteCss, buildRadiusCss } from "../tokens/index.js";
|
|
14
|
+
import { buildPaletteData, deriveRadius, deriveSpacing } from "../tokens/palette.js";
|
|
15
|
+
import {
|
|
16
|
+
DEFAULT_STATE,
|
|
17
|
+
NEUTRAL_OPTIONS,
|
|
18
|
+
isAccentHex,
|
|
19
|
+
readAppliedDeriveOverride,
|
|
20
|
+
toDeriveOverride,
|
|
21
|
+
useDeriveControlsState
|
|
22
|
+
} from "./derive-state.js";
|
|
23
|
+
import { DEFAULT_STATE as DEFAULT_STATE2, parsePersistedDeriveState } from "./derive-state.js";
|
|
24
|
+
const STYLE_TAG_ID = "basalt-derive-controls-style";
|
|
25
|
+
const LEVEL_MARKS = [-5, 0, 5].map((v) => ({ value: v, label: String(v) }));
|
|
26
|
+
const DENSITY_LEVEL_MARKS = [-3, 0, 3].map((v) => ({ value: v, label: String(v) }));
|
|
27
|
+
const LEVEL_SLIDERS = [
|
|
28
|
+
["lightLevel", "Light level"],
|
|
29
|
+
["darkLevel", "Dark level"],
|
|
30
|
+
["vibrancy", "Vibrancy"],
|
|
31
|
+
["accentBrightness", "Brightness"],
|
|
32
|
+
["radius", "Radius"],
|
|
33
|
+
["density", "Density"]
|
|
34
|
+
];
|
|
35
|
+
function applyDeriveOverride(override) {
|
|
36
|
+
if (override === null) {
|
|
37
|
+
document.getElementById(STYLE_TAG_ID)?.remove();
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
let styleEl = document.getElementById(STYLE_TAG_ID);
|
|
41
|
+
if (!styleEl) {
|
|
42
|
+
styleEl = document.createElement("style");
|
|
43
|
+
styleEl.id = STYLE_TAG_ID;
|
|
44
|
+
document.body.appendChild(styleEl);
|
|
45
|
+
}
|
|
46
|
+
const paletteCss = buildPaletteCss(void 0, buildPaletteData(override.config));
|
|
47
|
+
const radiusCss = buildRadiusCss(deriveRadius(override.radiusLevel));
|
|
48
|
+
const densityCss = buildDensityCss(deriveSpacing(override.densityLevel));
|
|
49
|
+
styleEl.textContent = `${paletteCss}
|
|
50
|
+
${radiusCss}
|
|
51
|
+
${densityCss}`;
|
|
52
|
+
}
|
|
53
|
+
if (typeof document !== "undefined") {
|
|
54
|
+
applyDeriveOverride(readAppliedDeriveOverride());
|
|
55
|
+
}
|
|
56
|
+
function DeriveControls({ resetIcon }) {
|
|
57
|
+
const [state, setState] = useDeriveControlsState();
|
|
58
|
+
const [accentDraft, setAccentDraft] = useState(state.accent);
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
setAccentDraft(state.accent);
|
|
61
|
+
}, [state.accent]);
|
|
62
|
+
const handleAccentChange = (value) => {
|
|
63
|
+
setAccentDraft(value);
|
|
64
|
+
if (isAccentHex(value)) setState({ ...state, accent: value });
|
|
65
|
+
};
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
applyDeriveOverride(toDeriveOverride(state));
|
|
68
|
+
}, [state]);
|
|
69
|
+
const reset = () => setState(DEFAULT_STATE);
|
|
70
|
+
return /* @__PURE__ */ jsxs(Stack, { gap: "sm", children: [
|
|
71
|
+
/* @__PURE__ */ jsx(
|
|
72
|
+
ColorInput,
|
|
73
|
+
{
|
|
74
|
+
size: "xs",
|
|
75
|
+
format: "hex",
|
|
76
|
+
label: "Accent seed",
|
|
77
|
+
value: accentDraft,
|
|
78
|
+
onChange: handleAccentChange
|
|
79
|
+
}
|
|
80
|
+
),
|
|
81
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
82
|
+
/* @__PURE__ */ jsx(Text, { size: "xs", fw: 500, mb: 4, children: "Neutral family" }),
|
|
83
|
+
/* @__PURE__ */ jsx(
|
|
84
|
+
SegmentedControl,
|
|
85
|
+
{
|
|
86
|
+
size: "xs",
|
|
87
|
+
fullWidth: true,
|
|
88
|
+
"aria-label": "Neutral family",
|
|
89
|
+
value: state.neutral,
|
|
90
|
+
onChange: (neutral) => setState({ ...state, neutral }),
|
|
91
|
+
data: NEUTRAL_OPTIONS
|
|
92
|
+
}
|
|
93
|
+
)
|
|
94
|
+
] }),
|
|
95
|
+
LEVEL_SLIDERS.map(([key, label]) => {
|
|
96
|
+
const isDensity = key === "density";
|
|
97
|
+
return /* @__PURE__ */ jsxs("div", { children: [
|
|
98
|
+
/* @__PURE__ */ jsxs(Text, { size: "xs", fw: 500, mb: 4, children: [
|
|
99
|
+
label,
|
|
100
|
+
" (",
|
|
101
|
+
state[key],
|
|
102
|
+
")"
|
|
103
|
+
] }),
|
|
104
|
+
/* @__PURE__ */ jsx(
|
|
105
|
+
Slider,
|
|
106
|
+
{
|
|
107
|
+
size: "xs",
|
|
108
|
+
min: isDensity ? -3 : -5,
|
|
109
|
+
max: isDensity ? 3 : 5,
|
|
110
|
+
step: 1,
|
|
111
|
+
"aria-label": label,
|
|
112
|
+
value: state[key],
|
|
113
|
+
onChange: (v) => setState({ ...state, [key]: v }),
|
|
114
|
+
marks: isDensity ? DENSITY_LEVEL_MARKS : LEVEL_MARKS
|
|
115
|
+
}
|
|
116
|
+
)
|
|
117
|
+
] }, key);
|
|
118
|
+
}),
|
|
119
|
+
/* @__PURE__ */ jsxs(Group, { justify: "space-between", mt: "xs", children: [
|
|
120
|
+
/* @__PURE__ */ jsx(
|
|
121
|
+
Switch,
|
|
122
|
+
{
|
|
123
|
+
size: "sm",
|
|
124
|
+
label: "Apply",
|
|
125
|
+
checked: state.applied,
|
|
126
|
+
onChange: (e) => setState({ ...state, applied: e.currentTarget.checked })
|
|
127
|
+
}
|
|
128
|
+
),
|
|
129
|
+
/* @__PURE__ */ jsx(Button, { size: "compact-xs", variant: "default", leftSection: resetIcon, onClick: reset, children: "Reset" })
|
|
130
|
+
] })
|
|
131
|
+
] });
|
|
132
|
+
}
|
|
133
|
+
export {
|
|
134
|
+
DEFAULT_STATE2 as DEFAULT_STATE,
|
|
135
|
+
DeriveControls,
|
|
136
|
+
parsePersistedDeriveState
|
|
137
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { DeriveConfig } from '../tokens/derive.js';
|
|
2
|
+
/** Neutral-family choices — plain label/value data, rendered by the panel's `SegmentedControl`. */
|
|
3
|
+
export declare const NEUTRAL_OPTIONS: {
|
|
4
|
+
label: string;
|
|
5
|
+
value: string;
|
|
6
|
+
}[];
|
|
7
|
+
/** A full 3- or 6-digit hex — the gate a `ColorInput` keystroke must clear before it reaches state. */
|
|
8
|
+
export declare const isAccentHex: (value: string) => boolean;
|
|
9
|
+
/** Exported for `derive-controls.test.ts` — the v2→v3 migration test needs the shape + default. */
|
|
10
|
+
export type PersistedDeriveState = DeriveConfig & {
|
|
11
|
+
applied: boolean;
|
|
12
|
+
radius: number;
|
|
13
|
+
density: number;
|
|
14
|
+
};
|
|
15
|
+
export declare const DEFAULT_STATE: PersistedDeriveState;
|
|
16
|
+
/**
|
|
17
|
+
* Validate + normalize a persisted envelope, or return null if it is unusable. Exported for
|
|
18
|
+
* `derive-controls.test.ts` — the pure, headless seam to test the v1→v2 migration through: no DOM
|
|
19
|
+
* render harness is configured in this package (see `../provider/build-fonts-css.test.ts`), so
|
|
20
|
+
* `createPersistedState`'s full localStorage round-trip isn't reachable from a unit test, but this
|
|
21
|
+
* is exactly the validator `parseStorage` (`../state`) falls back to `initial` from on a rejection
|
|
22
|
+
* (this module passes no `migrate`, so a v1 envelope — pre-radius — hits this same rejection path).
|
|
23
|
+
*/
|
|
24
|
+
export declare function parsePersistedDeriveState(value: unknown): PersistedDeriveState | null;
|
|
25
|
+
/**
|
|
26
|
+
* The persisted-state hook. ONE module-scoped store (see `createPersistedState`), so the panel and
|
|
27
|
+
* `BasaltProvider` subscribe to the SAME instance — dragging a slider notifies both in the same
|
|
28
|
+
* tick, which is what keeps the injected CSS and the rebuilt theme object from ever disagreeing.
|
|
29
|
+
*/
|
|
30
|
+
export declare const useDeriveControlsState: () => readonly [PersistedDeriveState, (next: PersistedDeriveState) => void];
|
|
31
|
+
/**
|
|
32
|
+
* An ACTIVE lab override — the resolved color config plus the two integer levels. Both consumers
|
|
33
|
+
* (the `<style>` injection and the theme rebuild) take this exact bundle, so they can never drift
|
|
34
|
+
* apart on which config is live.
|
|
35
|
+
*/
|
|
36
|
+
export type DeriveOverride = {
|
|
37
|
+
config: DeriveConfig;
|
|
38
|
+
radiusLevel: number;
|
|
39
|
+
densityLevel: number;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* The live override for a state value, or `null` when the "Apply" switch is off.
|
|
43
|
+
*
|
|
44
|
+
* Builds the `DeriveConfig` from the six knobs EXPLICITLY rather than spreading the whole state —
|
|
45
|
+
* `resolveDeriveConfig` is a plain spread, so handing it the persisted state would carry
|
|
46
|
+
* `applied`/`radius`/`density` into the config object (and from there onto
|
|
47
|
+
* `theme.other.basaltDerive`) as junk keys.
|
|
48
|
+
*/
|
|
49
|
+
export declare function toDeriveOverride(state: PersistedDeriveState): DeriveOverride | null;
|
|
50
|
+
/**
|
|
51
|
+
* Read the active override straight from localStorage, outside React — the chunk-load path, before
|
|
52
|
+
* any component mounts. Fully validated by {@link parsePersistedDeriveState}, so it cannot throw.
|
|
53
|
+
*/
|
|
54
|
+
export declare function readAppliedDeriveOverride(): DeriveOverride | null;
|
|
55
|
+
//# sourceMappingURL=derive-state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"derive-state.d.ts","sourceRoot":"","sources":["../../src/theme-lab/derive-state.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AASpD,mGAAmG;AACnG,eAAO,MAAM,eAAe;;;GAK3B,CAAA;AAKD,uGAAuG;AACvG,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,KAAG,OAA6B,CAAA;AAEzE,mGAAmG;AACnG,MAAM,MAAM,oBAAoB,GAAG,YAAY,GAAG;IAChD,OAAO,EAAE,OAAO,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,CAAA;CAChB,CAAA;AAED,eAAO,MAAM,aAAa,EAAE,oBAK3B,CAAA;AAWD;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,OAAO,GAAG,oBAAoB,GAAG,IAAI,CA2BrF;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,6EAgBjC,CAAA;AAEF;;;;GAIG;AACH,MAAM,MAAM,cAAc,GAAG;IAAE,MAAM,EAAE,YAAY,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,CAAA;AAEhG;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,oBAAoB,GAAG,cAAc,GAAG,IAAI,CAcnF;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,IAAI,cAAc,GAAG,IAAI,CAGjE"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { createPersistedState, readPersistedValue } from "../state.js";
|
|
2
|
+
import { DEFAULT_DERIVE_CONFIG, resolveDeriveConfig } from "../tokens/derive.js";
|
|
3
|
+
const STORAGE_KEY = "theme-lab-derive";
|
|
4
|
+
const STORAGE_VERSION = 4;
|
|
5
|
+
const NEUTRAL_OPTIONS = [
|
|
6
|
+
{ label: "Zinc", value: "zinc" },
|
|
7
|
+
{ label: "Neutral", value: "neutral" },
|
|
8
|
+
{ label: "Stone", value: "stone" },
|
|
9
|
+
{ label: "Slate", value: "slate" }
|
|
10
|
+
];
|
|
11
|
+
const NEUTRAL_VALUES = new Set(NEUTRAL_OPTIONS.map((o) => o.value));
|
|
12
|
+
const HEX_RE = /^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i;
|
|
13
|
+
const isAccentHex = (value) => HEX_RE.test(value);
|
|
14
|
+
const DEFAULT_STATE = {
|
|
15
|
+
...DEFAULT_DERIVE_CONFIG,
|
|
16
|
+
applied: false,
|
|
17
|
+
radius: 0,
|
|
18
|
+
density: 0
|
|
19
|
+
};
|
|
20
|
+
const isLevel = (v) => typeof v === "number" && Number.isInteger(v) && v >= -5 && v <= 5;
|
|
21
|
+
const isDensityLevel = (v) => typeof v === "number" && Number.isInteger(v) && v >= -3 && v <= 3;
|
|
22
|
+
function parsePersistedDeriveState(value) {
|
|
23
|
+
if (typeof value !== "object" || value === null) return null;
|
|
24
|
+
const v = value;
|
|
25
|
+
const valid = typeof v["accent"] === "string" && HEX_RE.test(v["accent"]) && typeof v["neutral"] === "string" && NEUTRAL_VALUES.has(v["neutral"]) && isLevel(v["lightLevel"]) && isLevel(v["darkLevel"]) && isLevel(v["vibrancy"]) && isLevel(v["accentBrightness"]) && isLevel(v["radius"]) && isDensityLevel(v["density"]) && typeof v["applied"] === "boolean";
|
|
26
|
+
if (!valid) return null;
|
|
27
|
+
return {
|
|
28
|
+
accent: v["accent"],
|
|
29
|
+
neutral: v["neutral"],
|
|
30
|
+
lightLevel: v["lightLevel"],
|
|
31
|
+
darkLevel: v["darkLevel"],
|
|
32
|
+
vibrancy: v["vibrancy"],
|
|
33
|
+
accentBrightness: v["accentBrightness"],
|
|
34
|
+
radius: v["radius"],
|
|
35
|
+
density: v["density"],
|
|
36
|
+
applied: v["applied"]
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
const useDeriveControlsState = createPersistedState({
|
|
40
|
+
key: STORAGE_KEY,
|
|
41
|
+
version: STORAGE_VERSION,
|
|
42
|
+
initial: DEFAULT_STATE,
|
|
43
|
+
schema: {
|
|
44
|
+
"~standard": {
|
|
45
|
+
version: 1,
|
|
46
|
+
vendor: "basalt-derive-controls",
|
|
47
|
+
validate: (value) => {
|
|
48
|
+
const parsed = parsePersistedDeriveState(value);
|
|
49
|
+
return parsed !== null ? { value: parsed } : { issues: [{ message: "invalid persisted derive-controls state" }] };
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
function toDeriveOverride(state) {
|
|
55
|
+
if (!state.applied) return null;
|
|
56
|
+
return {
|
|
57
|
+
config: resolveDeriveConfig({
|
|
58
|
+
accent: state.accent,
|
|
59
|
+
neutral: state.neutral,
|
|
60
|
+
lightLevel: state.lightLevel,
|
|
61
|
+
darkLevel: state.darkLevel,
|
|
62
|
+
vibrancy: state.vibrancy,
|
|
63
|
+
accentBrightness: state.accentBrightness
|
|
64
|
+
}),
|
|
65
|
+
radiusLevel: state.radius,
|
|
66
|
+
densityLevel: state.density
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function readAppliedDeriveOverride() {
|
|
70
|
+
const persisted = parsePersistedDeriveState(readPersistedValue(STORAGE_KEY, STORAGE_VERSION));
|
|
71
|
+
return persisted === null ? null : toDeriveOverride(persisted);
|
|
72
|
+
}
|
|
73
|
+
export {
|
|
74
|
+
DEFAULT_STATE,
|
|
75
|
+
NEUTRAL_OPTIONS,
|
|
76
|
+
isAccentHex,
|
|
77
|
+
parsePersistedDeriveState,
|
|
78
|
+
readAppliedDeriveOverride,
|
|
79
|
+
toDeriveOverride,
|
|
80
|
+
useDeriveControlsState
|
|
81
|
+
};
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
|
+
export { DeriveControls } from './derive-controls.js';
|
|
3
|
+
export type { DeriveControlsProps } from './derive-controls.js';
|
|
2
4
|
export type ColorTunable = {
|
|
3
5
|
var: string;
|
|
4
6
|
label: string;
|
|
@@ -12,8 +14,16 @@ export type Overrides = Record<string, string>;
|
|
|
12
14
|
export declare const AREA_TOP_VAR = "--vx-area-top";
|
|
13
15
|
export declare const AREA_BOTTOM_VAR = "--vx-area-bottom";
|
|
14
16
|
/**
|
|
15
|
-
*
|
|
16
|
-
* so `rgba()`/`color-mix()` chrome
|
|
17
|
+
* Structural `--vx-*` vars worth tuning by eye — the ones `tokens/palette.ts` hand-authors and
|
|
18
|
+
* that never move with the derive config (ColorInput is hex-only, so `rgba()`/`color-mix()` chrome
|
|
19
|
+
* vars like `--vx-axis` / `--vx-grid` are intentionally omitted regardless).
|
|
20
|
+
*
|
|
21
|
+
* Identity/color tuning lives exclusively in {@link DeriveControls} (one accent seed + bounded
|
|
22
|
+
* knobs, `tokens/derive.ts`) — every `--vx-*` var GENERATED from that config (the accent family,
|
|
23
|
+
* the 12 categorical fills, the ink ramp, most of the surface stops, the `good`/`warn`/`bad`
|
|
24
|
+
* status/semantic hues) has been pruned from here on purpose: hand-tuning a hex the derive engine
|
|
25
|
+
* regenerates on every render is a dead knob. What remains is a low-level inspector for the
|
|
26
|
+
* genuinely NON-derived structural tokens only.
|
|
17
27
|
*
|
|
18
28
|
* Generic by design: argo's domain series (Health / Strength / Walking) are NOT shipped — a
|
|
19
29
|
* consumer passes its own series groups to {@link ThemeLabControls} via the `groups` prop.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/theme-lab/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/theme-lab/index.tsx"],"names":[],"mappings":"AAyCA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AA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|
package/dist/theme-lab/index.js
CHANGED
|
@@ -13,87 +13,37 @@ import {
|
|
|
13
13
|
Tooltip
|
|
14
14
|
} from "@mantine/core";
|
|
15
15
|
import { useState } from "react";
|
|
16
|
-
import { BP
|
|
16
|
+
import { BP } from "../tokens/palette.js";
|
|
17
17
|
import { VX } from "../tokens/index.js";
|
|
18
|
-
|
|
18
|
+
import { DeriveControls } from "./derive-controls.js";
|
|
19
19
|
const AREA_TOP_VAR = "--vx-area-top";
|
|
20
20
|
const AREA_BOTTOM_VAR = "--vx-area-bottom";
|
|
21
21
|
const COLOR_GROUPS = [
|
|
22
22
|
{
|
|
23
|
-
//
|
|
24
|
-
//
|
|
25
|
-
//
|
|
26
|
-
|
|
27
|
-
// onto it (theme/index.ts). `On accent` is the label ON that fill — the theme cannot recompute
|
|
28
|
-
// contrast in CSS, so if you tune `Fill` light, drop `On accent` to a dark ink yourself.
|
|
29
|
-
title: "Accent",
|
|
30
|
-
items: [
|
|
31
|
-
{ var: "--vx-accent", label: "Accent (ink)" },
|
|
32
|
-
{ var: "--vx-accentHover", label: "Accent hover" },
|
|
33
|
-
{ var: "--vx-accentFill", label: "Fill" },
|
|
34
|
-
{ var: "--vx-accentFillHover", label: "Fill hover" },
|
|
35
|
-
{ var: "--vx-onAccent", label: "On accent" }
|
|
36
|
-
]
|
|
37
|
-
},
|
|
38
|
-
{
|
|
39
|
-
// Every filled surface in the Mantine chrome, single-sourced (theme/index.ts bridges
|
|
40
|
-
// `--mantine-color-{family}-filled` onto these). They all sit in ONE luminance band so a white
|
|
41
|
-
// label always works — retune within it, or you break the label. Hover is derived from the
|
|
42
|
-
// fill, so it follows automatically and is not listed. `blue` lives under Accent → Fill.
|
|
43
|
-
title: "Fills",
|
|
44
|
-
items: FILL_FAMILIES.map((name) => ({
|
|
45
|
-
var: `--vx-fill-${name}`,
|
|
46
|
-
label: name.charAt(0).toUpperCase() + name.slice(1)
|
|
47
|
-
}))
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
title: "Ink",
|
|
51
|
-
items: [
|
|
52
|
-
{ var: "--vx-ink", label: "Ink" },
|
|
53
|
-
{ var: "--vx-ink2", label: "Ink 2" },
|
|
54
|
-
{ var: "--vx-muted", label: "Muted" },
|
|
55
|
-
{ var: "--vx-faint", label: "Faint" }
|
|
56
|
-
]
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
title: "Semantic",
|
|
60
|
-
items: [
|
|
61
|
-
{ var: "--vx-goodSolid", label: "Good" },
|
|
62
|
-
{ var: "--vx-warnSolid", label: "Warn" },
|
|
63
|
-
{ var: "--vx-badSolid", label: "Bad" }
|
|
64
|
-
]
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
title: "Status",
|
|
23
|
+
// `excellent` (top-of-scale grade) and `neutral` (mid-scale) keep their own hand-authored BP
|
|
24
|
+
// families (`p(BP.forest)` / `p(BP.gray, 1, 2)`) — unlike `good`/`warn`/`bad`, which are the
|
|
25
|
+
// SAME derived hues as `Semantic` and are not independently tunable here.
|
|
26
|
+
title: "Status (chart-only)",
|
|
68
27
|
items: [
|
|
69
28
|
{ var: "--vx-status-excellent", label: "Excellent" },
|
|
70
|
-
{ var: "--vx-status-good", label: "Good" },
|
|
71
|
-
{ var: "--vx-status-warn", label: "Warn" },
|
|
72
|
-
{ var: "--vx-status-bad", label: "Bad" },
|
|
73
29
|
{ var: "--vx-status-neutral", label: "Neutral" }
|
|
74
30
|
]
|
|
75
31
|
},
|
|
76
32
|
{
|
|
77
|
-
|
|
33
|
+
// Chart line/dot chrome — hand-authored off the zinc `BP.gray`/`BP.white`/`BP.darkGray`
|
|
34
|
+
// families, independent of the derive config.
|
|
35
|
+
title: "Chart chrome",
|
|
78
36
|
items: [
|
|
79
37
|
{ var: "--vx-line", label: "Line" },
|
|
80
38
|
{ var: "--vx-line2", label: "Line 2" },
|
|
81
|
-
{ var: "--vx-neutral", label: "Neutral" },
|
|
82
39
|
{ var: "--vx-dotStroke", label: "Dot stroke" }
|
|
83
40
|
]
|
|
84
41
|
},
|
|
85
42
|
{
|
|
43
|
+
// The floating-layer surface (menus, popovers, tooltips, modals, drawers) — the one SURFACE
|
|
44
|
+
// stop the derive engine has no law for, so it stays a hand-picked hex/color-mix().
|
|
86
45
|
title: "Surface",
|
|
87
|
-
items: [
|
|
88
|
-
{ var: "--vx-surface-bg", label: "Background" },
|
|
89
|
-
{ var: "--vx-surface-panel", label: "Panel" },
|
|
90
|
-
{ var: "--vx-surface-panelHover", label: "Panel hover" },
|
|
91
|
-
{ var: "--vx-surface-elevated", label: "Elevated" },
|
|
92
|
-
{ var: "--vx-surface-subtle", label: "Subtle" },
|
|
93
|
-
{ var: "--vx-surface-overlay", label: "Overlay" },
|
|
94
|
-
{ var: "--vx-surface-field", label: "Field" },
|
|
95
|
-
{ var: "--vx-surface-border", label: "Border" }
|
|
96
|
-
]
|
|
46
|
+
items: [{ var: "--vx-surface-overlay", label: "Overlay" }]
|
|
97
47
|
}
|
|
98
48
|
];
|
|
99
49
|
const COLOR_VARS = COLOR_GROUPS.flatMap((g) => g.items.map((i) => i.var));
|
|
@@ -255,6 +205,7 @@ export {
|
|
|
255
205
|
AREA_BOTTOM_VAR,
|
|
256
206
|
AREA_TOP_VAR,
|
|
257
207
|
COLOR_GROUPS,
|
|
208
|
+
DeriveControls,
|
|
258
209
|
ThemeLabControls,
|
|
259
210
|
applyOverrides,
|
|
260
211
|
loadOverrides,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/theme-toggle/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/theme-toggle/index.tsx"],"names":[],"mappings":"AA8GA,MAAM,MAAM,gBAAgB,GAAG;IAC7B,qFAAqF;IACrF,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,+EAA+E;IAC/E,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB,CAAA;AAOD,wBAAgB,WAAW,CAAC,EAAE,SAAe,EAAE,UAAgB,EAAE,GAAE,gBAAqB,+BA8DvF"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import {
|
|
3
3
|
ActionIcon,
|
|
4
|
+
Center,
|
|
4
5
|
Popover,
|
|
5
6
|
SegmentedControl,
|
|
6
7
|
useComputedColorScheme,
|
|
@@ -54,7 +55,7 @@ function MoonGlyph() {
|
|
|
54
55
|
}
|
|
55
56
|
function SchemeGlyph({ dark, reduceMotion }) {
|
|
56
57
|
if (reduceMotion) {
|
|
57
|
-
return /* @__PURE__ */ jsx(
|
|
58
|
+
return /* @__PURE__ */ jsx(Center, { component: "span", inline: true, children: dark ? /* @__PURE__ */ jsx(MoonGlyph, {}) : /* @__PURE__ */ jsx(SunGlyph, {}) });
|
|
58
59
|
}
|
|
59
60
|
return /* @__PURE__ */ jsx(AnimatePresence, { mode: "wait", initial: false, children: dark ? /* @__PURE__ */ jsx(
|
|
60
61
|
motion.span,
|
|
@@ -113,7 +114,7 @@ function ThemeToggle({ openDelay = 150, closeDelay = 200 } = {}) {
|
|
|
113
114
|
{
|
|
114
115
|
variant: "subtle",
|
|
115
116
|
color: "gray",
|
|
116
|
-
|
|
117
|
+
style: { borderRadius: "var(--vx-radius-ctrl)" },
|
|
117
118
|
"aria-label": `Theme: ${LABEL[colorScheme]}. Click to cycle, hover to pick directly.`,
|
|
118
119
|
onClick: () => setColorScheme(nextScheme(colorScheme)),
|
|
119
120
|
onMouseEnter: scheduleOpen,
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import type { ColorPair } from './index.js';
|
|
2
|
+
export type DeriveConfig = {
|
|
3
|
+
/**
|
|
4
|
+
* Seed hex — the one color a consumer picks. Drives the entire accent family + `onAccent`.
|
|
5
|
+
*
|
|
6
|
+
* The seed contributes its HUE and nothing else: the derivation laws normalize its chroma
|
|
7
|
+
* (`max(seed, 40)`) and pin its tone to the Y=0.165 fill band, so a lighter/darker or more/less
|
|
8
|
+
* saturated seed produces the SAME palette as long as the hue matches. That is deliberate —
|
|
9
|
+
* contrast stays derivation-guaranteed instead of seed-dependent. `vibrancy` and
|
|
10
|
+
* `accentBrightness` below are the ONLY expressive controls layered on top of those laws.
|
|
11
|
+
*/
|
|
12
|
+
accent: string;
|
|
13
|
+
/** Which low-chroma neutral family backs every surface + ink stop. */
|
|
14
|
+
neutral: 'zinc' | 'neutral' | 'stone' | 'slate';
|
|
15
|
+
/** -5..5 — shifts the LIGHT scheme's surface tone stops by `2 x level + 2`. Positive =
|
|
16
|
+
* lighter. The `+2` baseline bakes the preferred "one level lighter" default into level 0. */
|
|
17
|
+
lightLevel: number;
|
|
18
|
+
/** -5..5 — shifts the DARK scheme's surface tone stops by `2 x level + 2`. Positive = lighter.
|
|
19
|
+
* Same baked `+2` baseline as `lightLevel`. */
|
|
20
|
+
darkLevel: number;
|
|
21
|
+
/**
|
|
22
|
+
* -5..5 (default 0) — scales the derived chroma of the accent family AND the 12 categorical
|
|
23
|
+
* fills via `0.72 x 1.2^level` (level 0 = the preferred x0.72 baseline, one vibrancy step above
|
|
24
|
+
* the original x0.6 muted center; level -5 ~= x0.29, the calibrated x1.0 spec saturation is
|
|
25
|
+
* crossed at ~+2 (0.72 x 1.2^2 ~= 1.037), +5 ~= x1.79). Gamut mapping in `hctToHex` absorbs any
|
|
26
|
+
* overshoot. Neutral surfaces/ink (and the status hues) are NOT affected.
|
|
27
|
+
*/
|
|
28
|
+
vibrancy: number;
|
|
29
|
+
/**
|
|
30
|
+
* -5..5 (default 0) — shifts the accent-family tones by `+5 x level` (fill, fill hover, dark
|
|
31
|
+
* ink accent, dark accent hover; hover deltas stay relative). The 12 categorical fills stay
|
|
32
|
+
* pinned on the fill band — chart colors must remain uniform. `onAccent` is still decided by
|
|
33
|
+
* the contrast law (3.0:1 white floor): white survives up to about +2 for typical seeds; from
|
|
34
|
+
* ~+3 the fill is light enough that the safety flip to dark ink engages.
|
|
35
|
+
*/
|
|
36
|
+
accentBrightness: number;
|
|
37
|
+
};
|
|
38
|
+
/** The default derive config — the shipped palette's baseline (all four knobs at level 0). */
|
|
39
|
+
export declare const DEFAULT_DERIVE_CONFIG: DeriveConfig;
|
|
40
|
+
/**
|
|
41
|
+
* Resolve a partial derive config against {@link DEFAULT_DERIVE_CONFIG} — the single place a
|
|
42
|
+
* consumer-supplied `{ derive }` option (`createBasaltTheme`'s second argument) becomes a full,
|
|
43
|
+
* six-knob `DeriveConfig`. Omitted knobs fall back to the shipped default for that knob.
|
|
44
|
+
*/
|
|
45
|
+
export declare function resolveDeriveConfig(partial?: Partial<DeriveConfig>): DeriveConfig;
|
|
46
|
+
/**
|
|
47
|
+
* Whether a resolved config is identical to {@link DEFAULT_DERIVE_CONFIG} — the gate
|
|
48
|
+
* `createBasaltTheme` and `BasaltProvider` use to stay on the pre-baked static path (zero extra
|
|
49
|
+
* derivation work) instead of re-deriving the palette.
|
|
50
|
+
*/
|
|
51
|
+
export declare function isDefaultDeriveConfig(config: DeriveConfig): boolean;
|
|
52
|
+
export type FillFamily = 'gray' | 'red' | 'pink' | 'grape' | 'violet' | 'indigo' | 'cyan' | 'teal' | 'green' | 'lime' | 'yellow' | 'orange';
|
|
53
|
+
export type SurfaceKey = 'bg' | 'panel' | 'panelHover' | 'elevated' | 'subtle' | 'field' | 'border' | 'hairline';
|
|
54
|
+
export type InkKey = 'ink' | 'ink2' | 'muted' | 'faint';
|
|
55
|
+
export type StatusKey = 'good' | 'warn' | 'bad';
|
|
56
|
+
/**
|
|
57
|
+
* Continuous derivation parameters — the derivation CORE's inputs, decoupled from the -5..5
|
|
58
|
+
* slider levels. `deriveTokens` maps levels onto these (with the re-centered baselines baked in).
|
|
59
|
+
*/
|
|
60
|
+
export type DeriveParams = {
|
|
61
|
+
/** Chroma multiplier for the accent family + 12 categorical fills. 1 = calibrated chroma. */
|
|
62
|
+
chromaMult: number;
|
|
63
|
+
/** Tone shift applied to the accent family only. 0 = calibrated tones. */
|
|
64
|
+
accentToneShift: number;
|
|
65
|
+
/** Tone shift for the LIGHT scheme's surface stops. 0 = calibrated stops. */
|
|
66
|
+
lightSurfaceShift: number;
|
|
67
|
+
/** Tone shift for the DARK scheme's surface stops. 0 = calibrated stops. */
|
|
68
|
+
darkSurfaceShift: number;
|
|
69
|
+
};
|
|
70
|
+
/** The full derived token set, grouped by family — the shape `palette.ts` builds ACCENT/FILL/
|
|
71
|
+
* SURFACE/INK/STATUS from. */
|
|
72
|
+
export type DerivedPalette = {
|
|
73
|
+
accent: ColorPair;
|
|
74
|
+
accentHover: ColorPair;
|
|
75
|
+
accentFill: ColorPair;
|
|
76
|
+
accentFillHover: ColorPair;
|
|
77
|
+
onAccent: ColorPair;
|
|
78
|
+
fill: Record<FillFamily, ColorPair>;
|
|
79
|
+
surface: Record<SurfaceKey, ColorPair>;
|
|
80
|
+
ink: Record<InkKey, ColorPair>;
|
|
81
|
+
status: Record<StatusKey, ColorPair>;
|
|
82
|
+
};
|
|
83
|
+
/** Derive the full palette from a seed accent + neutral family + surface levels.
|
|
84
|
+
* Public level-based entry: maps the -5..5 sliders onto `DeriveParams` (vibrancy x0.72 center,
|
|
85
|
+
* surface +2 baseline) and delegates to `deriveTokensRaw`. */
|
|
86
|
+
export declare function deriveTokens(config: DeriveConfig): DerivedPalette;
|
|
87
|
+
/** Derivation core over continuous params — see `DeriveParams` for the calibration contract. */
|
|
88
|
+
export declare function deriveTokensRaw(config: Pick<DeriveConfig, 'accent' | 'neutral'>, params: DeriveParams): DerivedPalette;
|
|
89
|
+
//# sourceMappingURL=derive.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"derive.d.ts","sourceRoot":"","sources":["../../src/tokens/derive.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAA;AAExC,MAAM,MAAM,YAAY,GAAG;IACzB;;;;;;;;OAQG;IACH,MAAM,EAAE,MAAM,CAA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