hextimator 0.12.3 → 0.14.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 +48 -0
- package/README.md +10 -8
- package/dist/{HextimatePaletteBuilder-REeEsEOu.d.ts → HextimatePaletteBuilder-BsQOgUcZ.d.ts} +9 -10
- package/dist/{chunk-KSUQW6CV.js → chunk-V4RWDZQM.js} +92 -12
- package/dist/cli.js +105 -33
- package/dist/{index-DSfF_JsR.d.ts → index-CA19MMV4.d.ts} +17 -3
- package/dist/index.d.ts +24 -24
- package/dist/index.js +3 -1
- package/dist/presets.d.ts +2 -2
- package/dist/react.d.ts +1 -1
- package/dist/react.js +1 -1
- package/fallback.css +15 -0
- package/package.json +1 -1
- package/tailwind-inverted.css +15 -0
- package/tailwind.css +5 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,51 @@
|
|
|
1
|
+
## 0.14.0
|
|
2
|
+
|
|
3
|
+
### Minor Changes
|
|
4
|
+
|
|
5
|
+
- [#173](https://github.com/fgrgic/hextimator/pull/173) [`f1fe2ca`](https://github.com/fgrgic/hextimator/commit/f1fe2ca5a922080b7c9c20d87ea43a8279cb0782) Thanks [@fgrgic](https://github.com/fgrgic)! - Adds `foreground-weak` variant as one of the default variants.
|
|
6
|
+
|
|
7
|
+
`foreground-weak` is the weakest contrast color to its background that still satisfies the required contrast ratio (e.g. `AAA`, or 7:1)
|
|
8
|
+
|
|
9
|
+
Not a breaking change, additive only. If you had specific overrides for `foreground-weak`, they will continue working as expected.
|
|
10
|
+
|
|
11
|
+
## 0.13.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- [#169](https://github.com/fgrgic/hextimator/pull/169) [`bcd6d93`](https://github.com/fgrgic/hextimator/commit/bcd6d934dc792393870e08ae3b453ecdea9a4c51) Thanks [@fgrgic](https://github.com/fgrgic)! - Overriding a generated token with `addToken` now uses a dotted key and applies before derivation (`surface.strong` instead of `surface-strong`). Kebab keys that collide with a generated label throw (`collides with a generated token`). See migration.md.
|
|
16
|
+
|
|
17
|
+
- [#170](https://github.com/fgrgic/hextimator/pull/170) [`1fd85c9`](https://github.com/fgrgic/hextimator/commit/1fd85c99ae3996aa601fec78d5b6d1c84ed59bcf) Thanks [@fgrgic](https://github.com/fgrgic)! - `HextimateConfig` and `fromConfig()` — express a theme's inputs as a plain object instead of a method chain.
|
|
18
|
+
|
|
19
|
+
```ts
|
|
20
|
+
fromConfig({ color: "#3a86ff" });
|
|
21
|
+
fromConfig({
|
|
22
|
+
color: "#3a86ff",
|
|
23
|
+
presets: [
|
|
24
|
+
{
|
|
25
|
+
tokens: [
|
|
26
|
+
{
|
|
27
|
+
name: "surface.weak",
|
|
28
|
+
value:
|
|
29
|
+
"[#123456](https://github.com/fgrgic/hextimator/issues/123456)",
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
},
|
|
33
|
+
],
|
|
34
|
+
});
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Returns a builder, so chaining continues as usual. Presets were already serializable — the colour wasn't. Pairing them makes a whole theme a value you can store, diff, or share between programs.
|
|
38
|
+
|
|
39
|
+
### Patch Changes
|
|
40
|
+
|
|
41
|
+
- [#167](https://github.com/fgrgic/hextimator/pull/167) [`8d34573`](https://github.com/fgrgic/hextimator/commit/8d34573fb423ebeaac96c6f220bef03affc021c4) Thanks [@fgrgic](https://github.com/fgrgic)! - docs: fix wrong claim in readme
|
|
42
|
+
|
|
43
|
+
## 0.13.0
|
|
44
|
+
|
|
45
|
+
### Major Changes
|
|
46
|
+
|
|
47
|
+
- **Breaking.** Overriding a generated token with `addToken` now uses a dotted key and applies before derivation (`surface.strong` instead of `surface-strong`). Kebab keys that collide with a generated label throw (`collides with a generated token`). See [migration.md](./docs/migration.md).
|
|
48
|
+
|
|
1
49
|
## 0.12.3
|
|
2
50
|
|
|
3
51
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -37,7 +37,7 @@ hextimator is the third option. **One color in, whole theme out.** Light and dar
|
|
|
37
37
|
|
|
38
38
|
hextimator is not the first palette generator. It targets one job the others skip: arbitrary brand colors at runtime.
|
|
39
39
|
|
|
40
|
-
- **[Adobe Leonardo](https://leonardocolor.io)**
|
|
40
|
+
- **[Adobe Leonardo](https://leonardocolor.io)** Runtime contrast scales from arbitrary hex (`Theme` → `contrastColors`, target ratios). A construction kit: you wire roles, surfaces, and dark mode yourself. hextimator is one call with those built in.
|
|
41
41
|
- **[Material dynamic color](https://github.com/material-foundation/material-color-utilities)** Full theming from one seed color. Battle-tested on Android. Output follows Material's token scheme. Hard to use outside Material-shaped UIs.
|
|
42
42
|
- **[Radix Colors](https://www.radix-ui.com/colors)** Hand-tuned scales with strong semantics. Fixed curated set. Does not generate themes from arbitrary input.
|
|
43
43
|
- **[tints.dev](https://tints.dev) / [uicolors.app](https://uicolors.app)** Quick Tailwind shade scales from one color. Build-time only. No semantic roles, contrast guarantees, dark theme, or library API.
|
|
@@ -88,13 +88,15 @@ npx hextimator '#BADA55' --preset bold
|
|
|
88
88
|
|
|
89
89
|
## What is in every theme
|
|
90
90
|
|
|
91
|
-
| Role | Variants
|
|
92
|
-
| -------- |
|
|
93
|
-
| surface | DEFAULT, strong, weak, foreground |
|
|
94
|
-
| accent | DEFAULT, strong, weak, foreground |
|
|
95
|
-
| positive | DEFAULT, strong, weak, foreground |
|
|
96
|
-
| negative | DEFAULT, strong, weak, foreground |
|
|
97
|
-
| caution | DEFAULT, strong, weak, foreground |
|
|
91
|
+
| Role | Variants |
|
|
92
|
+
| -------- | ------------------------------------------------- |
|
|
93
|
+
| surface | DEFAULT, strong, weak, foreground, foreground-weak |
|
|
94
|
+
| accent | DEFAULT, strong, weak, foreground, foreground-weak |
|
|
95
|
+
| positive | DEFAULT, strong, weak, foreground, foreground-weak |
|
|
96
|
+
| negative | DEFAULT, strong, weak, foreground, foreground-weak |
|
|
97
|
+
| caution | DEFAULT, strong, weak, foreground, foreground-weak |
|
|
98
|
+
|
|
99
|
+
`foreground-weak` is the softest foreground that still meets your contrast target against the role's DEFAULT background - use it for secondary or muted text.
|
|
98
100
|
|
|
99
101
|
Plus **`brand-exact`** (your input color, unchanged) and **`brand-exact-foreground`**.
|
|
100
102
|
|
package/dist/{HextimatePaletteBuilder-REeEsEOu.d.ts → HextimatePaletteBuilder-BsQOgUcZ.d.ts}
RENAMED
|
@@ -435,17 +435,10 @@ declare class HextimatePaletteBuilder {
|
|
|
435
435
|
*/
|
|
436
436
|
addVariant(name: string, placement: VariantPlacement): this;
|
|
437
437
|
/**
|
|
438
|
-
* Adds a standalone
|
|
439
|
-
* The value can be a direct color, a derived token based on an existing role+variant, or an object specifying different values for light and dark themes.
|
|
438
|
+
* Adds a standalone token, or overrides a generated palette color before derivation.
|
|
440
439
|
*
|
|
441
|
-
*
|
|
442
|
-
*
|
|
443
|
-
*
|
|
444
|
-
* It can also be used to override specific tokens after generation.
|
|
445
|
-
* `addToken('surface-strong', '#ff0066')` overrides the automatically generated "surface-strong" variant with a custom color.
|
|
446
|
-
*
|
|
447
|
-
* @param name Token name (e.g. "brand", "logo")
|
|
448
|
-
* @param value Token value, which can be an exact color, or derived from an existing role+variant.
|
|
440
|
+
* Override with a dotted key: `surface.weak`, `surface.DEFAULT` (not `surface-weak`).
|
|
441
|
+
* A kebab key that matches a generated label throws at format time.
|
|
449
442
|
*/
|
|
450
443
|
addToken(name: string, value: TokenValue): this;
|
|
451
444
|
/**
|
|
@@ -540,6 +533,12 @@ declare class HextimatePaletteBuilder {
|
|
|
540
533
|
private applyVariant;
|
|
541
534
|
private applyAnchoredVariant;
|
|
542
535
|
private applyToken;
|
|
536
|
+
private applyPalettePin;
|
|
537
|
+
/**
|
|
538
|
+
* Standalone token names must not squash palette flat keys after
|
|
539
|
+
* roleNames / variantNames / separator / excludes are applied.
|
|
540
|
+
*/
|
|
541
|
+
private assertNoPaletteLabelCollisions;
|
|
543
542
|
private resolveStandaloneTokens;
|
|
544
543
|
private resolveTokenValue;
|
|
545
544
|
private resolveTokenSingle;
|
|
@@ -1833,17 +1833,10 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
|
|
|
1833
1833
|
return this;
|
|
1834
1834
|
}
|
|
1835
1835
|
/**
|
|
1836
|
-
* Adds a standalone
|
|
1837
|
-
* The value can be a direct color, a derived token based on an existing role+variant, or an object specifying different values for light and dark themes.
|
|
1836
|
+
* Adds a standalone token, or overrides a generated palette color before derivation.
|
|
1838
1837
|
*
|
|
1839
|
-
*
|
|
1840
|
-
*
|
|
1841
|
-
*
|
|
1842
|
-
* It can also be used to override specific tokens after generation.
|
|
1843
|
-
* `addToken('surface-strong', '#ff0066')` overrides the automatically generated "surface-strong" variant with a custom color.
|
|
1844
|
-
*
|
|
1845
|
-
* @param name Token name (e.g. "brand", "logo")
|
|
1846
|
-
* @param value Token value, which can be an exact color, or derived from an existing role+variant.
|
|
1838
|
+
* Override with a dotted key: `surface.weak`, `surface.DEFAULT` (not `surface-weak`).
|
|
1839
|
+
* A kebab key that matches a generated label throws at format time.
|
|
1847
1840
|
*/
|
|
1848
1841
|
addToken(name, value) {
|
|
1849
1842
|
this.operations.push({ method: "addToken", args: [name, value] });
|
|
@@ -2013,6 +2006,7 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
|
|
|
2013
2006
|
}
|
|
2014
2007
|
} : options;
|
|
2015
2008
|
const colorFormat = mergedOptions?.colors ?? "hex";
|
|
2009
|
+
this.assertNoPaletteLabelCollisions(mergedOptions);
|
|
2016
2010
|
const lightTokens = this.resolveStandaloneTokens(
|
|
2017
2011
|
"light",
|
|
2018
2012
|
this.lightPalette,
|
|
@@ -2187,8 +2181,86 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
|
|
|
2187
2181
|
}
|
|
2188
2182
|
}
|
|
2189
2183
|
applyToken(name, value) {
|
|
2184
|
+
if (name.includes(".")) {
|
|
2185
|
+
this.applyPalettePin(name, value);
|
|
2186
|
+
return;
|
|
2187
|
+
}
|
|
2190
2188
|
this.standaloneTokens.push({ name, value });
|
|
2191
2189
|
}
|
|
2190
|
+
applyPalettePin(coordinate, value) {
|
|
2191
|
+
const dot = coordinate.indexOf(".");
|
|
2192
|
+
const role = coordinate.slice(0, dot);
|
|
2193
|
+
const variant = coordinate.slice(dot + 1);
|
|
2194
|
+
if (!role || !variant) {
|
|
2195
|
+
throw new Error(
|
|
2196
|
+
`Invalid palette coordinate "${coordinate}". Expected "role.variant".`
|
|
2197
|
+
);
|
|
2198
|
+
}
|
|
2199
|
+
for (const palette of [this.lightPalette, this.darkPalette]) {
|
|
2200
|
+
const scale = palette[role];
|
|
2201
|
+
if (!scale) {
|
|
2202
|
+
throw new Error(
|
|
2203
|
+
`Unknown role "${role}" in palette coordinate "${coordinate}"`
|
|
2204
|
+
);
|
|
2205
|
+
}
|
|
2206
|
+
if (scale[variant] === void 0) {
|
|
2207
|
+
throw new Error(
|
|
2208
|
+
`Unknown variant "${variant}" in palette coordinate "${coordinate}"`
|
|
2209
|
+
);
|
|
2210
|
+
}
|
|
2211
|
+
}
|
|
2212
|
+
this.lightPalette[role][variant] = convert(
|
|
2213
|
+
this.resolveTokenValue(value, "light", this.lightPalette),
|
|
2214
|
+
"oklch"
|
|
2215
|
+
);
|
|
2216
|
+
this.darkPalette[role][variant] = convert(
|
|
2217
|
+
this.resolveTokenValue(value, "dark", this.darkPalette),
|
|
2218
|
+
"oklch"
|
|
2219
|
+
);
|
|
2220
|
+
}
|
|
2221
|
+
/**
|
|
2222
|
+
* Standalone token names must not squash palette flat keys after
|
|
2223
|
+
* roleNames / variantNames / separator / excludes are applied.
|
|
2224
|
+
*/
|
|
2225
|
+
assertNoPaletteLabelCollisions(options) {
|
|
2226
|
+
if (this.standaloneTokens.length === 0) return;
|
|
2227
|
+
const sep = options?.separator ?? "-";
|
|
2228
|
+
const excludeRoles = new Set(options?.excludeRoles ?? []);
|
|
2229
|
+
const excludeVariants = new Set(options?.excludeVariants ?? []);
|
|
2230
|
+
const labelToCoord = /* @__PURE__ */ new Map();
|
|
2231
|
+
for (const role of Object.keys(this.lightPalette)) {
|
|
2232
|
+
if (excludeRoles.has(role)) continue;
|
|
2233
|
+
const scale = this.lightPalette[role];
|
|
2234
|
+
for (const variant of Object.keys(scale)) {
|
|
2235
|
+
if (excludeVariants.has(variant)) continue;
|
|
2236
|
+
const raw = scale[variant];
|
|
2237
|
+
if (typeof raw !== "object" || raw === null || !("space" in raw)) {
|
|
2238
|
+
continue;
|
|
2239
|
+
}
|
|
2240
|
+
const isDefault = variant === "DEFAULT";
|
|
2241
|
+
const entry = {
|
|
2242
|
+
role: options?.roleNames?.[role] ?? role,
|
|
2243
|
+
variant: options?.variantNames?.[variant] ?? variant,
|
|
2244
|
+
isDefault,
|
|
2245
|
+
value: ""
|
|
2246
|
+
};
|
|
2247
|
+
labelToCoord.set(toFlatKey(entry, sep), {
|
|
2248
|
+
role,
|
|
2249
|
+
variant,
|
|
2250
|
+
isDefault
|
|
2251
|
+
});
|
|
2252
|
+
}
|
|
2253
|
+
}
|
|
2254
|
+
for (const { name } of this.standaloneTokens) {
|
|
2255
|
+
const coord = labelToCoord.get(name);
|
|
2256
|
+
if (!coord) continue;
|
|
2257
|
+
const suggestion = coord.isDefault ? `${coord.role}.DEFAULT` : `${coord.role}.${coord.variant}`;
|
|
2258
|
+
throw new Error(
|
|
2259
|
+
`addToken("${name}") collides with a generated token.
|
|
2260
|
+
Did you mean addToken("${suggestion}") to change the palette?`
|
|
2261
|
+
);
|
|
2262
|
+
}
|
|
2263
|
+
}
|
|
2192
2264
|
resolveStandaloneTokens(themeType, palette, colorFormat) {
|
|
2193
2265
|
return this.standaloneTokens.map(({ name, value }) => {
|
|
2194
2266
|
const color = this.resolveTokenValue(value, themeType, palette);
|
|
@@ -2454,7 +2526,7 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
|
|
|
2454
2526
|
}
|
|
2455
2527
|
};
|
|
2456
2528
|
|
|
2457
|
-
// src/
|
|
2529
|
+
// src/hextimate.ts
|
|
2458
2530
|
var HextimateError = class extends Error {
|
|
2459
2531
|
constructor(input, message) {
|
|
2460
2532
|
super(message ?? `Failed to hextimate color: ${String(input)}`);
|
|
@@ -2477,6 +2549,13 @@ function hextimate(color) {
|
|
|
2477
2549
|
}
|
|
2478
2550
|
}
|
|
2479
2551
|
|
|
2552
|
+
// src/presets/fromConfig.ts
|
|
2553
|
+
function fromConfig(c) {
|
|
2554
|
+
let b = hextimate(c.color);
|
|
2555
|
+
for (const p of c.presets ?? []) b = b.preset(p);
|
|
2556
|
+
return b;
|
|
2557
|
+
}
|
|
2558
|
+
|
|
2480
2559
|
export {
|
|
2481
2560
|
convert,
|
|
2482
2561
|
parse,
|
|
@@ -2484,5 +2563,6 @@ export {
|
|
|
2484
2563
|
simulateColor,
|
|
2485
2564
|
HextimatePaletteBuilder,
|
|
2486
2565
|
HextimateError,
|
|
2487
|
-
hextimate
|
|
2566
|
+
hextimate,
|
|
2567
|
+
fromConfig
|
|
2488
2568
|
};
|
package/dist/cli.js
CHANGED
|
@@ -1841,17 +1841,10 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
|
|
|
1841
1841
|
return this;
|
|
1842
1842
|
}
|
|
1843
1843
|
/**
|
|
1844
|
-
* Adds a standalone
|
|
1845
|
-
* The value can be a direct color, a derived token based on an existing role+variant, or an object specifying different values for light and dark themes.
|
|
1844
|
+
* Adds a standalone token, or overrides a generated palette color before derivation.
|
|
1846
1845
|
*
|
|
1847
|
-
*
|
|
1848
|
-
*
|
|
1849
|
-
*
|
|
1850
|
-
* It can also be used to override specific tokens after generation.
|
|
1851
|
-
* `addToken('surface-strong', '#ff0066')` overrides the automatically generated "surface-strong" variant with a custom color.
|
|
1852
|
-
*
|
|
1853
|
-
* @param name Token name (e.g. "brand", "logo")
|
|
1854
|
-
* @param value Token value, which can be an exact color, or derived from an existing role+variant.
|
|
1846
|
+
* Override with a dotted key: `surface.weak`, `surface.DEFAULT` (not `surface-weak`).
|
|
1847
|
+
* A kebab key that matches a generated label throws at format time.
|
|
1855
1848
|
*/
|
|
1856
1849
|
addToken(name, value) {
|
|
1857
1850
|
this.operations.push({ method: "addToken", args: [name, value] });
|
|
@@ -2021,6 +2014,7 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
|
|
|
2021
2014
|
}
|
|
2022
2015
|
} : options;
|
|
2023
2016
|
const colorFormat = mergedOptions?.colors ?? "hex";
|
|
2017
|
+
this.assertNoPaletteLabelCollisions(mergedOptions);
|
|
2024
2018
|
const lightTokens = this.resolveStandaloneTokens(
|
|
2025
2019
|
"light",
|
|
2026
2020
|
this.lightPalette,
|
|
@@ -2195,8 +2189,86 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
|
|
|
2195
2189
|
}
|
|
2196
2190
|
}
|
|
2197
2191
|
applyToken(name, value) {
|
|
2192
|
+
if (name.includes(".")) {
|
|
2193
|
+
this.applyPalettePin(name, value);
|
|
2194
|
+
return;
|
|
2195
|
+
}
|
|
2198
2196
|
this.standaloneTokens.push({ name, value });
|
|
2199
2197
|
}
|
|
2198
|
+
applyPalettePin(coordinate, value) {
|
|
2199
|
+
const dot = coordinate.indexOf(".");
|
|
2200
|
+
const role = coordinate.slice(0, dot);
|
|
2201
|
+
const variant = coordinate.slice(dot + 1);
|
|
2202
|
+
if (!role || !variant) {
|
|
2203
|
+
throw new Error(
|
|
2204
|
+
`Invalid palette coordinate "${coordinate}". Expected "role.variant".`
|
|
2205
|
+
);
|
|
2206
|
+
}
|
|
2207
|
+
for (const palette of [this.lightPalette, this.darkPalette]) {
|
|
2208
|
+
const scale = palette[role];
|
|
2209
|
+
if (!scale) {
|
|
2210
|
+
throw new Error(
|
|
2211
|
+
`Unknown role "${role}" in palette coordinate "${coordinate}"`
|
|
2212
|
+
);
|
|
2213
|
+
}
|
|
2214
|
+
if (scale[variant] === void 0) {
|
|
2215
|
+
throw new Error(
|
|
2216
|
+
`Unknown variant "${variant}" in palette coordinate "${coordinate}"`
|
|
2217
|
+
);
|
|
2218
|
+
}
|
|
2219
|
+
}
|
|
2220
|
+
this.lightPalette[role][variant] = convert(
|
|
2221
|
+
this.resolveTokenValue(value, "light", this.lightPalette),
|
|
2222
|
+
"oklch"
|
|
2223
|
+
);
|
|
2224
|
+
this.darkPalette[role][variant] = convert(
|
|
2225
|
+
this.resolveTokenValue(value, "dark", this.darkPalette),
|
|
2226
|
+
"oklch"
|
|
2227
|
+
);
|
|
2228
|
+
}
|
|
2229
|
+
/**
|
|
2230
|
+
* Standalone token names must not squash palette flat keys after
|
|
2231
|
+
* roleNames / variantNames / separator / excludes are applied.
|
|
2232
|
+
*/
|
|
2233
|
+
assertNoPaletteLabelCollisions(options) {
|
|
2234
|
+
if (this.standaloneTokens.length === 0) return;
|
|
2235
|
+
const sep = options?.separator ?? "-";
|
|
2236
|
+
const excludeRoles = new Set(options?.excludeRoles ?? []);
|
|
2237
|
+
const excludeVariants = new Set(options?.excludeVariants ?? []);
|
|
2238
|
+
const labelToCoord = /* @__PURE__ */ new Map();
|
|
2239
|
+
for (const role of Object.keys(this.lightPalette)) {
|
|
2240
|
+
if (excludeRoles.has(role)) continue;
|
|
2241
|
+
const scale = this.lightPalette[role];
|
|
2242
|
+
for (const variant of Object.keys(scale)) {
|
|
2243
|
+
if (excludeVariants.has(variant)) continue;
|
|
2244
|
+
const raw = scale[variant];
|
|
2245
|
+
if (typeof raw !== "object" || raw === null || !("space" in raw)) {
|
|
2246
|
+
continue;
|
|
2247
|
+
}
|
|
2248
|
+
const isDefault = variant === "DEFAULT";
|
|
2249
|
+
const entry = {
|
|
2250
|
+
role: options?.roleNames?.[role] ?? role,
|
|
2251
|
+
variant: options?.variantNames?.[variant] ?? variant,
|
|
2252
|
+
isDefault,
|
|
2253
|
+
value: ""
|
|
2254
|
+
};
|
|
2255
|
+
labelToCoord.set(toFlatKey(entry, sep), {
|
|
2256
|
+
role,
|
|
2257
|
+
variant,
|
|
2258
|
+
isDefault
|
|
2259
|
+
});
|
|
2260
|
+
}
|
|
2261
|
+
}
|
|
2262
|
+
for (const { name } of this.standaloneTokens) {
|
|
2263
|
+
const coord = labelToCoord.get(name);
|
|
2264
|
+
if (!coord) continue;
|
|
2265
|
+
const suggestion = coord.isDefault ? `${coord.role}.DEFAULT` : `${coord.role}.${coord.variant}`;
|
|
2266
|
+
throw new Error(
|
|
2267
|
+
`addToken("${name}") collides with a generated token.
|
|
2268
|
+
Did you mean addToken("${suggestion}") to change the palette?`
|
|
2269
|
+
);
|
|
2270
|
+
}
|
|
2271
|
+
}
|
|
2200
2272
|
resolveStandaloneTokens(themeType, palette, colorFormat) {
|
|
2201
2273
|
return this.standaloneTokens.map(({ name, value }) => {
|
|
2202
2274
|
const color = this.resolveTokenValue(value, themeType, palette);
|
|
@@ -2462,6 +2534,29 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
|
|
|
2462
2534
|
}
|
|
2463
2535
|
};
|
|
2464
2536
|
|
|
2537
|
+
// src/hextimate.ts
|
|
2538
|
+
var HextimateError = class extends Error {
|
|
2539
|
+
constructor(input, message) {
|
|
2540
|
+
super(message ?? `Failed to hextimate color: ${String(input)}`);
|
|
2541
|
+
this.input = input;
|
|
2542
|
+
this.name = "HextimateError";
|
|
2543
|
+
}
|
|
2544
|
+
};
|
|
2545
|
+
function hextimate(color) {
|
|
2546
|
+
try {
|
|
2547
|
+
const parsedColor = parse(color);
|
|
2548
|
+
return new HextimatePaletteBuilder(parsedColor);
|
|
2549
|
+
} catch (e) {
|
|
2550
|
+
if (e instanceof HextimateError) {
|
|
2551
|
+
throw e;
|
|
2552
|
+
}
|
|
2553
|
+
throw new HextimateError(
|
|
2554
|
+
color,
|
|
2555
|
+
e instanceof Error ? e.message : "Unknown error"
|
|
2556
|
+
);
|
|
2557
|
+
}
|
|
2558
|
+
}
|
|
2559
|
+
|
|
2465
2560
|
// src/presets/bold.ts
|
|
2466
2561
|
var bold = {
|
|
2467
2562
|
style: {
|
|
@@ -2620,29 +2715,6 @@ var vibrant = {
|
|
|
2620
2715
|
}
|
|
2621
2716
|
};
|
|
2622
2717
|
|
|
2623
|
-
// src/index.ts
|
|
2624
|
-
var HextimateError = class extends Error {
|
|
2625
|
-
constructor(input, message) {
|
|
2626
|
-
super(message ?? `Failed to hextimate color: ${String(input)}`);
|
|
2627
|
-
this.input = input;
|
|
2628
|
-
this.name = "HextimateError";
|
|
2629
|
-
}
|
|
2630
|
-
};
|
|
2631
|
-
function hextimate(color) {
|
|
2632
|
-
try {
|
|
2633
|
-
const parsedColor = parse(color);
|
|
2634
|
-
return new HextimatePaletteBuilder(parsedColor);
|
|
2635
|
-
} catch (e) {
|
|
2636
|
-
if (e instanceof HextimateError) {
|
|
2637
|
-
throw e;
|
|
2638
|
-
}
|
|
2639
|
-
throw new HextimateError(
|
|
2640
|
-
color,
|
|
2641
|
-
e instanceof Error ? e.message : "Unknown error"
|
|
2642
|
-
);
|
|
2643
|
-
}
|
|
2644
|
-
}
|
|
2645
|
-
|
|
2646
2718
|
// src/cli.ts
|
|
2647
2719
|
var __dirname = dirname(fileURLToPath(import.meta.url));
|
|
2648
2720
|
var PKG_VERSION = JSON.parse(
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as HextimatePreset } from './HextimatePaletteBuilder-
|
|
1
|
+
import { g as HextimatePreset, d as ColorInput, H as HextimatePaletteBuilder } from './HextimatePaletteBuilder-BsQOgUcZ.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Darker accents on light themes, lighter accents on dark themes.
|
|
@@ -6,6 +6,19 @@ import { g as HextimatePreset } from './HextimatePaletteBuilder-REeEsEOu.js';
|
|
|
6
6
|
*/
|
|
7
7
|
declare const bold: HextimatePreset;
|
|
8
8
|
|
|
9
|
+
/**
|
|
10
|
+
* Accent color plus optional presets - plain, serializable theme input.
|
|
11
|
+
*
|
|
12
|
+
* Shared vocabulary between app code and tooling: the same object an app runs
|
|
13
|
+
* is the object a design-tool plugin runs.
|
|
14
|
+
*/
|
|
15
|
+
type HextimateConfig = {
|
|
16
|
+
color: ColorInput;
|
|
17
|
+
presets?: HextimatePreset[];
|
|
18
|
+
};
|
|
19
|
+
/** Apply a {@link HextimateConfig}: `hextimate(color)` then each preset in order. */
|
|
20
|
+
declare function fromConfig(c: HextimateConfig): HextimatePaletteBuilder;
|
|
21
|
+
|
|
9
22
|
/**
|
|
10
23
|
* Preset for Material UI (MUI) projects.
|
|
11
24
|
*
|
|
@@ -65,6 +78,7 @@ declare const tinted: HextimatePreset;
|
|
|
65
78
|
/** High-saturation palette. Colors that pop. */
|
|
66
79
|
declare const vibrant: HextimatePreset;
|
|
67
80
|
|
|
81
|
+
type index_HextimateConfig = HextimateConfig;
|
|
68
82
|
declare const index_HextimatePreset: typeof HextimatePreset;
|
|
69
83
|
declare const index_bold: typeof bold;
|
|
70
84
|
declare const index_mui: typeof mui;
|
|
@@ -73,7 +87,7 @@ declare const index_shadcn: typeof shadcn;
|
|
|
73
87
|
declare const index_tinted: typeof tinted;
|
|
74
88
|
declare const index_vibrant: typeof vibrant;
|
|
75
89
|
declare namespace index {
|
|
76
|
-
export { index_HextimatePreset as HextimatePreset, index_bold as bold, index_mui as mui, index_muted as muted, index_shadcn as shadcn, index_tinted as tinted, index_vibrant as vibrant };
|
|
90
|
+
export { type index_HextimateConfig as HextimateConfig, index_HextimatePreset as HextimatePreset, index_bold as bold, index_mui as mui, index_muted as muted, index_shadcn as shadcn, index_tinted as tinted, index_vibrant as vibrant };
|
|
77
91
|
}
|
|
78
92
|
|
|
79
|
-
export { muted as a, bold as b, index as i, mui as m, shadcn as s, tinted as t, vibrant as v };
|
|
93
|
+
export { type HextimateConfig as H, muted as a, bold as b, fromConfig as f, index as i, mui as m, shadcn as s, tinted as t, vibrant as v };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { C as Color, a as CVDType, O as OKLCH, b as ColorSpace, c as ColorInSpace, d as ColorInput, H as HextimatePaletteBuilder } from './HextimatePaletteBuilder-
|
|
2
|
-
export { D as DerivedToken, F as FlatTokenMap, e as FormatResult, f as HextimateFormatOptions, g as HextimatePreset, h as HextimateResult, i as HextimateStyleOptions, N as NestedTokenMap, T as ThemeAdjustments, j as TokenValue, V as VariantPlacement } from './HextimatePaletteBuilder-
|
|
3
|
-
export { i as presets } from './index-
|
|
1
|
+
import { C as Color, a as CVDType, O as OKLCH, b as ColorSpace, c as ColorInSpace, d as ColorInput, H as HextimatePaletteBuilder } from './HextimatePaletteBuilder-BsQOgUcZ.js';
|
|
2
|
+
export { D as DerivedToken, F as FlatTokenMap, e as FormatResult, f as HextimateFormatOptions, g as HextimatePreset, h as HextimateResult, i as HextimateStyleOptions, N as NestedTokenMap, T as ThemeAdjustments, j as TokenValue, V as VariantPlacement } from './HextimatePaletteBuilder-BsQOgUcZ.js';
|
|
3
|
+
export { H as HextimateConfig, f as fromConfig, i as presets } from './index-CA19MMV4.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Daltonize a color for a specific type of color vision deficiency (CVD).
|
|
@@ -43,27 +43,6 @@ declare function simulateColor(color: Color, type: CVDType, severity?: number):
|
|
|
43
43
|
*/
|
|
44
44
|
declare function convert<S extends ColorSpace>(color: Color, to: S): ColorInSpace<S>;
|
|
45
45
|
|
|
46
|
-
/**
|
|
47
|
-
* Parse a ColorInput into a Color.
|
|
48
|
-
*
|
|
49
|
-
* If the input is already a Color, it will be returned as is.
|
|
50
|
-
* If the input is a number, it will be parsed as a numeric hex value.
|
|
51
|
-
* If the input is a string, it will be parsed as a hex value, CSS function, or comma separated values.
|
|
52
|
-
* If the input is a tuple, it will be parsed as a color tuple.
|
|
53
|
-
* If the input is a CSS function string, it will be parsed as a CSS function.
|
|
54
|
-
* If the input is a comma separated values string, it will be parsed as a comma separated values.
|
|
55
|
-
*
|
|
56
|
-
* **Alpha is always set to 1.** Transparent inputs like `rgba(255,0,0,0.5)` are treated as
|
|
57
|
-
* fully opaque. This is intentional: alpha tokens break WCAG contrast guarantees because
|
|
58
|
-
* contrast ratios depend on whatever is rendered behind the element, which hextimator cannot
|
|
59
|
-
* know at generation time.
|
|
60
|
-
*
|
|
61
|
-
* @param input ColorInput
|
|
62
|
-
* @param assumeSpace color space to assume. If not provided, the color space will be inferred from the input, and default to 'srgb' if ambiguous
|
|
63
|
-
* @returns Color or throws a ColorParseError if parsing fails
|
|
64
|
-
*/
|
|
65
|
-
declare function parse(input: ColorInput, assumeSpace?: ColorSpace): Color;
|
|
66
|
-
|
|
67
46
|
/** Thrown when `hextimate()` fails to parse or generate a palette from the given input. */
|
|
68
47
|
declare class HextimateError extends Error {
|
|
69
48
|
readonly input: ColorInput;
|
|
@@ -87,4 +66,25 @@ declare class HextimateError extends Error {
|
|
|
87
66
|
*/
|
|
88
67
|
declare function hextimate(color: ColorInput): HextimatePaletteBuilder;
|
|
89
68
|
|
|
69
|
+
/**
|
|
70
|
+
* Parse a ColorInput into a Color.
|
|
71
|
+
*
|
|
72
|
+
* If the input is already a Color, it will be returned as is.
|
|
73
|
+
* If the input is a number, it will be parsed as a numeric hex value.
|
|
74
|
+
* If the input is a string, it will be parsed as a hex value, CSS function, or comma separated values.
|
|
75
|
+
* If the input is a tuple, it will be parsed as a color tuple.
|
|
76
|
+
* If the input is a CSS function string, it will be parsed as a CSS function.
|
|
77
|
+
* If the input is a comma separated values string, it will be parsed as a comma separated values.
|
|
78
|
+
*
|
|
79
|
+
* **Alpha is always set to 1.** Transparent inputs like `rgba(255,0,0,0.5)` are treated as
|
|
80
|
+
* fully opaque. This is intentional: alpha tokens break WCAG contrast guarantees because
|
|
81
|
+
* contrast ratios depend on whatever is rendered behind the element, which hextimator cannot
|
|
82
|
+
* know at generation time.
|
|
83
|
+
*
|
|
84
|
+
* @param input ColorInput
|
|
85
|
+
* @param assumeSpace color space to assume. If not provided, the color space will be inferred from the input, and default to 'srgb' if ambiguous
|
|
86
|
+
* @returns Color or throws a ColorParseError if parsing fails
|
|
87
|
+
*/
|
|
88
|
+
declare function parse(input: ColorInput, assumeSpace?: ColorSpace): Color;
|
|
89
|
+
|
|
90
90
|
export { CVDType, HextimateError, HextimatePaletteBuilder, convert as convertColor, daltonizeColor, hextimate, parse as parseColor, simulateColor };
|
package/dist/index.js
CHANGED
|
@@ -3,10 +3,11 @@ import {
|
|
|
3
3
|
HextimatePaletteBuilder,
|
|
4
4
|
convert,
|
|
5
5
|
daltonizeColor,
|
|
6
|
+
fromConfig,
|
|
6
7
|
hextimate,
|
|
7
8
|
parse,
|
|
8
9
|
simulateColor
|
|
9
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-V4RWDZQM.js";
|
|
10
11
|
import {
|
|
11
12
|
presets_exports
|
|
12
13
|
} from "./chunk-TEZ2I4CJ.js";
|
|
@@ -15,6 +16,7 @@ export {
|
|
|
15
16
|
HextimatePaletteBuilder,
|
|
16
17
|
convert as convertColor,
|
|
17
18
|
daltonizeColor,
|
|
19
|
+
fromConfig,
|
|
18
20
|
hextimate,
|
|
19
21
|
parse as parseColor,
|
|
20
22
|
presets_exports as presets,
|
package/dist/presets.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { b as bold, m as mui, a as muted, s as shadcn, t as tinted, v as vibrant } from './index-
|
|
2
|
-
export { g as HextimatePreset } from './HextimatePaletteBuilder-
|
|
1
|
+
export { H as HextimateConfig, b as bold, m as mui, a as muted, s as shadcn, t as tinted, v as vibrant } from './index-CA19MMV4.js';
|
|
2
|
+
export { g as HextimatePreset } from './HextimatePaletteBuilder-BsQOgUcZ.js';
|
package/dist/react.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as HextimateStyleOptions, g as HextimatePreset, H as HextimatePaletteBuilder, h as HextimateResult, F as FlatTokenMap, f as HextimateFormatOptions } from './HextimatePaletteBuilder-
|
|
1
|
+
import { i as HextimateStyleOptions, g as HextimatePreset, H as HextimatePaletteBuilder, h as HextimateResult, F as FlatTokenMap, f as HextimateFormatOptions } from './HextimatePaletteBuilder-BsQOgUcZ.js';
|
|
2
2
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
3
|
import { PropsWithChildren, RefObject, CSSProperties, ReactNode } from 'react';
|
|
4
4
|
|
package/dist/react.js
CHANGED
package/fallback.css
CHANGED
|
@@ -3,22 +3,27 @@
|
|
|
3
3
|
--surface-strong: #fcfcfc;
|
|
4
4
|
--surface-weak: #ebebeb;
|
|
5
5
|
--surface-foreground: #030303;
|
|
6
|
+
--surface-foreground-weak: #525252;
|
|
6
7
|
--accent: #454545;
|
|
7
8
|
--accent-strong: #383838;
|
|
8
9
|
--accent-weak: #525252;
|
|
9
10
|
--accent-foreground: #f5f5f5;
|
|
11
|
+
--accent-foreground-weak: #dedede;
|
|
10
12
|
--positive: #454545;
|
|
11
13
|
--positive-strong: #383838;
|
|
12
14
|
--positive-weak: #525252;
|
|
13
15
|
--positive-foreground: #f5f5f5;
|
|
16
|
+
--positive-foreground-weak: #dedede;
|
|
14
17
|
--negative: #454545;
|
|
15
18
|
--negative-strong: #383838;
|
|
16
19
|
--negative-weak: #525252;
|
|
17
20
|
--negative-foreground: #f5f5f5;
|
|
21
|
+
--negative-foreground-weak: #dedede;
|
|
18
22
|
--caution: #454545;
|
|
19
23
|
--caution-strong: #383838;
|
|
20
24
|
--caution-weak: #525252;
|
|
21
25
|
--caution-foreground: #f5f5f5;
|
|
26
|
+
--caution-foreground-weak: #dedede;
|
|
22
27
|
--brand-exact: #737373;
|
|
23
28
|
--brand-exact-foreground: #f5f5f5;
|
|
24
29
|
}
|
|
@@ -28,22 +33,27 @@
|
|
|
28
33
|
--surface-strong: #030303;
|
|
29
34
|
--surface-weak: #2e2e2e;
|
|
30
35
|
--surface-foreground: #f5f5f5;
|
|
36
|
+
--surface-foreground-weak: #a3a3a3;
|
|
31
37
|
--accent: #454545;
|
|
32
38
|
--accent-strong: #525252;
|
|
33
39
|
--accent-weak: #2b2b2b;
|
|
34
40
|
--accent-foreground: #f5f5f5;
|
|
41
|
+
--accent-foreground-weak: #dedede;
|
|
35
42
|
--positive: #454545;
|
|
36
43
|
--positive-strong: #525252;
|
|
37
44
|
--positive-weak: #2b2b2b;
|
|
38
45
|
--positive-foreground: #f5f5f5;
|
|
46
|
+
--positive-foreground-weak: #dedede;
|
|
39
47
|
--negative: #454545;
|
|
40
48
|
--negative-strong: #525252;
|
|
41
49
|
--negative-weak: #2b2b2b;
|
|
42
50
|
--negative-foreground: #f5f5f5;
|
|
51
|
+
--negative-foreground-weak: #dedede;
|
|
43
52
|
--caution: #454545;
|
|
44
53
|
--caution-strong: #525252;
|
|
45
54
|
--caution-weak: #2b2b2b;
|
|
46
55
|
--caution-foreground: #f5f5f5;
|
|
56
|
+
--caution-foreground-weak: #dedede;
|
|
47
57
|
--brand-exact: #737373;
|
|
48
58
|
--brand-exact-foreground: #f5f5f5;
|
|
49
59
|
}
|
|
@@ -53,22 +63,27 @@
|
|
|
53
63
|
--surface-strong: #030303;
|
|
54
64
|
--surface-weak: #2e2e2e;
|
|
55
65
|
--surface-foreground: #f5f5f5;
|
|
66
|
+
--surface-foreground-weak: #a3a3a3;
|
|
56
67
|
--accent: #454545;
|
|
57
68
|
--accent-strong: #525252;
|
|
58
69
|
--accent-weak: #2b2b2b;
|
|
59
70
|
--accent-foreground: #f5f5f5;
|
|
71
|
+
--accent-foreground-weak: #dedede;
|
|
60
72
|
--positive: #454545;
|
|
61
73
|
--positive-strong: #525252;
|
|
62
74
|
--positive-weak: #2b2b2b;
|
|
63
75
|
--positive-foreground: #f5f5f5;
|
|
76
|
+
--positive-foreground-weak: #dedede;
|
|
64
77
|
--negative: #454545;
|
|
65
78
|
--negative-strong: #525252;
|
|
66
79
|
--negative-weak: #2b2b2b;
|
|
67
80
|
--negative-foreground: #f5f5f5;
|
|
81
|
+
--negative-foreground-weak: #dedede;
|
|
68
82
|
--caution: #454545;
|
|
69
83
|
--caution-strong: #525252;
|
|
70
84
|
--caution-weak: #2b2b2b;
|
|
71
85
|
--caution-foreground: #f5f5f5;
|
|
86
|
+
--caution-foreground-weak: #dedede;
|
|
72
87
|
--brand-exact: #737373;
|
|
73
88
|
--brand-exact-foreground: #f5f5f5;
|
|
74
89
|
}
|
package/package.json
CHANGED
package/tailwind-inverted.css
CHANGED
|
@@ -3,20 +3,35 @@
|
|
|
3
3
|
--color-accent-strong-inverted: var(--accent-strong-inverted);
|
|
4
4
|
--color-accent-weak-inverted: var(--accent-weak-inverted);
|
|
5
5
|
--color-accent-foreground-inverted: var(--accent-foreground-inverted);
|
|
6
|
+
--color-accent-foreground-weak-inverted: var(
|
|
7
|
+
--accent-foreground-weak-inverted
|
|
8
|
+
);
|
|
6
9
|
--color-surface-inverted: var(--surface-inverted);
|
|
7
10
|
--color-surface-strong-inverted: var(--surface-strong-inverted);
|
|
8
11
|
--color-surface-weak-inverted: var(--surface-weak-inverted);
|
|
9
12
|
--color-surface-foreground-inverted: var(--surface-foreground-inverted);
|
|
13
|
+
--color-surface-foreground-weak-inverted: var(
|
|
14
|
+
--surface-foreground-weak-inverted
|
|
15
|
+
);
|
|
10
16
|
--color-positive-inverted: var(--positive-inverted);
|
|
11
17
|
--color-positive-strong-inverted: var(--positive-strong-inverted);
|
|
12
18
|
--color-positive-weak-inverted: var(--positive-weak-inverted);
|
|
13
19
|
--color-positive-foreground-inverted: var(--positive-foreground-inverted);
|
|
20
|
+
--color-positive-foreground-weak-inverted: var(
|
|
21
|
+
--positive-foreground-weak-inverted
|
|
22
|
+
);
|
|
14
23
|
--color-negative-inverted: var(--negative-inverted);
|
|
15
24
|
--color-negative-strong-inverted: var(--negative-strong-inverted);
|
|
16
25
|
--color-negative-weak-inverted: var(--negative-weak-inverted);
|
|
17
26
|
--color-negative-foreground-inverted: var(--negative-foreground-inverted);
|
|
27
|
+
--color-negative-foreground-weak-inverted: var(
|
|
28
|
+
--negative-foreground-weak-inverted
|
|
29
|
+
);
|
|
18
30
|
--color-caution-inverted: var(--caution-inverted);
|
|
19
31
|
--color-caution-strong-inverted: var(--caution-strong-inverted);
|
|
20
32
|
--color-caution-weak-inverted: var(--caution-weak-inverted);
|
|
21
33
|
--color-caution-foreground-inverted: var(--caution-foreground-inverted);
|
|
34
|
+
--color-caution-foreground-weak-inverted: var(
|
|
35
|
+
--caution-foreground-weak-inverted
|
|
36
|
+
);
|
|
22
37
|
}
|
package/tailwind.css
CHANGED
|
@@ -3,22 +3,27 @@
|
|
|
3
3
|
--color-accent-strong: var(--accent-strong);
|
|
4
4
|
--color-accent-weak: var(--accent-weak);
|
|
5
5
|
--color-accent-foreground: var(--accent-foreground);
|
|
6
|
+
--color-accent-foreground-weak: var(--accent-foreground-weak);
|
|
6
7
|
--color-surface: var(--surface);
|
|
7
8
|
--color-surface-strong: var(--surface-strong);
|
|
8
9
|
--color-surface-weak: var(--surface-weak);
|
|
9
10
|
--color-surface-foreground: var(--surface-foreground);
|
|
11
|
+
--color-surface-foreground-weak: var(--surface-foreground-weak);
|
|
10
12
|
--color-positive: var(--positive);
|
|
11
13
|
--color-positive-strong: var(--positive-strong);
|
|
12
14
|
--color-positive-weak: var(--positive-weak);
|
|
13
15
|
--color-positive-foreground: var(--positive-foreground);
|
|
16
|
+
--color-positive-foreground-weak: var(--positive-foreground-weak);
|
|
14
17
|
--color-negative: var(--negative);
|
|
15
18
|
--color-negative-strong: var(--negative-strong);
|
|
16
19
|
--color-negative-weak: var(--negative-weak);
|
|
17
20
|
--color-negative-foreground: var(--negative-foreground);
|
|
21
|
+
--color-negative-foreground-weak: var(--negative-foreground-weak);
|
|
18
22
|
--color-caution: var(--caution);
|
|
19
23
|
--color-caution-strong: var(--caution-strong);
|
|
20
24
|
--color-caution-weak: var(--caution-weak);
|
|
21
25
|
--color-caution-foreground: var(--caution-foreground);
|
|
26
|
+
--color-caution-foreground-weak: var(--caution-foreground-weak);
|
|
22
27
|
--color-brand-exact: var(--brand-exact);
|
|
23
28
|
--color-brand-exact-foreground: var(--brand-exact-foreground);
|
|
24
29
|
}
|