hextimator 0.1.1 → 0.1.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/CHANGELOG.md +5 -1
- package/README.md +8 -4
- package/dist/{HextimatePaletteBuilder-BzrgFryu.d.mts → HextimatePaletteBuilder-BOuHKcVE.d.mts} +3 -3
- package/dist/{HextimatePaletteBuilder-BzrgFryu.d.ts → HextimatePaletteBuilder-BOuHKcVE.d.ts} +3 -3
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/react.d.mts +1 -1
- package/dist/react.d.ts +1 -1
- package/llms.txt +157 -11
- package/package.json +1 -1
- package/tailwind.css +2 -0
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -6,11 +6,15 @@
|
|
|
6
6
|
</picture>
|
|
7
7
|
</p>
|
|
8
8
|
|
|
9
|
-
One
|
|
9
|
+
One color in, whole theme out.
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
-
|
|
11
|
+
Your customers pick a brand color. Your app looks good. Every time. No manual tuning, no edge cases where "that shade of yellow" breaks your UI.
|
|
12
|
+
|
|
13
|
+
- **Ship white-labeling without the design overhead** — generate per-tenant branded themes at runtime from a single input color. No design review per customer.
|
|
14
|
+
- **Every color just works** — perceptually uniform color science (OKLCH) means electric blue looks as balanced as muted olive. No hue gets special treatment.
|
|
15
|
+
- **Accessible by default** — every foreground meets AAA contrast against its background, light and dark mode included.
|
|
16
|
+
|
|
17
|
+
**[hextimator.com](https://hextimator.com)** — try it in the playground.
|
|
14
18
|
|
|
15
19
|
## Installation
|
|
16
20
|
|
package/dist/{HextimatePaletteBuilder-BzrgFryu.d.mts → HextimatePaletteBuilder-BOuHKcVE.d.mts}
RENAMED
|
@@ -149,9 +149,9 @@ interface HextimateGenerationOptions {
|
|
|
149
149
|
* Degree ranges for the semantic colors.
|
|
150
150
|
* Determines where to look for "green", "red", "yellow" in the color space.
|
|
151
151
|
* If not provided, the default ranges will be used:
|
|
152
|
-
* - positive: [
|
|
153
|
-
* - negative: [
|
|
154
|
-
* - warning: [
|
|
152
|
+
* - positive: [135, 160] greens
|
|
153
|
+
* - negative: [5, 25] reds
|
|
154
|
+
* - warning: [45, 65] ambers
|
|
155
155
|
*/
|
|
156
156
|
semanticColorRanges?: {
|
|
157
157
|
positive?: [number, number];
|
package/dist/{HextimatePaletteBuilder-BzrgFryu.d.ts → HextimatePaletteBuilder-BOuHKcVE.d.ts}
RENAMED
|
@@ -149,9 +149,9 @@ interface HextimateGenerationOptions {
|
|
|
149
149
|
* Degree ranges for the semantic colors.
|
|
150
150
|
* Determines where to look for "green", "red", "yellow" in the color space.
|
|
151
151
|
* If not provided, the default ranges will be used:
|
|
152
|
-
* - positive: [
|
|
153
|
-
* - negative: [
|
|
154
|
-
* - warning: [
|
|
152
|
+
* - positive: [135, 160] greens
|
|
153
|
+
* - negative: [5, 25] reds
|
|
154
|
+
* - warning: [45, 65] ambers
|
|
155
155
|
*/
|
|
156
156
|
semanticColorRanges?: {
|
|
157
157
|
positive?: [number, number];
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as Color, a as CVDType, O as OKLCH, b as ColorSpace, c as ColorInSpace, d as ColorInput, H as HextimatePreset, e as HextimateGenerationOptions, f as HextimatePaletteBuilder } from './HextimatePaletteBuilder-
|
|
2
|
-
export { D as DerivedToken, F as FlatTokenMap, g as FormatResult, h as HextimateFormatOptions, i as HextimateOptions, j as HextimateResult, N as NestedTokenMap, T as ThemeAdjustments, k as TokenValue, V as VariantPlacement } from './HextimatePaletteBuilder-
|
|
1
|
+
import { C as Color, a as CVDType, O as OKLCH, b as ColorSpace, c as ColorInSpace, d as ColorInput, H as HextimatePreset, e as HextimateGenerationOptions, f as HextimatePaletteBuilder } from './HextimatePaletteBuilder-BOuHKcVE.mjs';
|
|
2
|
+
export { D as DerivedToken, F as FlatTokenMap, g as FormatResult, h as HextimateFormatOptions, i as HextimateOptions, j as HextimateResult, N as NestedTokenMap, T as ThemeAdjustments, k as TokenValue, V as VariantPlacement } from './HextimatePaletteBuilder-BOuHKcVE.mjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Daltonize a color for a specific type of color vision deficiency (CVD).
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as Color, a as CVDType, O as OKLCH, b as ColorSpace, c as ColorInSpace, d as ColorInput, H as HextimatePreset, e as HextimateGenerationOptions, f as HextimatePaletteBuilder } from './HextimatePaletteBuilder-
|
|
2
|
-
export { D as DerivedToken, F as FlatTokenMap, g as FormatResult, h as HextimateFormatOptions, i as HextimateOptions, j as HextimateResult, N as NestedTokenMap, T as ThemeAdjustments, k as TokenValue, V as VariantPlacement } from './HextimatePaletteBuilder-
|
|
1
|
+
import { C as Color, a as CVDType, O as OKLCH, b as ColorSpace, c as ColorInSpace, d as ColorInput, H as HextimatePreset, e as HextimateGenerationOptions, f as HextimatePaletteBuilder } from './HextimatePaletteBuilder-BOuHKcVE.js';
|
|
2
|
+
export { D as DerivedToken, F as FlatTokenMap, g as FormatResult, h as HextimateFormatOptions, i as HextimateOptions, j as HextimateResult, N as NestedTokenMap, T as ThemeAdjustments, k as TokenValue, V as VariantPlacement } from './HextimatePaletteBuilder-BOuHKcVE.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Daltonize a color for a specific type of color vision deficiency (CVD).
|
package/dist/react.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { e as HextimateGenerationOptions, f as HextimatePaletteBuilder, j as HextimateResult, h as HextimateFormatOptions, F as FlatTokenMap } from './HextimatePaletteBuilder-
|
|
2
|
+
import { e as HextimateGenerationOptions, f as HextimatePaletteBuilder, j as HextimateResult, h as HextimateFormatOptions, F as FlatTokenMap } from './HextimatePaletteBuilder-BOuHKcVE.mjs';
|
|
3
3
|
import { PropsWithChildren } from 'react';
|
|
4
4
|
|
|
5
5
|
type DarkModeStrategy = {
|
package/dist/react.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
-
import { e as HextimateGenerationOptions, f as HextimatePaletteBuilder, j as HextimateResult, h as HextimateFormatOptions, F as FlatTokenMap } from './HextimatePaletteBuilder-
|
|
2
|
+
import { e as HextimateGenerationOptions, f as HextimatePaletteBuilder, j as HextimateResult, h as HextimateFormatOptions, F as FlatTokenMap } from './HextimatePaletteBuilder-BOuHKcVE.js';
|
|
3
3
|
import { PropsWithChildren } from 'react';
|
|
4
4
|
|
|
5
5
|
type DarkModeStrategy = {
|
package/llms.txt
CHANGED
|
@@ -82,12 +82,13 @@ Output shape depends on `as`:
|
|
|
82
82
|
|
|
83
83
|
### Default palette structure
|
|
84
84
|
|
|
85
|
-
Every palette includes 5 roles
|
|
85
|
+
Every palette includes 5 roles x 4 variants + 2 brand tokens = 22 tokens:
|
|
86
86
|
|
|
87
87
|
- Roles: `base`, `accent`, `positive`, `negative`, `warning`
|
|
88
88
|
- Variants: `DEFAULT` (no suffix), `strong`, `weak`, `foreground`
|
|
89
|
+
- Brand tokens: `brand-exact` (the exact input color, unmodified), `brand-exact-foreground` (best-contrast foreground for that color)
|
|
89
90
|
|
|
90
|
-
Token keys: `accent`, `accent-strong`, `accent-weak`, `accent-foreground`, `base`, `base-strong`,
|
|
91
|
+
Token keys: `accent`, `accent-strong`, `accent-weak`, `accent-foreground`, `base`, `base-strong`, ..., `brand-exact`, `brand-exact-foreground`
|
|
91
92
|
|
|
92
93
|
### Presets
|
|
93
94
|
|
|
@@ -106,6 +107,111 @@ const theme = hextimate("#6366F1")
|
|
|
106
107
|
|
|
107
108
|
The shadcn preset adds tokens like foreground, card, popover, secondary, muted, border, input, ring, and renames roles (base→background, accent→primary, negative→destructive, positive→success).
|
|
108
109
|
|
|
110
|
+
### Creating presets
|
|
111
|
+
|
|
112
|
+
A preset is a plain `HextimatePreset` object with optional fields for `generation`, `roles`, `variants`, `tokens`, and `format`. It configures the builder the same way chained methods would, but as a reusable data object.
|
|
113
|
+
|
|
114
|
+
```typescript
|
|
115
|
+
import type { HextimatePreset } from "hextimator";
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
**Interface:**
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
interface HextimatePreset {
|
|
122
|
+
generation?: HextimateGenerationOptions; // contrast, lightness, chroma, hue shifts
|
|
123
|
+
roles?: Array<{ name: string; color: ColorInput | DerivedToken }>;
|
|
124
|
+
variants?: Array<{ name: string; placement: VariantPlacement }>;
|
|
125
|
+
tokens?: Array<{ name: string; value: TokenValue }>;
|
|
126
|
+
format?: HextimateFormatOptions; // default format options, overridable in .format()
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
**Token values** can be:
|
|
131
|
+
- A raw color: `"#FF6600"`, `[255, 102, 102]`, etc.
|
|
132
|
+
- A derived reference: `{ from: "role.variant", emphasis?, lightness?, chroma?, hue? }`
|
|
133
|
+
- Per-theme: `{ light: DerivedToken | ColorInput, dark: DerivedToken | ColorInput }`
|
|
134
|
+
|
|
135
|
+
**`from` syntax**: `"role"` resolves to the DEFAULT variant, `"role.variant"` to a specific one. Valid built-in references: `base`, `base.strong`, `base.weak`, `base.foreground`, `accent`, `accent.strong`, etc. Custom roles/tokens added earlier in the preset can also be referenced.
|
|
136
|
+
|
|
137
|
+
**`emphasis`** is theme-aware contrast adjustment. Positive values push the color *away* from the background (more contrast), negative values pull it *toward* the background (softer). The direction flips automatically between light and dark themes, so `emphasis: 0.12` always means "slightly more visible than the source" regardless of theme. Use this instead of per-theme `lightness` splits when you just want "a bit more/less contrast."
|
|
138
|
+
|
|
139
|
+
**`roleNames` / `variantNames`** in format options remap output keys. This is how you match another framework's naming. For example, `roleNames: { base: "background", accent: "primary" }` turns `base-strong` into `background-strong` and `accent` into `primary` in the output. `variantNames: { DEFAULT: "main", foreground: "contrastText" }` turns `accent` (DEFAULT) into `primary-main` and `accent-foreground` into `primary-contrastText`.
|
|
140
|
+
|
|
141
|
+
**Role colors** can be derived from other roles: `{ from: "accent", hue: 180 }` creates a role whose hue is rotated 180 degrees from the accent.
|
|
142
|
+
|
|
143
|
+
**Example - custom preset for a design system with "surface", "brand", and "danger" tokens:**
|
|
144
|
+
|
|
145
|
+
```typescript
|
|
146
|
+
const myPreset: HextimatePreset = {
|
|
147
|
+
roles: [
|
|
148
|
+
// Add an "info" role not in the default palette
|
|
149
|
+
{ name: "info", color: "#0288d1" },
|
|
150
|
+
// Derive a secondary role by rotating the accent hue
|
|
151
|
+
{ name: "secondary", color: { from: "accent", hue: 180 } },
|
|
152
|
+
],
|
|
153
|
+
tokens: [
|
|
154
|
+
// Surface tokens derived from base
|
|
155
|
+
{ name: "surface", value: { from: "base" } },
|
|
156
|
+
{ name: "surface-raised", value: { from: "base", emphasis: -0.025 } },
|
|
157
|
+
{ name: "surface-overlay", value: { from: "base", emphasis: -0.05 } },
|
|
158
|
+
|
|
159
|
+
// Text with varying prominence
|
|
160
|
+
{ name: "text-primary", value: { from: "base.foreground" } },
|
|
161
|
+
{ name: "text-secondary", value: { from: "base.foreground", emphasis: -0.2 } },
|
|
162
|
+
{ name: "text-disabled", value: { from: "base.foreground", emphasis: -0.4 } },
|
|
163
|
+
|
|
164
|
+
// Border that adjusts direction per theme
|
|
165
|
+
{ name: "border", value: { from: "base", emphasis: 0.12 } },
|
|
166
|
+
|
|
167
|
+
// Per-theme token when emphasis alone isn't enough
|
|
168
|
+
{
|
|
169
|
+
name: "divider",
|
|
170
|
+
value: {
|
|
171
|
+
light: { from: "base.weak", lightness: -0.08 },
|
|
172
|
+
dark: { from: "base.weak", lightness: +0.08 },
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
],
|
|
176
|
+
format: {
|
|
177
|
+
as: "css",
|
|
178
|
+
colors: "hex",
|
|
179
|
+
roleNames: {
|
|
180
|
+
base: "surface",
|
|
181
|
+
accent: "brand",
|
|
182
|
+
negative: "danger",
|
|
183
|
+
positive: "success",
|
|
184
|
+
},
|
|
185
|
+
variantNames: {
|
|
186
|
+
DEFAULT: "", // no suffix for the base variant
|
|
187
|
+
strong: "bold",
|
|
188
|
+
weak: "subtle",
|
|
189
|
+
foreground: "on", // e.g. --brand-on
|
|
190
|
+
},
|
|
191
|
+
separator: "-",
|
|
192
|
+
},
|
|
193
|
+
};
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
Usage:
|
|
197
|
+
|
|
198
|
+
```typescript
|
|
199
|
+
import { hextimate } from "hextimator";
|
|
200
|
+
|
|
201
|
+
const theme = hextimate("#6366F1").preset(myPreset).format();
|
|
202
|
+
// .format() options override preset defaults:
|
|
203
|
+
const asScss = hextimate("#6366F1").preset(myPreset).format({ as: "scss" });
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
**How to build a preset for an existing app's theme:**
|
|
207
|
+
|
|
208
|
+
1. List the app's theme tokens (e.g. from its CSS variables or theme config)
|
|
209
|
+
2. Map each token to a hextimator source: which built-in role/variant is it closest to?
|
|
210
|
+
3. Use `roleNames`/`variantNames` to rename the 20 built-in tokens to match the app's naming
|
|
211
|
+
4. Use `tokens` for any extra tokens not covered by the built-in 5x4 grid, deriving them with `from` + `emphasis`/`lightness`/`chroma`/`hue` offsets
|
|
212
|
+
5. Use `roles` if the app has color categories beyond base/accent/positive/negative/warning
|
|
213
|
+
6. Set `format` defaults to match what the app expects (CSS vars, object, etc.)
|
|
214
|
+
|
|
109
215
|
### Standalone tokens with per-theme values
|
|
110
216
|
|
|
111
217
|
```typescript
|
|
@@ -148,8 +254,12 @@ Alpha is always ignored (forced to 1) to preserve contrast guarantees.
|
|
|
148
254
|
|
|
149
255
|
```bash
|
|
150
256
|
npx hextimator <color> [options]
|
|
257
|
+
# or the shorter alias:
|
|
258
|
+
npx hextimate <color> [options]
|
|
151
259
|
```
|
|
152
260
|
|
|
261
|
+
Both commands are identical. Use whichever you prefer.
|
|
262
|
+
|
|
153
263
|
| Flag | Description | Default |
|
|
154
264
|
|---|---|---|
|
|
155
265
|
| `-f, --format` | `css`, `object`, `tailwind`, `tailwind-css`, `scss`, `json` | `css` |
|
|
@@ -209,24 +319,60 @@ function App() {
|
|
|
209
319
|
}
|
|
210
320
|
```
|
|
211
321
|
|
|
212
|
-
Dark mode strategies:
|
|
322
|
+
Dark mode strategies:
|
|
323
|
+
- `{ type: "media" }` (default) -- uses `prefers-color-scheme` media query
|
|
324
|
+
- `{ type: "class", className?: string }` -- toggles on a CSS class (default: `"dark"`)
|
|
325
|
+
- `{ type: "data", attribute?: string }` -- toggles on a data attribute (default: `"data-theme"`)
|
|
326
|
+
- `{ type: "media-or-class", className?: string }` -- media query with class override
|
|
327
|
+
- `false` -- disable dark mode entirely
|
|
328
|
+
|
|
329
|
+
Hook options:
|
|
330
|
+
|
|
331
|
+
| Option | Type | Description |
|
|
332
|
+
|---|---|---|
|
|
333
|
+
| `generation` | `HextimateGenerationOptions` | Palette generation options |
|
|
334
|
+
| `format` | `Omit<HextimateFormatOptions, "as">` | Format options (output is always CSS vars) |
|
|
335
|
+
| `configure` | `(builder: HextimatePaletteBuilder) => void` | Customize the builder (add roles, tokens, presets) |
|
|
336
|
+
| `darkMode` | `DarkModeStrategy` | Dark mode strategy (see above) |
|
|
337
|
+
| `cssPrefix` | `string` | Prefix for all CSS variable names |
|
|
338
|
+
| `target` | `RefObject<HTMLElement>` | Inject variables into a specific element instead of `:root` |
|
|
213
339
|
|
|
214
|
-
|
|
340
|
+
### Provider
|
|
215
341
|
|
|
216
|
-
|
|
342
|
+
For app-wide theming with dynamic color changes:
|
|
217
343
|
|
|
218
344
|
```typescript
|
|
219
345
|
import { HextimatorProvider, useHextimatorTheme } from "hextimator/react";
|
|
220
346
|
|
|
221
|
-
|
|
222
|
-
|
|
347
|
+
<HextimatorProvider
|
|
348
|
+
defaultColor="#6A5ACD"
|
|
349
|
+
defaultMode="system" // "light" | "dark" | "system"
|
|
350
|
+
generation={generationOpts}
|
|
351
|
+
format={formatOpts}
|
|
352
|
+
configure={(b) => b.preset(presets.shadcn)}
|
|
353
|
+
darkMode={{ type: "class" }}
|
|
354
|
+
cssPrefix="app"
|
|
355
|
+
target={containerRef}
|
|
356
|
+
>
|
|
223
357
|
<App />
|
|
224
358
|
</HextimatorProvider>
|
|
225
|
-
|
|
226
|
-
// In children — setColor triggers re-generation
|
|
227
|
-
const { color, setColor, palette } = useHextimatorTheme();
|
|
228
359
|
```
|
|
229
360
|
|
|
361
|
+
`useHextimatorTheme()` returns:
|
|
362
|
+
|
|
363
|
+
| Property | Type | Description |
|
|
364
|
+
|---|---|---|
|
|
365
|
+
| `color` | `string` | Current input color |
|
|
366
|
+
| `setColor` | `(color: string) => void` | Change the input color (triggers re-generation) |
|
|
367
|
+
| `palette` | `HextimateResult` | The generated `{ light, dark }` palette |
|
|
368
|
+
| `mode` | `"light" \| "dark"` | Resolved color mode (accounts for OS preference) |
|
|
369
|
+
| `modePreference` | `"light" \| "dark" \| "system"` | Raw preference before resolution |
|
|
370
|
+
| `setMode` | `(mode: ModePreference) => void` | Change mode preference |
|
|
371
|
+
| `generation` | `HextimateGenerationOptions \| undefined` | Current generation options |
|
|
372
|
+
| `setGeneration` | `(opts) => void` | Update generation options |
|
|
373
|
+
| `configure` | `((builder) => void) \| undefined` | Current builder configure function |
|
|
374
|
+
| `setConfigure` | `(fn) => void` | Update the configure callback |
|
|
375
|
+
|
|
230
376
|
## Tailwind CSS v4
|
|
231
377
|
|
|
232
378
|
```css
|
|
@@ -234,7 +380,7 @@ const { color, setColor, palette } = useHextimatorTheme();
|
|
|
234
380
|
@import "hextimator/tailwind.css";
|
|
235
381
|
```
|
|
236
382
|
|
|
237
|
-
This registers all
|
|
383
|
+
This registers all built-in tokens as Tailwind utilities (`bg-accent`, `text-base-foreground`, etc.).
|
|
238
384
|
|
|
239
385
|
## Common recipes
|
|
240
386
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hextimator",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Generate perceptually uniform color palettes with light/dark themes and WCAG contrast guarantees from a single brand color. Outputs CSS vars, Tailwind, SCSS, or JSON.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"color",
|
package/tailwind.css
CHANGED
|
@@ -19,4 +19,6 @@
|
|
|
19
19
|
--color-warning-strong: var(--warning-strong);
|
|
20
20
|
--color-warning-weak: var(--warning-weak);
|
|
21
21
|
--color-warning-foreground: var(--warning-foreground);
|
|
22
|
+
--color-brand-exact: var(--brand-exact);
|
|
23
|
+
--color-brand-exact-foreground: var(--brand-exact-foreground);
|
|
22
24
|
}
|