hextimator 0.5.0 → 0.6.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/CHANGELOG.md +14 -4
- package/README.md +82 -18
- package/dist/{HextimatePaletteBuilder-C8I05ZmB.d.ts → HextimatePaletteBuilder-BH1jrzj7.d.ts} +35 -35
- package/dist/chunk-KFR2LTS2.js +183 -0
- package/dist/{chunk-HCVIQY7G.js → chunk-QQZBI4SO.js} +63 -233
- package/dist/cli.js +109 -103
- package/dist/index-Cd9eX-1l.d.ts +79 -0
- package/dist/index.d.ts +4 -79
- package/dist/index.js +4 -2
- package/dist/presets.d.ts +2 -0
- package/dist/presets.js +16 -0
- package/dist/react.d.ts +4 -4
- package/dist/react.js +2 -1
- package/fallback.css +12 -12
- package/llms.txt +40 -40
- package/package.json +19 -9
- package/tailwind.css +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
|
-
## 0.
|
|
1
|
+
## 0.6.0 (Latest)
|
|
2
2
|
|
|
3
|
-
- [#
|
|
3
|
+
- [#114](https://github.com/fgrgic/hextimator/pull/114) **Breaking**. Uses `surface` instead of `base` for the background tokens (e.g. `base-strong` → `surface-strong`). This avoids a class-name collision with Tailwind's built-in text-base font-size utility and makes the token name match its semantic purpose (the surface behind your content).
|
|
4
|
+
|
|
5
|
+
Migration checklist: [migration.md](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/migration.md).
|
|
6
|
+
|
|
7
|
+
## 0.5.1
|
|
8
|
+
|
|
9
|
+
- [#110](https://github.com/fgrgic/hextimator/pull/110): Add ./presets as a dedicated subpath export so `import { tinted } from 'hextimator/presets'` works
|
|
10
|
+
|
|
11
|
+
## 0.5.0
|
|
12
|
+
|
|
13
|
+
- [#108](https://github.com/fgrgic/hextimator/pull/108) **Breaking.** `.format({ as: "css" })` and `.format({ as: "tailwind-css" })` now return a ready-to-paste stylesheet **string** instead of a `{ light, dark }` map of CSS variable objects. Both themes are combined into one output and wrapped for dark mode according to the new `darkMode` option.
|
|
4
14
|
|
|
5
15
|
```ts
|
|
6
16
|
// Before (0.4)
|
|
@@ -19,7 +29,7 @@
|
|
|
19
29
|
- New CLI flags mirroring the options: `--dark-mode <strategy>` and `--selector <css>`. The `--theme` flag is ignored for `css`/`tailwind-css` outputs (both themes always combine into one string).
|
|
20
30
|
- React integration unchanged.
|
|
21
31
|
|
|
22
|
-
Migration checklist: [
|
|
32
|
+
Migration checklist: [migration.md](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/migration.md).
|
|
23
33
|
|
|
24
34
|
## 0.4.0
|
|
25
35
|
|
|
@@ -51,7 +61,7 @@
|
|
|
51
61
|
<HextimatorScope style={s} /> → <HextimatorScope wrapperStyle={s} />
|
|
52
62
|
```
|
|
53
63
|
|
|
54
|
-
Migration checklist: [
|
|
64
|
+
Migration checklist: [migration.md](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/migration.md).
|
|
55
65
|
|
|
56
66
|
## 0.2.0
|
|
57
67
|
|
package/README.md
CHANGED
|
@@ -6,15 +6,45 @@
|
|
|
6
6
|
</picture>
|
|
7
7
|
</p>
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Per-tenant themes from a single one brand color: Runtime theming for B2B2C and white-label apps.
|
|
10
10
|
|
|
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.
|
|
11
|
+
Your customers pick a brand color. Your app looks good. Every time. No per-customer design reviews, no manual tuning, no edge cases where "that shade of yellow" breaks your UI.
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
- **Every color just works** — perceptually uniform colors with OKLCH means that electric blue looks as balanced as muted olive.
|
|
15
|
-
- **Accessible by default** — every foreground meets AAA contrast against its background, light and dark mode included.
|
|
13
|
+
Ship multi-tenant apps without the design overhead:
|
|
16
14
|
|
|
17
|
-
**
|
|
15
|
+
- **Every color just works**. Perceptually uniform colors with OKLCH means that electric blue looks as balanced as muted olive.
|
|
16
|
+
- **Accessible by default**. Every foreground meets AAA contrast against its background, light and dark mode included.
|
|
17
|
+
|
|
18
|
+
Try it in the playground: **[hextimator.com](https://hextimator.com)**
|
|
19
|
+
|
|
20
|
+
## Why `hextimator` exists
|
|
21
|
+
|
|
22
|
+
You're building a B2B, a B2B2C, or a white-label app. Every tenant wants their own brand color in the app. The options today are:
|
|
23
|
+
|
|
24
|
+
1. **Let customers pick any hex.** It works until a partner's _legal-pad yellow_ renders your buttons unreadable, and their _cheeto dust tangerine_ toast makes it indistinguishable from a warning.
|
|
25
|
+
2. **Constrain them to a curated palette.** Now you need to tell a paying customer that their brand color isn't allowed. Or spend hours adjusting all the other colors by hand to make the theme somewhat work.
|
|
26
|
+
|
|
27
|
+
Hextimator is option 3. One color in, whole theme out. You get accent, semantic roles, light/dark palette, every foreground guaranteed to meet WCAG contrast against its background. Every time. Even for that yellow.
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import { hextimate } from "hextimator";
|
|
31
|
+
|
|
32
|
+
const tenantTheme = hextimate(tenant.brandColor).format({ as: "css" });
|
|
33
|
+
|
|
34
|
+
document.getElementById("tenant-theme").textContent = tenantTheme;
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
That's the integration. Swap the color, the theme regenerates at runtime, and the UI stays readable.
|
|
38
|
+
|
|
39
|
+
Using React? Even easier:
|
|
40
|
+
|
|
41
|
+
```jsx
|
|
42
|
+
<HextimatorProvider defaultColor={tenant.brandColor}>
|
|
43
|
+
<App />
|
|
44
|
+
</HextimatorProvider>
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
See full React integration guide [here](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/react.md).
|
|
18
48
|
|
|
19
49
|
## Installation
|
|
20
50
|
|
|
@@ -24,20 +54,38 @@ Add to your project:
|
|
|
24
54
|
npm i hextimator
|
|
25
55
|
```
|
|
26
56
|
|
|
27
|
-
|
|
57
|
+
**Using tailwind?**
|
|
58
|
+
make sure to include
|
|
28
59
|
|
|
29
|
-
```
|
|
30
|
-
|
|
60
|
+
```css
|
|
61
|
+
@import "hextimator/tailwind.css";
|
|
31
62
|
```
|
|
32
63
|
|
|
64
|
+
in your `index.css`
|
|
65
|
+
|
|
33
66
|
## Quick start
|
|
34
67
|
|
|
68
|
+
```bash
|
|
69
|
+
npm install hextimator
|
|
70
|
+
```
|
|
71
|
+
|
|
35
72
|
```typescript
|
|
36
73
|
import { hextimate } from "hextimator";
|
|
37
74
|
|
|
38
|
-
const theme = hextimate("#
|
|
75
|
+
const theme = hextimate("#6A5ACD").format();
|
|
76
|
+
// theme.light / theme.dark each contain your full theme tokens
|
|
39
77
|
```
|
|
40
78
|
|
|
79
|
+
### Multi-tenant app with React
|
|
80
|
+
|
|
81
|
+
```jsx
|
|
82
|
+
<HextimatorProvider defaultColor={tenant.brandColor}>
|
|
83
|
+
<App />
|
|
84
|
+
</HextimatorProvider>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
See full React integration guide [here](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/react.md).
|
|
88
|
+
|
|
41
89
|
### With presets
|
|
42
90
|
|
|
43
91
|
Presets are partial or full themes. You can chain them together, [extend them](#extending-presets), or not use them at all. They provide a starting point: whether for a specific framework or a particular style:
|
|
@@ -73,8 +121,8 @@ Presets can bring their own **`style`** (contrast, chroma, and other generation
|
|
|
73
121
|
|
|
74
122
|
```typescript
|
|
75
123
|
const theme = hextimate("#DEC0DE")
|
|
76
|
-
.preset(presets.tinted) // e.g. sets a looser
|
|
77
|
-
.style({
|
|
124
|
+
.preset(presets.tinted) // e.g. sets a looser surfaceMaxChroma
|
|
125
|
+
.style({ surfaceMaxChroma: 0.01 }) // tighten further for this app
|
|
78
126
|
.preset(presets.shadcn)
|
|
79
127
|
.format();
|
|
80
128
|
```
|
|
@@ -95,7 +143,7 @@ const theme = hextimate("#0FF5E7").format({ as: "css", colors: "oklch" });
|
|
|
95
143
|
|
|
96
144
|
```typescript
|
|
97
145
|
hextimate("#FACADE")
|
|
98
|
-
.style({ minContrastRatio: "AA",
|
|
146
|
+
.style({ minContrastRatio: "AA", surfaceMaxChroma: 0.02 })
|
|
99
147
|
.format();
|
|
100
148
|
```
|
|
101
149
|
|
|
@@ -116,7 +164,7 @@ hextimate("#F11732").format({
|
|
|
116
164
|
const myPreset: HextimatePreset = {
|
|
117
165
|
format: {
|
|
118
166
|
excludeRoles: ["warning"],
|
|
119
|
-
excludeVariants: ["
|
|
167
|
+
excludeVariants: ["weak"],
|
|
120
168
|
},
|
|
121
169
|
};
|
|
122
170
|
```
|
|
@@ -152,7 +200,7 @@ All formats return `{ light: { ... }, dark: { ... } }`.
|
|
|
152
200
|
|
|
153
201
|
Besides hex, **`hextimate`** accepts CSS color strings, RGB tuples, and numeric `0xRRGGBB`—anything **`parseColor`** understands.
|
|
154
202
|
|
|
155
|
-
> **Note on alpha**: Alpha values are intentionally ignored — `rgba(255, 0, 0, 0.5)` is treated as fully opaque `rgb(255, 0, 0)`. Alpha tokens undermine accessibility guarantees because contrast ratios depend on the background, which hextimator does not control.
|
|
203
|
+
> **Note on alpha**: Alpha values are intentionally ignored — `rgba(255, 0, 0, 0.5)` is treated as fully opaque `rgb(255, 0, 0)`. Alpha tokens undermine accessibility guarantees because contrast ratios depend on the background, which hextimator does not control. You can always add an opacity modifier later if you wish (e.g. `accent-weak/20` in tailwind).
|
|
156
204
|
|
|
157
205
|
Before `.format()` you can still chain **`addRole` / `addVariant` / `addToken`**, **`.preset()`**, **`.fork()`**, **`.simulate()` / `.adaptFor()`**, and anything else in [Extending the palette](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/extending-the-palette.md) or [Presets](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/presets.md).
|
|
158
206
|
|
|
@@ -160,7 +208,7 @@ Before `.format()` you can still chain **`addRole` / `addVariant` / `addToken`**
|
|
|
160
208
|
|
|
161
209
|
1. **Parse** any color input into a normalized `Color` object.
|
|
162
210
|
2. **Convert** to OKLCH (perceptual color space) so lightness and chroma adjustments look uniform across hues.
|
|
163
|
-
3. **Generate** accent,
|
|
211
|
+
3. **Generate** accent, surface, and semantic color scales — each with DEFAULT, strong, weak, and foreground variants.
|
|
164
212
|
4. **Gamut-map** back to sRGB via binary-search chroma reduction (preserves lightness and hue).
|
|
165
213
|
5. **Format** into your chosen output (CSS vars, Tailwind, SCSS, JSON, or plain object).
|
|
166
214
|
|
|
@@ -175,6 +223,22 @@ const color = parseColor("rgb(255, 102, 102)");
|
|
|
175
223
|
const oklch = convertColor(color, "oklch");
|
|
176
224
|
```
|
|
177
225
|
|
|
226
|
+
## CLI
|
|
227
|
+
|
|
228
|
+
Quickly get one-off themes from the terminal:
|
|
229
|
+
|
|
230
|
+
```sh
|
|
231
|
+
npx hextimate "#ff6677";
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
Get the full help running:
|
|
235
|
+
|
|
236
|
+
```
|
|
237
|
+
npx hextimate -h
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
> Note: `hextimate` and `hextimator` are the same CLI; pick whichever you like typing.
|
|
241
|
+
|
|
178
242
|
## React
|
|
179
243
|
|
|
180
244
|
Import from `hextimator/react`:
|
|
@@ -187,7 +251,7 @@ See **[React (full guide)](https://github.com/fgrgic/hextimator/blob/main/packag
|
|
|
187
251
|
|
|
188
252
|
### `fallback.css`
|
|
189
253
|
|
|
190
|
-
Pre-JS placeholder: neutral values for the same variables as default `hextimate()` (and `hextimator/tailwind.css`). Use in **client-rendered** apps so the first paint is not missing `--accent`, `--
|
|
254
|
+
Pre-JS placeholder: neutral values for the same variables as default `hextimate()` (and `hextimator/tailwind.css`). Use in **client-rendered** apps so the first paint is not missing `--accent`, `--surface`, etc. before your bundle runs; runtime theme CSS then replaces them. Import **before** `tailwind.css` if you use it.
|
|
191
255
|
|
|
192
256
|
```css
|
|
193
257
|
@import "hextimator/fallback.css";
|
|
@@ -198,7 +262,7 @@ Does not match **preset-only** token names (e.g. shadcn); use the CLI to generat
|
|
|
198
262
|
|
|
199
263
|
## Documentation
|
|
200
264
|
|
|
201
|
-
- [
|
|
265
|
+
- [Migration guide](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/migration.md) — breaking changes by version
|
|
202
266
|
- [Extending the palette](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/extending-the-palette.md) — `addRole`, `addVariant`, `addToken`
|
|
203
267
|
- [Presets](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/presets.md) — drop-in configs for shadcn/ui, or create your own
|
|
204
268
|
- [Multiple themes](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/multiple-themes.md) — dynamic theming and `.fork()`
|
package/dist/{HextimatePaletteBuilder-C8I05ZmB.d.ts → HextimatePaletteBuilder-BH1jrzj7.d.ts}
RENAMED
|
@@ -95,10 +95,10 @@ interface ThemeAdjustments {
|
|
|
95
95
|
*/
|
|
96
96
|
minContrastRatio?: 'AAA' | 'AA' | number;
|
|
97
97
|
/**
|
|
98
|
-
* Maximum chroma for the
|
|
99
|
-
* Overrides the global `
|
|
98
|
+
* Maximum chroma for the surface colors (surface, strong, weak) in this theme.
|
|
99
|
+
* Overrides the global `surfaceMaxChroma` for this theme only.
|
|
100
100
|
*/
|
|
101
|
-
|
|
101
|
+
surfaceMaxChroma?: number;
|
|
102
102
|
/**
|
|
103
103
|
* Maximum chroma for foreground colors in this theme.
|
|
104
104
|
* Overrides the global `foregroundMaxChroma` for this theme only.
|
|
@@ -110,23 +110,23 @@ interface ThemeAdjustments {
|
|
|
110
110
|
*/
|
|
111
111
|
interface HextimateStyleOptions {
|
|
112
112
|
/**
|
|
113
|
-
* Preferred
|
|
114
|
-
* It will be used as a baseline to generate the rest of
|
|
113
|
+
* Preferred surface color for dark and light mode.
|
|
114
|
+
* It will be used as a baseline to generate the rest of surface colors (strong, weak).
|
|
115
115
|
* If not provided, it will be derived from the main input color with very low chroma.
|
|
116
116
|
*
|
|
117
|
-
* Takes precedence over `
|
|
117
|
+
* Takes precedence over `surfaceHueShift` when both are set.
|
|
118
118
|
*/
|
|
119
|
-
|
|
119
|
+
surfaceColor?: ColorInput;
|
|
120
120
|
/**
|
|
121
|
-
* Rotate the
|
|
121
|
+
* Rotate the surface color's hue relative to the accent color (in degrees).
|
|
122
122
|
*
|
|
123
123
|
* Examples: 180 for complementary, 30 for analogous, -30 for the other direction.
|
|
124
124
|
*
|
|
125
|
-
* Ignored when an explicit `
|
|
125
|
+
* Ignored when an explicit `surfaceColor` is provided.
|
|
126
126
|
*
|
|
127
127
|
* Default: 0 (same hue as the accent).
|
|
128
128
|
*/
|
|
129
|
-
|
|
129
|
+
surfaceHueShift?: number;
|
|
130
130
|
/**
|
|
131
131
|
* Semantic colors to use for the theme
|
|
132
132
|
* If not provided, they will be generated from the provided main color,
|
|
@@ -139,12 +139,12 @@ interface HextimateStyleOptions {
|
|
|
139
139
|
};
|
|
140
140
|
/**
|
|
141
141
|
* Invert the hue used for the accent color in dark mode.
|
|
142
|
-
* Uses
|
|
143
|
-
* Only has effect if `
|
|
142
|
+
* Uses surface hue as accent, and accent hue as surface.
|
|
143
|
+
* Only has effect if `surfaceColor` is provided alongside the main accent color
|
|
144
144
|
*
|
|
145
145
|
* Default: false.
|
|
146
146
|
*/
|
|
147
|
-
|
|
147
|
+
invertDarkModeSurfaceAccent?: boolean;
|
|
148
148
|
/**
|
|
149
149
|
* Degree ranges for the semantic colors.
|
|
150
150
|
* Determines where to look for "green", "red", "yellow" in the color space.
|
|
@@ -159,14 +159,14 @@ interface HextimateStyleOptions {
|
|
|
159
159
|
warning?: [number, number];
|
|
160
160
|
};
|
|
161
161
|
/**
|
|
162
|
-
* Maximum chroma for the
|
|
163
|
-
* Higher values will produce more colorful
|
|
162
|
+
* Maximum chroma for the surface colors (surface, strong, weak).
|
|
163
|
+
* Higher values will produce more colorful surface colors, lower values will produce more gray surface colors.
|
|
164
164
|
*
|
|
165
165
|
* Default: 0.01.
|
|
166
166
|
*/
|
|
167
|
-
|
|
167
|
+
surfaceMaxChroma?: number;
|
|
168
168
|
/**
|
|
169
|
-
* Maximum chroma for all the foreground colors (e.g.
|
|
169
|
+
* Maximum chroma for all the foreground colors (e.g. surface-accent-foreground)
|
|
170
170
|
* Higher values will produce more colorful foreground colors, lower values will produce more gray foreground colors.
|
|
171
171
|
*
|
|
172
172
|
* Default: 0.01.
|
|
@@ -214,7 +214,7 @@ interface HextimateFormatOptions {
|
|
|
214
214
|
* Internal name → your custom name.
|
|
215
215
|
*
|
|
216
216
|
* Examples:
|
|
217
|
-
* -
|
|
217
|
+
* - surface: "bg"
|
|
218
218
|
* - accent: "button"
|
|
219
219
|
* - positive: "success"
|
|
220
220
|
* - negative: "error"
|
|
@@ -222,7 +222,7 @@ interface HextimateFormatOptions {
|
|
|
222
222
|
*
|
|
223
223
|
* If not provided, the default role names will be used.
|
|
224
224
|
* The default role names are:
|
|
225
|
-
* -
|
|
225
|
+
* - surface: "surface"
|
|
226
226
|
* - accent: "accent"
|
|
227
227
|
* - positive: "positive"
|
|
228
228
|
* - negative: "negative"
|
|
@@ -245,16 +245,16 @@ interface HextimateFormatOptions {
|
|
|
245
245
|
* If not provided, the default separator will be used.
|
|
246
246
|
* The default separator is: "-"
|
|
247
247
|
*
|
|
248
|
-
* Use "_" for "
|
|
248
|
+
* Use "_" for "surface_strong", "/" for "surface/strong", etc.
|
|
249
249
|
*/
|
|
250
250
|
separator?: string;
|
|
251
251
|
/**
|
|
252
252
|
* Output format.
|
|
253
|
-
* - "object" (default): {
|
|
253
|
+
* - "object" (default): { surface: "#f2eee8", "surface-strong": "#d4cfc8", ...}
|
|
254
254
|
* - "css": ready-to-paste CSS stylesheet string with `:root {}` and a dark-mode wrapper
|
|
255
|
-
* - "tailwind": {
|
|
256
|
-
* - "scss": { $
|
|
257
|
-
* - "json": '{ "
|
|
255
|
+
* - "tailwind": { surface: { DEFAULT: "#f2eee8", strong: "#d4cfc8", weak: "#faf8f6" } }
|
|
256
|
+
* - "scss": { $surface: "#f2eee8", $surface-strong: "#d4cfc8", ...}
|
|
257
|
+
* - "json": '{ "surface": "#f2eee8", "surface-strong": "#d4cfc8", ...}'
|
|
258
258
|
* - "tailwind-css": Tailwind v4 stylesheet string with a single `@theme { ... }` block and dark-mode overrides
|
|
259
259
|
*
|
|
260
260
|
* Stylesheet outputs (`css`, `tailwind-css`) combine light + dark into one
|
|
@@ -384,10 +384,10 @@ type VariantPlacement = {
|
|
|
384
384
|
* simple contrast adjustments.
|
|
385
385
|
*
|
|
386
386
|
* @example
|
|
387
|
-
* { from: "
|
|
387
|
+
* { from: "surface.weak", lightness: -0.05 }
|
|
388
388
|
* { from: "accent", hue: -20 }
|
|
389
|
-
* { from: "
|
|
390
|
-
* { from: "
|
|
389
|
+
* { from: "surface", emphasis: 0.12 }
|
|
390
|
+
* { from: "surface.foreground", emphasis: -0.2 }
|
|
391
391
|
*/
|
|
392
392
|
interface DerivedToken {
|
|
393
393
|
from: string;
|
|
@@ -402,7 +402,7 @@ interface DerivedToken {
|
|
|
402
402
|
* @example
|
|
403
403
|
* "#FF6600"
|
|
404
404
|
* { from: "accent", lightness: +0.1 }
|
|
405
|
-
* { light: { from: "
|
|
405
|
+
* { light: { from: "surface.weak", lightness: -0.05 }, dark: { from: "surface.weak", lightness: +0.05 } }
|
|
406
406
|
*/
|
|
407
407
|
type TokenValue = ColorInput | DerivedToken | {
|
|
408
408
|
light: DerivedToken | ColorInput;
|
|
@@ -421,7 +421,7 @@ declare class HextimatePaletteBuilder {
|
|
|
421
421
|
private presetFormatDefaults?;
|
|
422
422
|
constructor(color: Color);
|
|
423
423
|
/**
|
|
424
|
-
* Merges style options into the builder and regenerates the
|
|
424
|
+
* Merges style options into the builder and regenerates the palettes,
|
|
425
425
|
* then replays recorded operations so roles and variants reflect the new style.
|
|
426
426
|
*/
|
|
427
427
|
style(partial: Partial<HextimateStyleOptions>): this;
|
|
@@ -434,7 +434,7 @@ declare class HextimatePaletteBuilder {
|
|
|
434
434
|
*
|
|
435
435
|
* The color can be a direct color value or a derived token referencing an existing role.
|
|
436
436
|
*
|
|
437
|
-
* e.g. `addRole('cta', '#ff0066')` adds a "cta" role with the specified
|
|
437
|
+
* e.g. `addRole('cta', '#ff0066')` adds a "cta" role with the specified color.
|
|
438
438
|
* `addRole('cta', { from: 'accent', hue: 180 })` adds a "cta" role with a complementary hue to accent.
|
|
439
439
|
*
|
|
440
440
|
* @param name Role name (e.g. "cta", "banner")
|
|
@@ -459,7 +459,7 @@ declare class HextimatePaletteBuilder {
|
|
|
459
459
|
* `addToken('brand', { light: '#3a86ff', dark: '#ff0066' })` adds a "brand" token with different colors in light and dark themes.
|
|
460
460
|
*
|
|
461
461
|
* It can also be used to override specific tokens after generation.
|
|
462
|
-
* `addToken('
|
|
462
|
+
* `addToken('surface-strong', '#ff0066')` overrides the automatically generated "surface-strong" variant with a custom color.
|
|
463
463
|
*
|
|
464
464
|
* @param name Token name (e.g. "brand", "logo")
|
|
465
465
|
* @param value Token value, which can be an exact color, or derived from an existing role+variant.
|
|
@@ -469,7 +469,7 @@ declare class HextimatePaletteBuilder {
|
|
|
469
469
|
* Applies a preset that configures roles, tokens, and format defaults
|
|
470
470
|
* for a specific framework or convention (e.g. shadcn/ui).
|
|
471
471
|
*
|
|
472
|
-
* Preset format defaults are used as
|
|
472
|
+
* Preset format defaults are used as defaults in `.format()` — any options
|
|
473
473
|
* you pass to `.format()` will override the preset's defaults.
|
|
474
474
|
*
|
|
475
475
|
* @example
|
|
@@ -490,7 +490,7 @@ declare class HextimatePaletteBuilder {
|
|
|
490
490
|
* Does not merge `preset.style` — used when replaying onto a builder whose `this.options` already reflect merged style.
|
|
491
491
|
*/
|
|
492
492
|
private recordPresetWithoutStyleMerge;
|
|
493
|
-
/** Roles, variants, tokens, and format only — `this.options` and
|
|
493
|
+
/** Roles, variants, tokens, and format only — `this.options` and palettes are already correct. */
|
|
494
494
|
private applyPresetRolesTokensFormat;
|
|
495
495
|
/**
|
|
496
496
|
*
|
|
@@ -525,7 +525,7 @@ declare class HextimatePaletteBuilder {
|
|
|
525
525
|
*/
|
|
526
526
|
adaptFor(type: CVDType, severity?: number): this;
|
|
527
527
|
/**
|
|
528
|
-
* Creates a new builder instance with the same operations history, optionally from a different
|
|
528
|
+
* Creates a new builder instance with the same operations history, optionally from a different accent color.
|
|
529
529
|
* To change style options on the fork, chain `.style()` after `.fork()`.
|
|
530
530
|
*
|
|
531
531
|
* @param color Optional new accent/brand color. If omitted, the fork uses the same color as this builder.
|
|
@@ -576,4 +576,4 @@ declare class HextimatePaletteBuilder {
|
|
|
576
576
|
private resolvedOptions;
|
|
577
577
|
}
|
|
578
578
|
|
|
579
|
-
export { type Color as C, type DerivedToken as D, type FlatTokenMap as F,
|
|
579
|
+
export { type Color as C, type DerivedToken as D, type FlatTokenMap as F, HextimatePaletteBuilder as H, type NestedTokenMap as N, type OKLCH as O, type ThemeAdjustments as T, type VariantPlacement as V, type CVDType as a, type ColorSpace as b, type ColorInSpace as c, type ColorInput as d, type FormatResult as e, type HextimateFormatOptions as f, type HextimateOptions as g, type HextimatePreset as h, type HextimateResult as i, type HextimateStyleOptions as j, type TokenValue as k };
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __export = (target, all) => {
|
|
3
|
+
for (var name in all)
|
|
4
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
// src/presets/index.ts
|
|
8
|
+
var presets_exports = {};
|
|
9
|
+
__export(presets_exports, {
|
|
10
|
+
bold: () => bold,
|
|
11
|
+
mui: () => mui,
|
|
12
|
+
muted: () => muted,
|
|
13
|
+
shadcn: () => shadcn,
|
|
14
|
+
tinted: () => tinted,
|
|
15
|
+
vibrant: () => vibrant
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
// src/presets/bold.ts
|
|
19
|
+
var bold = {
|
|
20
|
+
style: {
|
|
21
|
+
light: { lightness: 0.5 },
|
|
22
|
+
dark: { lightness: 0.8 },
|
|
23
|
+
surfaceMaxChroma: 0.06,
|
|
24
|
+
foregroundMaxChroma: 0.02
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// src/presets/mui.ts
|
|
29
|
+
var mui = {
|
|
30
|
+
roles: [
|
|
31
|
+
{ name: "info", color: "#0288d1" },
|
|
32
|
+
{ name: "secondary", color: { from: "accent", hue: 180 } }
|
|
33
|
+
],
|
|
34
|
+
tokens: [
|
|
35
|
+
// background
|
|
36
|
+
{ name: "background-default", value: { from: "surface" } },
|
|
37
|
+
{
|
|
38
|
+
name: "background-paper",
|
|
39
|
+
value: { from: "surface", emphasis: -0.025 }
|
|
40
|
+
},
|
|
41
|
+
// text
|
|
42
|
+
{ name: "text-primary", value: { from: "surface.foreground" } },
|
|
43
|
+
{
|
|
44
|
+
name: "text-secondary",
|
|
45
|
+
value: { from: "surface.foreground", emphasis: -0.2 }
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: "text-disabled",
|
|
49
|
+
value: { from: "surface.foreground", emphasis: -0.4 }
|
|
50
|
+
},
|
|
51
|
+
// divider
|
|
52
|
+
{ name: "divider", value: { from: "surface", emphasis: 0.12 } },
|
|
53
|
+
// action tokens
|
|
54
|
+
{ name: "action-hover", value: { from: "surface", emphasis: 0.04 } },
|
|
55
|
+
{ name: "action-selected", value: { from: "surface", emphasis: 0.08 } },
|
|
56
|
+
{ name: "action-disabled", value: { from: "surface", emphasis: 0.15 } },
|
|
57
|
+
{
|
|
58
|
+
name: "action-disabledBackground",
|
|
59
|
+
value: { from: "surface", emphasis: 0.06 }
|
|
60
|
+
},
|
|
61
|
+
{ name: "action-focus", value: { from: "surface", emphasis: 0.06 } }
|
|
62
|
+
],
|
|
63
|
+
format: {
|
|
64
|
+
as: "object",
|
|
65
|
+
colors: "hex",
|
|
66
|
+
separator: "-",
|
|
67
|
+
roleNames: {
|
|
68
|
+
accent: "primary",
|
|
69
|
+
negative: "error",
|
|
70
|
+
positive: "success"
|
|
71
|
+
},
|
|
72
|
+
variantNames: {
|
|
73
|
+
DEFAULT: "main",
|
|
74
|
+
weak: "light",
|
|
75
|
+
strong: "dark",
|
|
76
|
+
foreground: "contrastText"
|
|
77
|
+
},
|
|
78
|
+
excludeRoles: ["surface"]
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
// src/presets/muted.ts
|
|
83
|
+
var muted = {
|
|
84
|
+
style: {
|
|
85
|
+
light: { maxChroma: 0.08 },
|
|
86
|
+
dark: { maxChroma: 0.07 },
|
|
87
|
+
surfaceMaxChroma: 5e-3,
|
|
88
|
+
foregroundMaxChroma: 5e-3
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
// src/presets/shadcn.ts
|
|
93
|
+
var shadcn = {
|
|
94
|
+
tokens: [
|
|
95
|
+
// shadcn uses bare --foreground (not --background-foreground)
|
|
96
|
+
{ name: "foreground", value: { from: "surface.foreground" } },
|
|
97
|
+
// card / popover — same as background
|
|
98
|
+
{ name: "card", value: { from: "surface" } },
|
|
99
|
+
{ name: "card-foreground", value: { from: "surface.foreground" } },
|
|
100
|
+
{ name: "popover", value: { from: "surface" } },
|
|
101
|
+
{ name: "popover-foreground", value: { from: "surface.foreground" } },
|
|
102
|
+
// secondary — subtle contrast from background
|
|
103
|
+
{ name: "secondary", value: { from: "surface" } },
|
|
104
|
+
{ name: "secondary-foreground", value: { from: "surface.foreground" } },
|
|
105
|
+
// muted — similar to secondary, but with dimmer foreground
|
|
106
|
+
{ name: "muted", value: { from: "surface" } },
|
|
107
|
+
{
|
|
108
|
+
name: "muted-foreground",
|
|
109
|
+
value: {
|
|
110
|
+
from: "surface.foreground",
|
|
111
|
+
emphasis: -0.25
|
|
112
|
+
}
|
|
113
|
+
},
|
|
114
|
+
// accent (shadcn meaning: subtle hover highlight, not the brand color)
|
|
115
|
+
{ name: "accent", value: { from: "surface" } },
|
|
116
|
+
{ name: "accent-foreground", value: { from: "surface.foreground" } },
|
|
117
|
+
// border / input
|
|
118
|
+
{
|
|
119
|
+
name: "border",
|
|
120
|
+
value: { from: "surface", emphasis: 0.8 }
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
name: "input",
|
|
124
|
+
value: {
|
|
125
|
+
from: "surface",
|
|
126
|
+
emphasis: 0.8
|
|
127
|
+
}
|
|
128
|
+
},
|
|
129
|
+
// ring — uses the brand/primary color
|
|
130
|
+
{ name: "ring", value: { from: "accent" } },
|
|
131
|
+
// chart tokens colors use brand/priamry color
|
|
132
|
+
{ name: "chart-1", value: { from: "accent" } },
|
|
133
|
+
{ name: "chart-2", value: { from: "chart-1", emphasis: -0.04 } },
|
|
134
|
+
{ name: "chart-3", value: { from: "chart-2", emphasis: -0.04 } },
|
|
135
|
+
{ name: "chart-4", value: { from: "chart-3", emphasis: -0.04 } },
|
|
136
|
+
{ name: "chart-5", value: { from: "chart-4", emphasis: -0.04 } }
|
|
137
|
+
],
|
|
138
|
+
format: {
|
|
139
|
+
as: "css",
|
|
140
|
+
colors: "oklch",
|
|
141
|
+
roleNames: {
|
|
142
|
+
surface: "background",
|
|
143
|
+
accent: "primary",
|
|
144
|
+
negative: "destructive",
|
|
145
|
+
positive: "success"
|
|
146
|
+
},
|
|
147
|
+
variantNames: {
|
|
148
|
+
foreground: "foreground"
|
|
149
|
+
},
|
|
150
|
+
excludeRoles: ["warning"],
|
|
151
|
+
excludeVariants: ["strong", "weak"]
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
// src/presets/tinted.ts
|
|
156
|
+
var tinted = {
|
|
157
|
+
style: {
|
|
158
|
+
surfaceMaxChroma: 0.05,
|
|
159
|
+
surfaceHueShift: 0,
|
|
160
|
+
foregroundMaxChroma: 0.015
|
|
161
|
+
}
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
// src/presets/vibrant.ts
|
|
165
|
+
var vibrant = {
|
|
166
|
+
style: {
|
|
167
|
+
light: { maxChroma: 0.2, lightness: 0.6 },
|
|
168
|
+
dark: { maxChroma: 0.18, lightness: 0.65 },
|
|
169
|
+
hueShift: 5,
|
|
170
|
+
surfaceHueShift: 180,
|
|
171
|
+
surfaceMaxChroma: 0.08
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
export {
|
|
176
|
+
bold,
|
|
177
|
+
mui,
|
|
178
|
+
muted,
|
|
179
|
+
shadcn,
|
|
180
|
+
tinted,
|
|
181
|
+
vibrant,
|
|
182
|
+
presets_exports
|
|
183
|
+
};
|