hextimator 0.2.0 → 0.3.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/CHANGELOG.md +31 -2
- package/README.md +83 -32
- package/dist/{HextimatePaletteBuilder-BOuHKcVE.d.ts → HextimatePaletteBuilder-xqJwP_G2.d.ts} +42 -26
- package/dist/{chunk-MBVLFPTG.js → chunk-2OMHLWID.js} +183 -88
- package/dist/cli.js +220 -120
- package/dist/index.d.ts +23 -26
- package/dist/index.js +1 -1
- package/dist/react.d.ts +33 -19
- package/dist/react.js +93 -46
- package/fallback.css +68 -80
- package/llms.txt +113 -21
- package/package.json +3 -3
package/dist/react.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { j as HextimateStyleOptions, H as HextimatePreset, e as HextimatePaletteBuilder, i as HextimateResult, g as HextimateFormatOptions, F as FlatTokenMap } from './HextimatePaletteBuilder-xqJwP_G2.js';
|
|
2
2
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
3
|
import { PropsWithChildren, RefObject, CSSProperties, ReactNode } from 'react';
|
|
4
4
|
|
|
@@ -23,8 +23,10 @@ interface HextimatorContextValue {
|
|
|
23
23
|
mode: ResolvedMode;
|
|
24
24
|
modePreference: ModePreference;
|
|
25
25
|
setMode: (mode: ModePreference) => void;
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
style: HextimateStyleOptions | undefined;
|
|
27
|
+
setStyle: (opts: HextimateStyleOptions | undefined) => void;
|
|
28
|
+
presets: HextimatePreset[] | undefined;
|
|
29
|
+
setPresets: (presets: HextimatePreset[] | undefined) => void;
|
|
28
30
|
configure: ((builder: HextimatePaletteBuilder) => void) | undefined;
|
|
29
31
|
setConfigure: (fn: ((builder: HextimatePaletteBuilder) => void) | undefined) => void;
|
|
30
32
|
palette: HextimateResult;
|
|
@@ -39,7 +41,7 @@ interface HextimatorContextValue {
|
|
|
39
41
|
/**
|
|
40
42
|
* Props for the `HextimatorProvider` component, which manages the state of a Hextimator-generated color palette and injects corresponding CSS variables into the document.
|
|
41
43
|
* - `defaultColor`: The initial base color to generate the palette from.
|
|
42
|
-
* - `
|
|
44
|
+
* - `style`: Initial options for how the palette is generated (e.g., light/dark settings, contrast requirements).
|
|
43
45
|
* - `format`: Initial options for how the generated palette is formatted (e.g., output format).
|
|
44
46
|
* - `configure`: An initial callback to further customize the palette builder before formatting.
|
|
45
47
|
* - `darkMode`: Strategy for handling dark mode variants in CSS variable injection.
|
|
@@ -49,7 +51,8 @@ interface HextimatorContextValue {
|
|
|
49
51
|
interface HextimatorProviderProps {
|
|
50
52
|
defaultColor: string;
|
|
51
53
|
defaultMode?: ModePreference;
|
|
52
|
-
|
|
54
|
+
style?: HextimateStyleOptions;
|
|
55
|
+
presets?: HextimatePreset[];
|
|
53
56
|
format?: Omit<HextimateFormatOptions, 'as'>;
|
|
54
57
|
configure?: (builder: HextimatePaletteBuilder) => void;
|
|
55
58
|
darkMode?: DarkModeStrategy;
|
|
@@ -61,21 +64,21 @@ interface HextimatorProviderProps {
|
|
|
61
64
|
* A React context provider that manages the state of
|
|
62
65
|
* a Hextimator-generated color palette and injects corresponding CSS variables into the document.
|
|
63
66
|
* It allows child components to access and update the
|
|
64
|
-
* base color,
|
|
67
|
+
* base color, style options, and configuration callback, automatically
|
|
65
68
|
* regenerating the palette and updating CSS variables as needed.
|
|
66
69
|
|
|
67
|
-
* The Provider accepts props for the default color,
|
|
70
|
+
* The Provider accepts props for the default color, style options, formatting options,
|
|
68
71
|
* dark mode strategy, CSS variable prefix, and an optional target element for CSS variable injection.
|
|
69
72
|
* It uses the `useHextimator` hook to generate the palette and handles the injection of CSS variables based on the current state.
|
|
70
73
|
*
|
|
71
74
|
* Example usage:
|
|
72
75
|
* ```tsx
|
|
73
|
-
* <HextimatorProvider defaultColor="#ff6600"
|
|
76
|
+
* <HextimatorProvider defaultColor="#ff6600" style={{ minContrastRatio: 'AA' }} darkMode={{ type: 'class', className: 'dark' }} cssPrefix="--myapp-">
|
|
74
77
|
* <App />
|
|
75
78
|
* </HextimatorProvider>
|
|
76
79
|
* ```
|
|
77
80
|
*/
|
|
78
|
-
declare function HextimatorProvider({ children, defaultColor, defaultMode: initialMode,
|
|
81
|
+
declare function HextimatorProvider({ children, defaultColor, defaultMode: initialMode, style: initialStyle, presets: initialPresets, format: formatOpts, configure: initialConfigure, darkMode, cssPrefix, target, }: PropsWithChildren<HextimatorProviderProps>): react_jsx_runtime.JSX.Element;
|
|
79
82
|
|
|
80
83
|
/**
|
|
81
84
|
* Props for `HextimatorScope`, a wrapper that creates a scoped theme for its
|
|
@@ -94,13 +97,22 @@ declare function HextimatorProvider({ children, defaultColor, defaultMode: initi
|
|
|
94
97
|
*/
|
|
95
98
|
interface HextimatorScopeProps {
|
|
96
99
|
defaultColor: string;
|
|
97
|
-
|
|
100
|
+
/**
|
|
101
|
+
* When true, builds from this scope's color and options only (via
|
|
102
|
+
* `hextimate`), without forking the parent builder. Use for previews or
|
|
103
|
+
* widgets where each scope must match exactly its presets and must not
|
|
104
|
+
* inherit parent roles, variants, or preset merges.
|
|
105
|
+
*/
|
|
106
|
+
isolated?: boolean;
|
|
107
|
+
style?: HextimateStyleOptions;
|
|
108
|
+
presets?: HextimatePreset[];
|
|
98
109
|
format?: Omit<HextimateFormatOptions, 'as'>;
|
|
99
110
|
configure?: (builder: HextimatePaletteBuilder) => void;
|
|
100
111
|
darkMode?: DarkModeStrategy;
|
|
101
112
|
cssPrefix?: string;
|
|
102
113
|
className?: string;
|
|
103
|
-
style
|
|
114
|
+
/** Inline styles for the scope wrapper element (not palette options; use `style` for those). */
|
|
115
|
+
wrapperStyle?: CSSProperties;
|
|
104
116
|
children?: ReactNode;
|
|
105
117
|
}
|
|
106
118
|
/**
|
|
@@ -135,7 +147,7 @@ interface HextimatorScopeProps {
|
|
|
135
147
|
* </HextimatorProvider>
|
|
136
148
|
* ```
|
|
137
149
|
*/
|
|
138
|
-
declare function HextimatorScope({ defaultColor,
|
|
150
|
+
declare function HextimatorScope({ defaultColor, isolated, style: initialStyle, presets: initialPresets, format: formatOpts, configure: initialConfigure, darkMode, cssPrefix, className, wrapperStyle, children, }: HextimatorScopeProps): react_jsx_runtime.JSX.Element;
|
|
139
151
|
|
|
140
152
|
/**
|
|
141
153
|
* Props for the `HextimatorStyle` component, a declarative alternative to
|
|
@@ -147,7 +159,7 @@ declare function HextimatorScope({ defaultColor, generation: initialGeneration,
|
|
|
147
159
|
* multiple subtrees can carry different themes via CSS cascade.
|
|
148
160
|
*
|
|
149
161
|
* - `color`: The base color to generate the palette from.
|
|
150
|
-
* - `
|
|
162
|
+
* - `style`: Options for how the palette is generated.
|
|
151
163
|
* - `format`: Options for how the generated palette is formatted.
|
|
152
164
|
* - `configure`: A callback to further customize the palette builder before formatting.
|
|
153
165
|
* - `darkMode`: Strategy for handling dark mode variants.
|
|
@@ -156,7 +168,8 @@ declare function HextimatorScope({ defaultColor, generation: initialGeneration,
|
|
|
156
168
|
*/
|
|
157
169
|
interface HextimatorStyleProps {
|
|
158
170
|
color: string;
|
|
159
|
-
|
|
171
|
+
style?: HextimateStyleOptions;
|
|
172
|
+
presets?: HextimatePreset[];
|
|
160
173
|
format?: Omit<HextimateFormatOptions, 'as'>;
|
|
161
174
|
configure?: (builder: HextimatePaletteBuilder) => void;
|
|
162
175
|
darkMode?: DarkModeStrategy;
|
|
@@ -180,11 +193,11 @@ interface HextimatorStyleProps {
|
|
|
180
193
|
* </div>
|
|
181
194
|
* ```
|
|
182
195
|
*/
|
|
183
|
-
declare function HextimatorStyle({ color,
|
|
196
|
+
declare function HextimatorStyle({ color, style: styleOptions, presets, format: formatOpts, configure, darkMode, cssPrefix, selector, }: HextimatorStyleProps): react_jsx_runtime.JSX.Element;
|
|
184
197
|
|
|
185
198
|
/**
|
|
186
199
|
* Options for the `useHextimator` hook, which generates a color palette and injects CSS variables based on a given color and configuration.
|
|
187
|
-
* - `
|
|
200
|
+
* - `style`: Options for how the palette is generated (e.g., light/dark settings, contrast requirements).
|
|
188
201
|
* - `format`: Options for how the generated palette is formatted (e.g., output format).
|
|
189
202
|
* - `configure`: A callback to further customize the palette builder before formatting.
|
|
190
203
|
* - `darkMode`: Strategy for handling dark mode variants in CSS variable injection.
|
|
@@ -193,7 +206,8 @@ declare function HextimatorStyle({ color, generation, format: formatOpts, config
|
|
|
193
206
|
*
|
|
194
207
|
*/
|
|
195
208
|
interface UseHextimatorOptions {
|
|
196
|
-
|
|
209
|
+
style?: HextimateStyleOptions;
|
|
210
|
+
presets?: HextimatePreset[];
|
|
197
211
|
format?: Omit<HextimateFormatOptions, 'as'>;
|
|
198
212
|
configure?: (builder: HextimatePaletteBuilder) => void;
|
|
199
213
|
darkMode?: DarkModeStrategy;
|
|
@@ -209,7 +223,7 @@ interface UseHextimatorOptions {
|
|
|
209
223
|
* Example usage:
|
|
210
224
|
* ```tsx
|
|
211
225
|
* const palette = useHextimator('#ff6600', {
|
|
212
|
-
*
|
|
226
|
+
* style: { minContrastRatio: 'AA' },
|
|
213
227
|
* darkMode: { type: 'class', className: 'dark' },
|
|
214
228
|
* cssPrefix: '--myapp-',
|
|
215
229
|
* });
|
|
@@ -231,7 +245,7 @@ declare function useHextimator(color: string, options?: UseHextimatorOptions): H
|
|
|
231
245
|
* - `mode` — the resolved color mode (`'light'` or `'dark'`), accounting for OS preference when set to `'system'`.
|
|
232
246
|
* - `modePreference` — the raw preference (`'light'`, `'dark'`, or `'system'`).
|
|
233
247
|
* - `setMode` — update the mode preference. Pass `'system'` to follow the OS.
|
|
234
|
-
* - `
|
|
248
|
+
* - `style` / `setStyle` — palette style options.
|
|
235
249
|
* - `configure` / `setConfigure` — builder configuration callback.
|
|
236
250
|
* - `palette` — the generated `HextimateResult`.
|
|
237
251
|
*
|
package/dist/react.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
hextimate
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-2OMHLWID.js";
|
|
4
4
|
|
|
5
5
|
// src/react/hextimator-provider.tsx
|
|
6
6
|
import {
|
|
@@ -59,24 +59,25 @@ import { useEffect, useMemo } from "react";
|
|
|
59
59
|
function buildStyleContent(palette, darkMode, cssPrefix, selector = ":root") {
|
|
60
60
|
const lightEntries = Object.entries(palette.light);
|
|
61
61
|
const darkEntries = Object.entries(palette.dark);
|
|
62
|
-
const toVars = (entries) => entries.map(([key, value]) => `${cssPrefix}${key}: ${value};`).join("\n
|
|
63
|
-
const lightVars = toVars(lightEntries);
|
|
64
|
-
const darkVars = toVars(darkEntries);
|
|
62
|
+
const toVars = (entries, lineIndent) => entries.map(([key, value]) => `${lineIndent}${cssPrefix}${key}: ${value};`).join("\n");
|
|
63
|
+
const lightVars = toVars(lightEntries, " ");
|
|
64
|
+
const darkVars = toVars(darkEntries, " ");
|
|
65
|
+
const darkVarsInMediaInner = toVars(darkEntries, " ");
|
|
65
66
|
const isRoot = selector === ":root";
|
|
66
67
|
if (darkMode === false) {
|
|
67
68
|
return `${selector} {
|
|
68
|
-
|
|
69
|
+
${lightVars}
|
|
69
70
|
}`;
|
|
70
71
|
}
|
|
71
72
|
if (darkMode.type === "media") {
|
|
72
73
|
return [
|
|
73
74
|
`${selector} {
|
|
74
|
-
|
|
75
|
+
${lightVars}
|
|
75
76
|
}`,
|
|
76
77
|
`@media (prefers-color-scheme: dark) {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
${selector} {
|
|
79
|
+
${darkVarsInMediaInner}
|
|
80
|
+
}
|
|
80
81
|
}`
|
|
81
82
|
].join("\n");
|
|
82
83
|
}
|
|
@@ -87,15 +88,15 @@ function buildStyleContent(palette, darkMode, cssPrefix, selector = ":root") {
|
|
|
87
88
|
const mediaDarkSelector = isRoot ? `:root:not(.${lightCls})` : `:root:not(.${lightCls}) ${selector}`;
|
|
88
89
|
return [
|
|
89
90
|
`${selector} {
|
|
90
|
-
|
|
91
|
+
${lightVars}
|
|
91
92
|
}`,
|
|
92
93
|
`@media (prefers-color-scheme: dark) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
${mediaDarkSelector} {
|
|
95
|
+
${darkVarsInMediaInner}
|
|
96
|
+
}
|
|
96
97
|
}`,
|
|
97
98
|
`${darkClassSelector} {
|
|
98
|
-
|
|
99
|
+
${darkVars}
|
|
99
100
|
}`
|
|
100
101
|
].join("\n");
|
|
101
102
|
}
|
|
@@ -104,10 +105,10 @@ function buildStyleContent(palette, darkMode, cssPrefix, selector = ":root") {
|
|
|
104
105
|
const darkSelector2 = isRoot ? `.${cls}` : `.${cls} ${selector}`;
|
|
105
106
|
return [
|
|
106
107
|
`${selector} {
|
|
107
|
-
|
|
108
|
+
${lightVars}
|
|
108
109
|
}`,
|
|
109
110
|
`${darkSelector2} {
|
|
110
|
-
|
|
111
|
+
${darkVars}
|
|
111
112
|
}`
|
|
112
113
|
].join("\n");
|
|
113
114
|
}
|
|
@@ -115,10 +116,10 @@ function buildStyleContent(palette, darkMode, cssPrefix, selector = ":root") {
|
|
|
115
116
|
const darkSelector = isRoot ? `[${attr}="dark"]` : `[${attr}="dark"] ${selector}`;
|
|
116
117
|
return [
|
|
117
118
|
`${selector} {
|
|
118
|
-
|
|
119
|
+
${lightVars}
|
|
119
120
|
}`,
|
|
120
121
|
`${darkSelector} {
|
|
121
|
-
|
|
122
|
+
${darkVars}
|
|
122
123
|
}`
|
|
123
124
|
].join("\n");
|
|
124
125
|
}
|
|
@@ -139,13 +140,15 @@ import { useRef } from "react";
|
|
|
139
140
|
function useStableOptions(options) {
|
|
140
141
|
const ref = useRef(options);
|
|
141
142
|
const serialized = JSON.stringify({
|
|
142
|
-
|
|
143
|
+
style: options?.style,
|
|
144
|
+
presets: options?.presets,
|
|
143
145
|
format: options?.format,
|
|
144
146
|
darkMode: options?.darkMode,
|
|
145
147
|
cssPrefix: options?.cssPrefix
|
|
146
148
|
});
|
|
147
149
|
if (serialized !== JSON.stringify({
|
|
148
|
-
|
|
150
|
+
style: ref.current?.style,
|
|
151
|
+
presets: ref.current?.presets,
|
|
149
152
|
format: ref.current?.format,
|
|
150
153
|
darkMode: ref.current?.darkMode,
|
|
151
154
|
cssPrefix: ref.current?.cssPrefix
|
|
@@ -160,14 +163,19 @@ function useHextimator(color, options) {
|
|
|
160
163
|
const stable = useStableOptions(options);
|
|
161
164
|
const configure = options?.configure;
|
|
162
165
|
const target = options?.target;
|
|
166
|
+
const presets = stable?.presets;
|
|
163
167
|
const palette = useMemo(() => {
|
|
164
|
-
const builder = hextimate(color
|
|
168
|
+
const builder = hextimate(color);
|
|
169
|
+
if (stable?.style && Object.keys(stable.style).length > 0) {
|
|
170
|
+
builder.style(stable.style);
|
|
171
|
+
}
|
|
172
|
+
for (const p of presets ?? []) builder.preset(p);
|
|
165
173
|
configure?.(builder);
|
|
166
174
|
return builder.format({
|
|
167
175
|
...stable?.format,
|
|
168
176
|
as: "css"
|
|
169
177
|
});
|
|
170
|
-
}, [color, stable?.
|
|
178
|
+
}, [color, stable?.style, presets, stable?.format, configure]);
|
|
171
179
|
const darkMode = stable?.darkMode ?? { type: "media" };
|
|
172
180
|
const cssPrefix = stable?.cssPrefix ?? "";
|
|
173
181
|
useEffect(() => {
|
|
@@ -200,7 +208,8 @@ function HextimatorProvider({
|
|
|
200
208
|
children,
|
|
201
209
|
defaultColor,
|
|
202
210
|
defaultMode: initialMode = "system",
|
|
203
|
-
|
|
211
|
+
style: initialStyle,
|
|
212
|
+
presets: initialPresets,
|
|
204
213
|
format: formatOpts,
|
|
205
214
|
configure: initialConfigure,
|
|
206
215
|
darkMode,
|
|
@@ -209,7 +218,8 @@ function HextimatorProvider({
|
|
|
209
218
|
}) {
|
|
210
219
|
const [color, setColor] = useState(defaultColor);
|
|
211
220
|
const [modePreference, setMode] = useState(initialMode);
|
|
212
|
-
const [
|
|
221
|
+
const [style, setStyle] = useState(initialStyle);
|
|
222
|
+
const [presets, setPresets] = useState(initialPresets);
|
|
213
223
|
const [configure, setConfigureState] = useState(() => initialConfigure);
|
|
214
224
|
const osDark = useOsPrefersDark();
|
|
215
225
|
const mode = modePreference === "system" ? osDark ? "dark" : "light" : modePreference;
|
|
@@ -227,7 +237,8 @@ function HextimatorProvider({
|
|
|
227
237
|
[]
|
|
228
238
|
);
|
|
229
239
|
const palette = useHextimator(color, {
|
|
230
|
-
|
|
240
|
+
style,
|
|
241
|
+
presets,
|
|
231
242
|
format: formatOpts,
|
|
232
243
|
configure,
|
|
233
244
|
darkMode,
|
|
@@ -235,10 +246,14 @@ function HextimatorProvider({
|
|
|
235
246
|
target
|
|
236
247
|
});
|
|
237
248
|
const builder = useMemo2(() => {
|
|
238
|
-
const b = hextimate(color
|
|
249
|
+
const b = hextimate(color);
|
|
250
|
+
if (style && Object.keys(style).length > 0) {
|
|
251
|
+
b.style(style);
|
|
252
|
+
}
|
|
253
|
+
for (const p of presets ?? []) b.preset(p);
|
|
239
254
|
configure?.(b);
|
|
240
255
|
return b;
|
|
241
|
-
}, [color,
|
|
256
|
+
}, [color, style, presets, configure]);
|
|
242
257
|
const value = useMemo2(
|
|
243
258
|
() => ({
|
|
244
259
|
color,
|
|
@@ -246,8 +261,10 @@ function HextimatorProvider({
|
|
|
246
261
|
mode,
|
|
247
262
|
modePreference,
|
|
248
263
|
setMode,
|
|
249
|
-
|
|
250
|
-
|
|
264
|
+
style,
|
|
265
|
+
setStyle,
|
|
266
|
+
presets,
|
|
267
|
+
setPresets,
|
|
251
268
|
configure,
|
|
252
269
|
setConfigure,
|
|
253
270
|
palette,
|
|
@@ -257,7 +274,8 @@ function HextimatorProvider({
|
|
|
257
274
|
color,
|
|
258
275
|
mode,
|
|
259
276
|
modePreference,
|
|
260
|
-
|
|
277
|
+
style,
|
|
278
|
+
presets,
|
|
261
279
|
configure,
|
|
262
280
|
setConfigure,
|
|
263
281
|
palette,
|
|
@@ -271,6 +289,7 @@ function HextimatorProvider({
|
|
|
271
289
|
import {
|
|
272
290
|
useCallback as useCallback2,
|
|
273
291
|
useContext,
|
|
292
|
+
useEffect as useEffect3,
|
|
274
293
|
useId,
|
|
275
294
|
useMemo as useMemo3,
|
|
276
295
|
useState as useState2
|
|
@@ -278,20 +297,26 @@ import {
|
|
|
278
297
|
import { jsx as jsx2, jsxs } from "react/jsx-runtime";
|
|
279
298
|
function HextimatorScope({
|
|
280
299
|
defaultColor,
|
|
281
|
-
|
|
300
|
+
isolated = false,
|
|
301
|
+
style: initialStyle,
|
|
302
|
+
presets: initialPresets,
|
|
282
303
|
format: formatOpts,
|
|
283
304
|
configure: initialConfigure,
|
|
284
305
|
darkMode,
|
|
285
306
|
cssPrefix,
|
|
286
307
|
className,
|
|
287
|
-
|
|
308
|
+
wrapperStyle,
|
|
288
309
|
children
|
|
289
310
|
}) {
|
|
290
311
|
const id = useId();
|
|
291
312
|
const selector = `[data-hextimator-scope="${id}"]`;
|
|
292
313
|
const [color, setColor] = useState2(defaultColor);
|
|
293
|
-
const [
|
|
314
|
+
const [style, setStyle] = useState2(initialStyle);
|
|
315
|
+
const [presets, setPresets] = useState2(initialPresets);
|
|
294
316
|
const [configure, setConfigureState] = useState2(() => initialConfigure);
|
|
317
|
+
useEffect3(() => {
|
|
318
|
+
setColor(defaultColor);
|
|
319
|
+
}, [defaultColor]);
|
|
295
320
|
const setConfigure = useCallback2(
|
|
296
321
|
(fn) => {
|
|
297
322
|
setConfigureState(() => fn);
|
|
@@ -300,16 +325,21 @@ function HextimatorScope({
|
|
|
300
325
|
);
|
|
301
326
|
const parent = useContext(HextimatorContext);
|
|
302
327
|
const stable = useStableOptions({
|
|
303
|
-
|
|
328
|
+
style,
|
|
329
|
+
presets,
|
|
304
330
|
format: formatOpts,
|
|
305
331
|
darkMode,
|
|
306
332
|
cssPrefix
|
|
307
333
|
});
|
|
308
334
|
const builder = useMemo3(() => {
|
|
309
|
-
const b = parent?.builder ? parent.builder.fork(color
|
|
335
|
+
const b = !isolated && parent?.builder ? parent.builder.fork(color) : hextimate(color);
|
|
336
|
+
if (stable?.style && Object.keys(stable.style).length > 0) {
|
|
337
|
+
b.style(stable.style);
|
|
338
|
+
}
|
|
339
|
+
for (const p of presets ?? []) b.preset(p);
|
|
310
340
|
configure?.(b);
|
|
311
341
|
return b;
|
|
312
|
-
}, [parent?.builder, color, stable, configure]);
|
|
342
|
+
}, [parent?.builder, color, presets, stable, configure, isolated]);
|
|
313
343
|
const palette = useMemo3(
|
|
314
344
|
() => builder.format({
|
|
315
345
|
...stable?.format,
|
|
@@ -339,8 +369,10 @@ function HextimatorScope({
|
|
|
339
369
|
mode,
|
|
340
370
|
modePreference,
|
|
341
371
|
setMode,
|
|
342
|
-
|
|
343
|
-
|
|
372
|
+
style,
|
|
373
|
+
setStyle,
|
|
374
|
+
presets,
|
|
375
|
+
setPresets,
|
|
344
376
|
configure,
|
|
345
377
|
setConfigure,
|
|
346
378
|
palette,
|
|
@@ -351,17 +383,26 @@ function HextimatorScope({
|
|
|
351
383
|
mode,
|
|
352
384
|
modePreference,
|
|
353
385
|
setMode,
|
|
354
|
-
|
|
386
|
+
style,
|
|
387
|
+
presets,
|
|
355
388
|
configure,
|
|
356
389
|
setConfigure,
|
|
357
390
|
palette,
|
|
358
391
|
builder
|
|
359
392
|
]
|
|
360
393
|
);
|
|
361
|
-
return /* @__PURE__ */ jsx2(HextimatorContext.Provider, { value, children: /* @__PURE__ */ jsxs(
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
394
|
+
return /* @__PURE__ */ jsx2(HextimatorContext.Provider, { value, children: /* @__PURE__ */ jsxs(
|
|
395
|
+
"div",
|
|
396
|
+
{
|
|
397
|
+
"data-hextimator-scope": id,
|
|
398
|
+
className,
|
|
399
|
+
style: wrapperStyle,
|
|
400
|
+
children: [
|
|
401
|
+
/* @__PURE__ */ jsx2("style", { "data-hextimator": "", children: css }),
|
|
402
|
+
children
|
|
403
|
+
]
|
|
404
|
+
}
|
|
405
|
+
) });
|
|
365
406
|
}
|
|
366
407
|
|
|
367
408
|
// src/react/hextimator-style.tsx
|
|
@@ -369,7 +410,8 @@ import { useMemo as useMemo4 } from "react";
|
|
|
369
410
|
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
370
411
|
function HextimatorStyle({
|
|
371
412
|
color,
|
|
372
|
-
|
|
413
|
+
style: styleOptions,
|
|
414
|
+
presets,
|
|
373
415
|
format: formatOpts,
|
|
374
416
|
configure,
|
|
375
417
|
darkMode,
|
|
@@ -377,13 +419,18 @@ function HextimatorStyle({
|
|
|
377
419
|
selector
|
|
378
420
|
}) {
|
|
379
421
|
const stable = useStableOptions({
|
|
380
|
-
|
|
422
|
+
style: styleOptions,
|
|
423
|
+
presets,
|
|
381
424
|
format: formatOpts,
|
|
382
425
|
darkMode,
|
|
383
426
|
cssPrefix
|
|
384
427
|
});
|
|
385
428
|
const css = useMemo4(() => {
|
|
386
|
-
const builder = hextimate(color
|
|
429
|
+
const builder = hextimate(color);
|
|
430
|
+
if (stable?.style && Object.keys(stable.style).length > 0) {
|
|
431
|
+
builder.style(stable.style);
|
|
432
|
+
}
|
|
433
|
+
for (const p of stable?.presets ?? []) builder.preset(p);
|
|
387
434
|
configure?.(builder);
|
|
388
435
|
const palette = builder.format({
|
|
389
436
|
...stable?.format,
|
package/fallback.css
CHANGED
|
@@ -1,86 +1,74 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Neutral placeholder theme for the pre-JavaScript paint (and before Hextimator injects CSS).
|
|
3
|
-
* Same token names as default hextimate() + hextimator/tailwind.css. Dark mode matches
|
|
4
|
-
* useHextimator / HextimatorStyle with darkMode: { type: "media-or-class" } (also fine for
|
|
5
|
-
* { type: "media" } when :root has no .light class).
|
|
6
|
-
*
|
|
7
|
-
* Does not include tokens from presets (e.g. shadcn). For those, generate CSS with the CLI
|
|
8
|
-
* and ship it alongside this file or instead of it.
|
|
9
|
-
*
|
|
10
|
-
* Regenerated at package build time (see package.json "build").
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
1
|
:root {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
2
|
+
--base: #f5f5f5;
|
|
3
|
+
--base-strong: #fcfcfc;
|
|
4
|
+
--base-weak: #ebebeb;
|
|
5
|
+
--base-foreground: #030303;
|
|
6
|
+
--accent: #aeaeae;
|
|
7
|
+
--accent-strong: #989898;
|
|
8
|
+
--accent-weak: #cecece;
|
|
9
|
+
--accent-foreground: #030303;
|
|
10
|
+
--positive: #aeaeae;
|
|
11
|
+
--positive-strong: #989898;
|
|
12
|
+
--positive-weak: #cecece;
|
|
13
|
+
--positive-foreground: #030303;
|
|
14
|
+
--negative: #aeaeae;
|
|
15
|
+
--negative-strong: #989898;
|
|
16
|
+
--negative-weak: #cecece;
|
|
17
|
+
--negative-foreground: #030303;
|
|
18
|
+
--warning: #aeaeae;
|
|
19
|
+
--warning-strong: #989898;
|
|
20
|
+
--warning-weak: #cecece;
|
|
21
|
+
--warning-foreground: #030303;
|
|
22
|
+
--brand-exact: #737373;
|
|
23
|
+
--brand-exact-foreground: #f5f5f5;
|
|
36
24
|
}
|
|
37
25
|
@media (prefers-color-scheme: dark) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
26
|
+
:root:not(.light) {
|
|
27
|
+
--base: #161616;
|
|
28
|
+
--base-strong: #030303;
|
|
29
|
+
--base-weak: #2e2e2e;
|
|
30
|
+
--base-foreground: #f5f5f5;
|
|
31
|
+
--accent: #a8a8a8;
|
|
32
|
+
--accent-strong: #b7b7b7;
|
|
33
|
+
--accent-weak: #989898;
|
|
34
|
+
--accent-foreground: #030303;
|
|
35
|
+
--positive: #a8a8a8;
|
|
36
|
+
--positive-strong: #b7b7b7;
|
|
37
|
+
--positive-weak: #989898;
|
|
38
|
+
--positive-foreground: #030303;
|
|
39
|
+
--negative: #a8a8a8;
|
|
40
|
+
--negative-strong: #b7b7b7;
|
|
41
|
+
--negative-weak: #989898;
|
|
42
|
+
--negative-foreground: #030303;
|
|
43
|
+
--warning: #a8a8a8;
|
|
44
|
+
--warning-strong: #b7b7b7;
|
|
45
|
+
--warning-weak: #989898;
|
|
46
|
+
--warning-foreground: #030303;
|
|
47
|
+
--brand-exact: #737373;
|
|
48
|
+
--brand-exact-foreground: #f5f5f5;
|
|
49
|
+
}
|
|
62
50
|
}
|
|
63
51
|
:root.dark {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
52
|
+
--base: #161616;
|
|
53
|
+
--base-strong: #030303;
|
|
54
|
+
--base-weak: #2e2e2e;
|
|
55
|
+
--base-foreground: #f5f5f5;
|
|
56
|
+
--accent: #a8a8a8;
|
|
57
|
+
--accent-strong: #b7b7b7;
|
|
58
|
+
--accent-weak: #989898;
|
|
59
|
+
--accent-foreground: #030303;
|
|
60
|
+
--positive: #a8a8a8;
|
|
61
|
+
--positive-strong: #b7b7b7;
|
|
62
|
+
--positive-weak: #989898;
|
|
63
|
+
--positive-foreground: #030303;
|
|
64
|
+
--negative: #a8a8a8;
|
|
65
|
+
--negative-strong: #b7b7b7;
|
|
66
|
+
--negative-weak: #989898;
|
|
67
|
+
--negative-foreground: #030303;
|
|
68
|
+
--warning: #a8a8a8;
|
|
69
|
+
--warning-strong: #b7b7b7;
|
|
70
|
+
--warning-weak: #989898;
|
|
71
|
+
--warning-foreground: #030303;
|
|
72
|
+
--brand-exact: #737373;
|
|
73
|
+
--brand-exact-foreground: #f5f5f5;
|
|
86
74
|
}
|