hextimator 0.5.1 → 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 +9 -3
- package/README.md +7 -7
- package/dist/{HextimatePaletteBuilder-BY1EjhFs.d.ts → HextimatePaletteBuilder-BH1jrzj7.d.ts} +34 -34
- package/dist/{chunk-JODPLAXA.js → chunk-KFR2LTS2.js} +32 -32
- package/dist/{chunk-RAI6L6AN.js → chunk-QQZBI4SO.js} +63 -58
- package/dist/cli.js +109 -103
- package/dist/{index-C2l4fSiA.d.ts → index-Cd9eX-1l.d.ts} +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/presets.d.ts +2 -2
- package/dist/presets.js +1 -1
- package/dist/react.d.ts +4 -4
- package/dist/react.js +2 -2
- package/fallback.css +12 -12
- package/llms.txt +40 -40
- package/package.json +1 -1
- package/tailwind.css +4 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
## 0.
|
|
1
|
+
## 0.6.0 (Latest)
|
|
2
|
+
|
|
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
|
|
2
8
|
|
|
3
9
|
- [#110](https://github.com/fgrgic/hextimator/pull/110): Add ./presets as a dedicated subpath export so `import { tinted } from 'hextimator/presets'` works
|
|
4
10
|
|
|
@@ -23,7 +29,7 @@
|
|
|
23
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).
|
|
24
30
|
- React integration unchanged.
|
|
25
31
|
|
|
26
|
-
Migration checklist: [
|
|
32
|
+
Migration checklist: [migration.md](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/migration.md).
|
|
27
33
|
|
|
28
34
|
## 0.4.0
|
|
29
35
|
|
|
@@ -55,7 +61,7 @@
|
|
|
55
61
|
<HextimatorScope style={s} /> → <HextimatorScope wrapperStyle={s} />
|
|
56
62
|
```
|
|
57
63
|
|
|
58
|
-
Migration checklist: [
|
|
64
|
+
Migration checklist: [migration.md](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/migration.md).
|
|
59
65
|
|
|
60
66
|
## 0.2.0
|
|
61
67
|
|
package/README.md
CHANGED
|
@@ -121,8 +121,8 @@ Presets can bring their own **`style`** (contrast, chroma, and other generation
|
|
|
121
121
|
|
|
122
122
|
```typescript
|
|
123
123
|
const theme = hextimate("#DEC0DE")
|
|
124
|
-
.preset(presets.tinted) // e.g. sets a looser
|
|
125
|
-
.style({
|
|
124
|
+
.preset(presets.tinted) // e.g. sets a looser surfaceMaxChroma
|
|
125
|
+
.style({ surfaceMaxChroma: 0.01 }) // tighten further for this app
|
|
126
126
|
.preset(presets.shadcn)
|
|
127
127
|
.format();
|
|
128
128
|
```
|
|
@@ -143,7 +143,7 @@ const theme = hextimate("#0FF5E7").format({ as: "css", colors: "oklch" });
|
|
|
143
143
|
|
|
144
144
|
```typescript
|
|
145
145
|
hextimate("#FACADE")
|
|
146
|
-
.style({ minContrastRatio: "AA",
|
|
146
|
+
.style({ minContrastRatio: "AA", surfaceMaxChroma: 0.02 })
|
|
147
147
|
.format();
|
|
148
148
|
```
|
|
149
149
|
|
|
@@ -200,7 +200,7 @@ All formats return `{ light: { ... }, dark: { ... } }`.
|
|
|
200
200
|
|
|
201
201
|
Besides hex, **`hextimate`** accepts CSS color strings, RGB tuples, and numeric `0xRRGGBB`—anything **`parseColor`** understands.
|
|
202
202
|
|
|
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. `
|
|
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).
|
|
204
204
|
|
|
205
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).
|
|
206
206
|
|
|
@@ -208,7 +208,7 @@ Before `.format()` you can still chain **`addRole` / `addVariant` / `addToken`**
|
|
|
208
208
|
|
|
209
209
|
1. **Parse** any color input into a normalized `Color` object.
|
|
210
210
|
2. **Convert** to OKLCH (perceptual color space) so lightness and chroma adjustments look uniform across hues.
|
|
211
|
-
3. **Generate** accent,
|
|
211
|
+
3. **Generate** accent, surface, and semantic color scales — each with DEFAULT, strong, weak, and foreground variants.
|
|
212
212
|
4. **Gamut-map** back to sRGB via binary-search chroma reduction (preserves lightness and hue).
|
|
213
213
|
5. **Format** into your chosen output (CSS vars, Tailwind, SCSS, JSON, or plain object).
|
|
214
214
|
|
|
@@ -251,7 +251,7 @@ See **[React (full guide)](https://github.com/fgrgic/hextimator/blob/main/packag
|
|
|
251
251
|
|
|
252
252
|
### `fallback.css`
|
|
253
253
|
|
|
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`, `--
|
|
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.
|
|
255
255
|
|
|
256
256
|
```css
|
|
257
257
|
@import "hextimator/fallback.css";
|
|
@@ -262,7 +262,7 @@ Does not match **preset-only** token names (e.g. shadcn); use the CLI to generat
|
|
|
262
262
|
|
|
263
263
|
## Documentation
|
|
264
264
|
|
|
265
|
-
- [
|
|
265
|
+
- [Migration guide](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/migration.md) — breaking changes by version
|
|
266
266
|
- [Extending the palette](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/extending-the-palette.md) — `addRole`, `addVariant`, `addToken`
|
|
267
267
|
- [Presets](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/presets.md) — drop-in configs for shadcn/ui, or create your own
|
|
268
268
|
- [Multiple themes](https://github.com/fgrgic/hextimator/blob/main/packages/hextimator/docs/multiple-themes.md) — dynamic theming and `.fork()`
|
package/dist/{HextimatePaletteBuilder-BY1EjhFs.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.
|
|
@@ -20,7 +20,7 @@ var bold = {
|
|
|
20
20
|
style: {
|
|
21
21
|
light: { lightness: 0.5 },
|
|
22
22
|
dark: { lightness: 0.8 },
|
|
23
|
-
|
|
23
|
+
surfaceMaxChroma: 0.06,
|
|
24
24
|
foregroundMaxChroma: 0.02
|
|
25
25
|
}
|
|
26
26
|
};
|
|
@@ -33,32 +33,32 @@ var mui = {
|
|
|
33
33
|
],
|
|
34
34
|
tokens: [
|
|
35
35
|
// background
|
|
36
|
-
{ name: "background-default", value: { from: "
|
|
36
|
+
{ name: "background-default", value: { from: "surface" } },
|
|
37
37
|
{
|
|
38
38
|
name: "background-paper",
|
|
39
|
-
value: { from: "
|
|
39
|
+
value: { from: "surface", emphasis: -0.025 }
|
|
40
40
|
},
|
|
41
41
|
// text
|
|
42
|
-
{ name: "text-primary", value: { from: "
|
|
42
|
+
{ name: "text-primary", value: { from: "surface.foreground" } },
|
|
43
43
|
{
|
|
44
44
|
name: "text-secondary",
|
|
45
|
-
value: { from: "
|
|
45
|
+
value: { from: "surface.foreground", emphasis: -0.2 }
|
|
46
46
|
},
|
|
47
47
|
{
|
|
48
48
|
name: "text-disabled",
|
|
49
|
-
value: { from: "
|
|
49
|
+
value: { from: "surface.foreground", emphasis: -0.4 }
|
|
50
50
|
},
|
|
51
51
|
// divider
|
|
52
|
-
{ name: "divider", value: { from: "
|
|
52
|
+
{ name: "divider", value: { from: "surface", emphasis: 0.12 } },
|
|
53
53
|
// action tokens
|
|
54
|
-
{ name: "action-hover", value: { from: "
|
|
55
|
-
{ name: "action-selected", value: { from: "
|
|
56
|
-
{ name: "action-disabled", value: { from: "
|
|
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
57
|
{
|
|
58
58
|
name: "action-disabledBackground",
|
|
59
|
-
value: { from: "
|
|
59
|
+
value: { from: "surface", emphasis: 0.06 }
|
|
60
60
|
},
|
|
61
|
-
{ name: "action-focus", value: { from: "
|
|
61
|
+
{ name: "action-focus", value: { from: "surface", emphasis: 0.06 } }
|
|
62
62
|
],
|
|
63
63
|
format: {
|
|
64
64
|
as: "object",
|
|
@@ -75,7 +75,7 @@ var mui = {
|
|
|
75
75
|
strong: "dark",
|
|
76
76
|
foreground: "contrastText"
|
|
77
77
|
},
|
|
78
|
-
excludeRoles: ["
|
|
78
|
+
excludeRoles: ["surface"]
|
|
79
79
|
}
|
|
80
80
|
};
|
|
81
81
|
|
|
@@ -84,7 +84,7 @@ var muted = {
|
|
|
84
84
|
style: {
|
|
85
85
|
light: { maxChroma: 0.08 },
|
|
86
86
|
dark: { maxChroma: 0.07 },
|
|
87
|
-
|
|
87
|
+
surfaceMaxChroma: 5e-3,
|
|
88
88
|
foregroundMaxChroma: 5e-3
|
|
89
89
|
}
|
|
90
90
|
};
|
|
@@ -93,36 +93,36 @@ var muted = {
|
|
|
93
93
|
var shadcn = {
|
|
94
94
|
tokens: [
|
|
95
95
|
// shadcn uses bare --foreground (not --background-foreground)
|
|
96
|
-
{ name: "foreground", value: { from: "
|
|
96
|
+
{ name: "foreground", value: { from: "surface.foreground" } },
|
|
97
97
|
// card / popover — same as background
|
|
98
|
-
{ name: "card", value: { from: "
|
|
99
|
-
{ name: "card-foreground", value: { from: "
|
|
100
|
-
{ name: "popover", value: { from: "
|
|
101
|
-
{ name: "popover-foreground", value: { from: "
|
|
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
102
|
// secondary — subtle contrast from background
|
|
103
|
-
{ name: "secondary", value: { from: "
|
|
104
|
-
{ name: "secondary-foreground", value: { from: "
|
|
103
|
+
{ name: "secondary", value: { from: "surface" } },
|
|
104
|
+
{ name: "secondary-foreground", value: { from: "surface.foreground" } },
|
|
105
105
|
// muted — similar to secondary, but with dimmer foreground
|
|
106
|
-
{ name: "muted", value: { from: "
|
|
106
|
+
{ name: "muted", value: { from: "surface" } },
|
|
107
107
|
{
|
|
108
108
|
name: "muted-foreground",
|
|
109
109
|
value: {
|
|
110
|
-
from: "
|
|
110
|
+
from: "surface.foreground",
|
|
111
111
|
emphasis: -0.25
|
|
112
112
|
}
|
|
113
113
|
},
|
|
114
114
|
// accent (shadcn meaning: subtle hover highlight, not the brand color)
|
|
115
|
-
{ name: "accent", value: { from: "
|
|
116
|
-
{ name: "accent-foreground", value: { from: "
|
|
115
|
+
{ name: "accent", value: { from: "surface" } },
|
|
116
|
+
{ name: "accent-foreground", value: { from: "surface.foreground" } },
|
|
117
117
|
// border / input
|
|
118
118
|
{
|
|
119
119
|
name: "border",
|
|
120
|
-
value: { from: "
|
|
120
|
+
value: { from: "surface", emphasis: 0.8 }
|
|
121
121
|
},
|
|
122
122
|
{
|
|
123
123
|
name: "input",
|
|
124
124
|
value: {
|
|
125
|
-
from: "
|
|
125
|
+
from: "surface",
|
|
126
126
|
emphasis: 0.8
|
|
127
127
|
}
|
|
128
128
|
},
|
|
@@ -139,7 +139,7 @@ var shadcn = {
|
|
|
139
139
|
as: "css",
|
|
140
140
|
colors: "oklch",
|
|
141
141
|
roleNames: {
|
|
142
|
-
|
|
142
|
+
surface: "background",
|
|
143
143
|
accent: "primary",
|
|
144
144
|
negative: "destructive",
|
|
145
145
|
positive: "success"
|
|
@@ -155,8 +155,8 @@ var shadcn = {
|
|
|
155
155
|
// src/presets/tinted.ts
|
|
156
156
|
var tinted = {
|
|
157
157
|
style: {
|
|
158
|
-
|
|
159
|
-
|
|
158
|
+
surfaceMaxChroma: 0.05,
|
|
159
|
+
surfaceHueShift: 0,
|
|
160
160
|
foregroundMaxChroma: 0.015
|
|
161
161
|
}
|
|
162
162
|
};
|
|
@@ -167,8 +167,8 @@ var vibrant = {
|
|
|
167
167
|
light: { maxChroma: 0.2, lightness: 0.6 },
|
|
168
168
|
dark: { maxChroma: 0.18, lightness: 0.65 },
|
|
169
169
|
hueShift: 5,
|
|
170
|
-
|
|
171
|
-
|
|
170
|
+
surfaceHueShift: 180,
|
|
171
|
+
surfaceMaxChroma: 0.08
|
|
172
172
|
}
|
|
173
173
|
};
|
|
174
174
|
|
|
@@ -1232,20 +1232,20 @@ function calculateContrast(colorA, colorB) {
|
|
|
1232
1232
|
|
|
1233
1233
|
// src/generate/generateAccent.ts
|
|
1234
1234
|
function generateAccent(accent, themeType, options) {
|
|
1235
|
-
const
|
|
1236
|
-
if (
|
|
1235
|
+
const invertSurfaceAndAccent = themeType === "dark" && options?.invertDarkModeSurfaceAccent;
|
|
1236
|
+
if (invertSurfaceAndAccent) {
|
|
1237
1237
|
const accentOklch = convert(accent, "oklch");
|
|
1238
|
-
const
|
|
1239
|
-
let
|
|
1240
|
-
if (
|
|
1241
|
-
|
|
1242
|
-
...
|
|
1243
|
-
h: wrapHue(accentOklch.h +
|
|
1238
|
+
const surfaceHueShift = options?.surfaceHueShift ?? 0;
|
|
1239
|
+
let surfaceOklch = options?.surfaceColor ? convert(parse(options.surfaceColor), "oklch") : convert(accent, "oklch");
|
|
1240
|
+
if (surfaceHueShift !== 0 && !options?.surfaceColor) {
|
|
1241
|
+
surfaceOklch = {
|
|
1242
|
+
...surfaceOklch,
|
|
1243
|
+
h: wrapHue(accentOklch.h + surfaceHueShift)
|
|
1244
1244
|
};
|
|
1245
1245
|
}
|
|
1246
1246
|
const maxChroma = options?.dark?.maxChroma;
|
|
1247
1247
|
const invertedAccent = {
|
|
1248
|
-
...
|
|
1248
|
+
...surfaceOklch,
|
|
1249
1249
|
c: maxChroma !== void 0 ? Math.min(accentOklch.c, maxChroma) : accentOklch.c
|
|
1250
1250
|
};
|
|
1251
1251
|
return expandColorToScale(invertedAccent, themeType, options);
|
|
@@ -1253,47 +1253,6 @@ function generateAccent(accent, themeType, options) {
|
|
|
1253
1253
|
return expandColorToScale(accent, themeType, options);
|
|
1254
1254
|
}
|
|
1255
1255
|
|
|
1256
|
-
// src/generate/generateBase.ts
|
|
1257
|
-
var BASELINE_DARK_L_VALUE = 0.2;
|
|
1258
|
-
var BASELINE_LIGHT_L_VALUE = 0.97;
|
|
1259
|
-
var BASELINE_MAX_CHROMA = 0.01;
|
|
1260
|
-
var STRONG_DELTA_DARK = -0.1;
|
|
1261
|
-
var STRONG_DELTA_LIGHT = 0.02;
|
|
1262
|
-
var WEAK_DELTA_DARK = 0.1;
|
|
1263
|
-
var WEAK_DELTA_LIGHT = -0.03;
|
|
1264
|
-
function generateBase(color, themeType, options) {
|
|
1265
|
-
const invertBaseAndAccent = themeType === "dark" && options?.invertDarkModeBaseAccent;
|
|
1266
|
-
const preferredBaseColorInput = invertBaseAndAccent ? color ?? options?.baseColor : options?.baseColor ?? color;
|
|
1267
|
-
const themeAdjustments = themeType === "light" ? options?.light : options?.dark;
|
|
1268
|
-
const baselineMaxChroma = themeAdjustments?.baseMaxChroma ?? options?.baseMaxChroma ?? BASELINE_MAX_CHROMA;
|
|
1269
|
-
const preferredBaseColor = convert(parse(preferredBaseColorInput), "oklch");
|
|
1270
|
-
let baseHue = preferredBaseColor.h;
|
|
1271
|
-
const baseChroma = Math.min(preferredBaseColor.c, baselineMaxChroma);
|
|
1272
|
-
const baseHueShift = options?.baseHueShift ?? 0;
|
|
1273
|
-
if (baseHueShift !== 0 && !options?.baseColor && !invertBaseAndAccent) {
|
|
1274
|
-
baseHue = wrapHue(convert(color, "oklch").h + baseHueShift);
|
|
1275
|
-
}
|
|
1276
|
-
const normalizedPreferredBaseColor = {
|
|
1277
|
-
...preferredBaseColor,
|
|
1278
|
-
h: baseHue,
|
|
1279
|
-
c: baseChroma,
|
|
1280
|
-
l: themeType === "light" ? BASELINE_LIGHT_L_VALUE : BASELINE_DARK_L_VALUE
|
|
1281
|
-
};
|
|
1282
|
-
return expandColorToScale(normalizedPreferredBaseColor, themeType, {
|
|
1283
|
-
baselineLValueDark: BASELINE_DARK_L_VALUE,
|
|
1284
|
-
baselineLValueLight: BASELINE_LIGHT_L_VALUE,
|
|
1285
|
-
strongDeltaDark: STRONG_DELTA_DARK,
|
|
1286
|
-
strongDeltaLight: STRONG_DELTA_LIGHT,
|
|
1287
|
-
weakDeltaDark: WEAK_DELTA_DARK,
|
|
1288
|
-
weakDeltaLight: WEAK_DELTA_LIGHT,
|
|
1289
|
-
minContrastRatio: options?.minContrastRatio,
|
|
1290
|
-
hueShift: options?.hueShift,
|
|
1291
|
-
foregroundMaxChroma: options?.foregroundMaxChroma,
|
|
1292
|
-
light: options?.light,
|
|
1293
|
-
dark: options?.dark
|
|
1294
|
-
});
|
|
1295
|
-
}
|
|
1296
|
-
|
|
1297
1256
|
// src/generate/generateSemanticColors.ts
|
|
1298
1257
|
var POSITIVE_RANGE = [135, 160];
|
|
1299
1258
|
var NEGATIVE_RANGE = [5, 25];
|
|
@@ -1395,10 +1354,54 @@ function _getSplitComplementaryColors(color) {
|
|
|
1395
1354
|
];
|
|
1396
1355
|
}
|
|
1397
1356
|
|
|
1357
|
+
// src/generate/generateSurface.ts
|
|
1358
|
+
var BASELINE_DARK_L_VALUE = 0.2;
|
|
1359
|
+
var BASELINE_LIGHT_L_VALUE = 0.97;
|
|
1360
|
+
var BASELINE_MAX_CHROMA = 0.01;
|
|
1361
|
+
var STRONG_DELTA_DARK = -0.1;
|
|
1362
|
+
var STRONG_DELTA_LIGHT = 0.02;
|
|
1363
|
+
var WEAK_DELTA_DARK = 0.1;
|
|
1364
|
+
var WEAK_DELTA_LIGHT = -0.03;
|
|
1365
|
+
function generateSurface(color, themeType, options) {
|
|
1366
|
+
const invertSurfaceAndAccent = themeType === "dark" && options?.invertDarkModeSurfaceAccent;
|
|
1367
|
+
const preferredSurfaceColorInput = invertSurfaceAndAccent ? color ?? options?.surfaceColor : options?.surfaceColor ?? color;
|
|
1368
|
+
const themeAdjustments = themeType === "light" ? options?.light : options?.dark;
|
|
1369
|
+
const surfaceMaxChroma = themeAdjustments?.surfaceMaxChroma ?? options?.surfaceMaxChroma ?? BASELINE_MAX_CHROMA;
|
|
1370
|
+
const preferredSurfaceColor = convert(
|
|
1371
|
+
parse(preferredSurfaceColorInput),
|
|
1372
|
+
"oklch"
|
|
1373
|
+
);
|
|
1374
|
+
let surfaceHue = preferredSurfaceColor.h;
|
|
1375
|
+
const surfaceChroma = Math.min(preferredSurfaceColor.c, surfaceMaxChroma);
|
|
1376
|
+
const surfaceHueShift = options?.surfaceHueShift ?? 0;
|
|
1377
|
+
if (surfaceHueShift !== 0 && !options?.surfaceColor && !invertSurfaceAndAccent) {
|
|
1378
|
+
surfaceHue = wrapHue(convert(color, "oklch").h + surfaceHueShift);
|
|
1379
|
+
}
|
|
1380
|
+
const normalizedPreferredSurfaceColor = {
|
|
1381
|
+
...preferredSurfaceColor,
|
|
1382
|
+
h: surfaceHue,
|
|
1383
|
+
c: surfaceChroma,
|
|
1384
|
+
l: themeType === "light" ? BASELINE_LIGHT_L_VALUE : BASELINE_DARK_L_VALUE
|
|
1385
|
+
};
|
|
1386
|
+
return expandColorToScale(normalizedPreferredSurfaceColor, themeType, {
|
|
1387
|
+
baselineLValueDark: BASELINE_DARK_L_VALUE,
|
|
1388
|
+
baselineLValueLight: BASELINE_LIGHT_L_VALUE,
|
|
1389
|
+
strongDeltaDark: STRONG_DELTA_DARK,
|
|
1390
|
+
strongDeltaLight: STRONG_DELTA_LIGHT,
|
|
1391
|
+
weakDeltaDark: WEAK_DELTA_DARK,
|
|
1392
|
+
weakDeltaLight: WEAK_DELTA_LIGHT,
|
|
1393
|
+
minContrastRatio: options?.minContrastRatio,
|
|
1394
|
+
hueShift: options?.hueShift,
|
|
1395
|
+
foregroundMaxChroma: options?.foregroundMaxChroma,
|
|
1396
|
+
light: options?.light,
|
|
1397
|
+
dark: options?.dark
|
|
1398
|
+
});
|
|
1399
|
+
}
|
|
1400
|
+
|
|
1398
1401
|
// src/generate/generate.ts
|
|
1399
1402
|
function generate(color, themeType, options) {
|
|
1400
1403
|
return {
|
|
1401
|
-
|
|
1404
|
+
surface: generateSurface(color, themeType, options),
|
|
1402
1405
|
accent: generateAccent(color, themeType, options),
|
|
1403
1406
|
...generateSemanticColors(color, themeType, options)
|
|
1404
1407
|
};
|
|
@@ -1443,7 +1446,7 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
|
|
|
1443
1446
|
this.seedOptionsForFork({});
|
|
1444
1447
|
}
|
|
1445
1448
|
/**
|
|
1446
|
-
* Merges style options into the builder and regenerates the
|
|
1449
|
+
* Merges style options into the builder and regenerates the palettes,
|
|
1447
1450
|
* then replays recorded operations so roles and variants reflect the new style.
|
|
1448
1451
|
*/
|
|
1449
1452
|
style(partial) {
|
|
@@ -1532,7 +1535,7 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
|
|
|
1532
1535
|
*
|
|
1533
1536
|
* The color can be a direct color value or a derived token referencing an existing role.
|
|
1534
1537
|
*
|
|
1535
|
-
* e.g. `addRole('cta', '#ff0066')` adds a "cta" role with the specified
|
|
1538
|
+
* e.g. `addRole('cta', '#ff0066')` adds a "cta" role with the specified color.
|
|
1536
1539
|
* `addRole('cta', { from: 'accent', hue: 180 })` adds a "cta" role with a complementary hue to accent.
|
|
1537
1540
|
*
|
|
1538
1541
|
* @param name Role name (e.g. "cta", "banner")
|
|
@@ -1565,7 +1568,7 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
|
|
|
1565
1568
|
* `addToken('brand', { light: '#3a86ff', dark: '#ff0066' })` adds a "brand" token with different colors in light and dark themes.
|
|
1566
1569
|
*
|
|
1567
1570
|
* It can also be used to override specific tokens after generation.
|
|
1568
|
-
* `addToken('
|
|
1571
|
+
* `addToken('surface-strong', '#ff0066')` overrides the automatically generated "surface-strong" variant with a custom color.
|
|
1569
1572
|
*
|
|
1570
1573
|
* @param name Token name (e.g. "brand", "logo")
|
|
1571
1574
|
* @param value Token value, which can be an exact color, or derived from an existing role+variant.
|
|
@@ -1579,7 +1582,7 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
|
|
|
1579
1582
|
* Applies a preset that configures roles, tokens, and format defaults
|
|
1580
1583
|
* for a specific framework or convention (e.g. shadcn/ui).
|
|
1581
1584
|
*
|
|
1582
|
-
* Preset format defaults are used as
|
|
1585
|
+
* Preset format defaults are used as defaults in `.format()` — any options
|
|
1583
1586
|
* you pass to `.format()` will override the preset's defaults.
|
|
1584
1587
|
*
|
|
1585
1588
|
* @example
|
|
@@ -1620,7 +1623,7 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
|
|
|
1620
1623
|
this.operations.push({ method: "preset", args: [preset] });
|
|
1621
1624
|
this.applyPresetRolesTokensFormat(preset);
|
|
1622
1625
|
}
|
|
1623
|
-
/** Roles, variants, tokens, and format only — `this.options` and
|
|
1626
|
+
/** Roles, variants, tokens, and format only — `this.options` and palettes are already correct. */
|
|
1624
1627
|
applyPresetRolesTokensFormat(preset) {
|
|
1625
1628
|
for (const role of preset.roles ?? []) {
|
|
1626
1629
|
this.applyRole(role.name, role.color);
|
|
@@ -1689,7 +1692,7 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
|
|
|
1689
1692
|
return this;
|
|
1690
1693
|
}
|
|
1691
1694
|
/**
|
|
1692
|
-
* Creates a new builder instance with the same operations history, optionally from a different
|
|
1695
|
+
* Creates a new builder instance with the same operations history, optionally from a different accent color.
|
|
1693
1696
|
* To change style options on the fork, chain `.style()` after `.fork()`.
|
|
1694
1697
|
*
|
|
1695
1698
|
* @param color Optional new accent/brand color. If omitted, the fork uses the same color as this builder.
|
|
@@ -1930,7 +1933,9 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
|
|
|
1930
1933
|
if (this.strongSideVariants.includes(variantName)) {
|
|
1931
1934
|
return this.strongSideVariants;
|
|
1932
1935
|
}
|
|
1933
|
-
const sampleRole = Object.keys(this.lightPalette).find(
|
|
1936
|
+
const sampleRole = Object.keys(this.lightPalette).find(
|
|
1937
|
+
(r) => r !== "surface"
|
|
1938
|
+
);
|
|
1934
1939
|
if (!sampleRole) return null;
|
|
1935
1940
|
const scale = this.lightPalette[sampleRole];
|
|
1936
1941
|
if (!scale[variantName]) return null;
|