hextimator 0.2.0 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -2
- package/README.md +83 -32
- package/dist/{HextimatePaletteBuilder-BOuHKcVE.d.ts → HextimatePaletteBuilder-xqJwP_G2.d.ts} +42 -26
- package/dist/{chunk-MBVLFPTG.js → chunk-2OMHLWID.js} +183 -88
- package/dist/cli.js +220 -120
- package/dist/index.d.ts +23 -26
- package/dist/index.js +1 -1
- package/dist/react.d.ts +33 -19
- package/dist/react.js +93 -46
- package/fallback.css +68 -80
- package/llms.txt +113 -21
- package/package.json +3 -3
package/dist/cli.js
CHANGED
|
@@ -843,11 +843,15 @@ function isColorObject(input) {
|
|
|
843
843
|
function buildTokenEntries(palette, options) {
|
|
844
844
|
const colorFormat = options?.colors ?? "hex";
|
|
845
845
|
const entries = [];
|
|
846
|
+
const excludeRoles = new Set(options?.excludeRoles ?? []);
|
|
847
|
+
const excludeVariants = new Set(options?.excludeVariants ?? []);
|
|
846
848
|
const roles = Object.keys(palette);
|
|
847
849
|
for (const role of roles) {
|
|
850
|
+
if (excludeRoles.has(role)) continue;
|
|
848
851
|
const scale = palette[role];
|
|
849
852
|
const variants = Object.keys(scale);
|
|
850
853
|
for (const variant of variants) {
|
|
854
|
+
if (excludeVariants.has(variant)) continue;
|
|
851
855
|
const raw = scale[variant];
|
|
852
856
|
if (!isColorObject(raw)) continue;
|
|
853
857
|
entries.push({
|
|
@@ -1360,6 +1364,27 @@ function generate(color, themeType, options) {
|
|
|
1360
1364
|
}
|
|
1361
1365
|
|
|
1362
1366
|
// src/HextimatePaletteBuilder.ts
|
|
1367
|
+
var NESTED_GEN_KEYS = /* @__PURE__ */ new Set([
|
|
1368
|
+
"light",
|
|
1369
|
+
"dark",
|
|
1370
|
+
"semanticColors",
|
|
1371
|
+
"semanticColorRanges"
|
|
1372
|
+
]);
|
|
1373
|
+
function mergeStyleOptions(...sources) {
|
|
1374
|
+
const result = {};
|
|
1375
|
+
for (const source of sources) {
|
|
1376
|
+
if (!source) continue;
|
|
1377
|
+
for (const [key, value] of Object.entries(source)) {
|
|
1378
|
+
if (value === void 0) continue;
|
|
1379
|
+
if (NESTED_GEN_KEYS.has(key) && typeof value === "object" && value !== null) {
|
|
1380
|
+
result[key] = { ...result[key], ...value };
|
|
1381
|
+
} else {
|
|
1382
|
+
result[key] = value;
|
|
1383
|
+
}
|
|
1384
|
+
}
|
|
1385
|
+
}
|
|
1386
|
+
return result;
|
|
1387
|
+
}
|
|
1363
1388
|
var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
|
|
1364
1389
|
lightPalette;
|
|
1365
1390
|
darkPalette;
|
|
@@ -1371,18 +1396,95 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
|
|
|
1371
1396
|
strongSideVariants = ["strong"];
|
|
1372
1397
|
betweenVariants = [];
|
|
1373
1398
|
presetFormatDefaults;
|
|
1374
|
-
constructor(color
|
|
1399
|
+
constructor(color) {
|
|
1375
1400
|
this.inputColor = color;
|
|
1376
|
-
this.options =
|
|
1377
|
-
this.
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1401
|
+
this.options = {};
|
|
1402
|
+
this.seedOptionsForFork({});
|
|
1403
|
+
}
|
|
1404
|
+
/**
|
|
1405
|
+
* Merges style options into the builder and regenerates the base palettes,
|
|
1406
|
+
* then replays recorded operations so roles and variants reflect the new style.
|
|
1407
|
+
*/
|
|
1408
|
+
style(partial) {
|
|
1409
|
+
this.operations.push({ method: "style", args: [partial] });
|
|
1410
|
+
this.options = mergeStyleOptions(this.options, partial);
|
|
1411
|
+
this.rebuildFromOperations();
|
|
1412
|
+
return this;
|
|
1413
|
+
}
|
|
1414
|
+
seedOptionsForFork(seededOptions) {
|
|
1415
|
+
this.options = { ...seededOptions };
|
|
1416
|
+
this.lightPalette = generate(
|
|
1417
|
+
this.inputColor,
|
|
1418
|
+
"light",
|
|
1419
|
+
this.resolvedOptions()
|
|
1420
|
+
);
|
|
1421
|
+
this.darkPalette = generate(
|
|
1422
|
+
this.inputColor,
|
|
1423
|
+
"dark",
|
|
1424
|
+
this.resolvedOptions()
|
|
1425
|
+
);
|
|
1426
|
+
this.standaloneTokens.length = 0;
|
|
1427
|
+
this.weakSideVariants.length = 0;
|
|
1428
|
+
this.weakSideVariants.push("weak");
|
|
1429
|
+
this.strongSideVariants.length = 0;
|
|
1430
|
+
this.strongSideVariants.push("strong");
|
|
1431
|
+
this.betweenVariants.length = 0;
|
|
1432
|
+
this.presetFormatDefaults = void 0;
|
|
1433
|
+
this.applyToken("brand-exact", this.inputColor);
|
|
1434
|
+
const colorOKLCH = convert(this.inputColor, "oklch");
|
|
1381
1435
|
const lightFg = { ...colorOKLCH, l: 0.97, c: Math.min(colorOKLCH.c, 0.01) };
|
|
1382
1436
|
const darkFg = { ...colorOKLCH, l: 0.1, c: Math.min(colorOKLCH.c, 0.01) };
|
|
1383
|
-
const brandForeground = calculateContrast(
|
|
1437
|
+
const brandForeground = calculateContrast(this.inputColor, lightFg) >= calculateContrast(this.inputColor, darkFg) ? lightFg : darkFg;
|
|
1384
1438
|
this.applyToken("brand-exact-foreground", brandForeground);
|
|
1385
1439
|
}
|
|
1440
|
+
rebuildFromOperations() {
|
|
1441
|
+
this.seedOptionsForFork(this.options);
|
|
1442
|
+
for (const op of this.operations) {
|
|
1443
|
+
this.replayOperationInPlace(op);
|
|
1444
|
+
}
|
|
1445
|
+
}
|
|
1446
|
+
replayOperationInPlace(op) {
|
|
1447
|
+
switch (op.method) {
|
|
1448
|
+
case "style":
|
|
1449
|
+
return;
|
|
1450
|
+
case "addRole":
|
|
1451
|
+
this.applyRole(...op.args);
|
|
1452
|
+
return;
|
|
1453
|
+
case "addVariant":
|
|
1454
|
+
this.applyVariant(...op.args);
|
|
1455
|
+
return;
|
|
1456
|
+
case "addToken":
|
|
1457
|
+
this.applyToken(...op.args);
|
|
1458
|
+
return;
|
|
1459
|
+
case "simulate":
|
|
1460
|
+
this.lightPalette = simulatePalette(
|
|
1461
|
+
this.lightPalette,
|
|
1462
|
+
op.args[0],
|
|
1463
|
+
op.args[1]
|
|
1464
|
+
);
|
|
1465
|
+
this.darkPalette = simulatePalette(
|
|
1466
|
+
this.darkPalette,
|
|
1467
|
+
op.args[0],
|
|
1468
|
+
op.args[1]
|
|
1469
|
+
);
|
|
1470
|
+
return;
|
|
1471
|
+
case "adaptFor":
|
|
1472
|
+
this.lightPalette = adaptPalette(
|
|
1473
|
+
this.lightPalette,
|
|
1474
|
+
op.args[0],
|
|
1475
|
+
op.args[1]
|
|
1476
|
+
);
|
|
1477
|
+
this.darkPalette = adaptPalette(
|
|
1478
|
+
this.darkPalette,
|
|
1479
|
+
op.args[0],
|
|
1480
|
+
op.args[1]
|
|
1481
|
+
);
|
|
1482
|
+
return;
|
|
1483
|
+
case "preset":
|
|
1484
|
+
this.applyPresetRolesTokensFormat(op.args[0]);
|
|
1485
|
+
return;
|
|
1486
|
+
}
|
|
1487
|
+
}
|
|
1386
1488
|
/**
|
|
1387
1489
|
* Adds a custom role with given name and color.
|
|
1388
1490
|
* The color is expanded into a full scale and added to both light and dark palettes.
|
|
@@ -1453,9 +1555,8 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
|
|
|
1453
1555
|
*/
|
|
1454
1556
|
preset(preset) {
|
|
1455
1557
|
this.operations.push({ method: "preset", args: [preset] });
|
|
1456
|
-
if (preset.
|
|
1457
|
-
|
|
1458
|
-
Object.assign(this.options, preset.generation, userOptions);
|
|
1558
|
+
if (preset.style) {
|
|
1559
|
+
this.options = mergeStyleOptions(this.options, preset.style);
|
|
1459
1560
|
this.lightPalette = generate(
|
|
1460
1561
|
this.inputColor,
|
|
1461
1562
|
"light",
|
|
@@ -1467,6 +1568,19 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
|
|
|
1467
1568
|
this.resolvedOptions()
|
|
1468
1569
|
);
|
|
1469
1570
|
}
|
|
1571
|
+
this.applyPresetRolesTokensFormat(preset);
|
|
1572
|
+
return this;
|
|
1573
|
+
}
|
|
1574
|
+
/**
|
|
1575
|
+
* Records a preset in the operation log and applies roles, variants, tokens, and format.
|
|
1576
|
+
* Does not merge `preset.style` — used when replaying onto a builder whose `this.options` already reflect merged style.
|
|
1577
|
+
*/
|
|
1578
|
+
recordPresetWithoutStyleMerge(preset) {
|
|
1579
|
+
this.operations.push({ method: "preset", args: [preset] });
|
|
1580
|
+
this.applyPresetRolesTokensFormat(preset);
|
|
1581
|
+
}
|
|
1582
|
+
/** Roles, variants, tokens, and format only — `this.options` and base palettes are already correct. */
|
|
1583
|
+
applyPresetRolesTokensFormat(preset) {
|
|
1470
1584
|
for (const role of preset.roles ?? []) {
|
|
1471
1585
|
this.applyRole(role.name, role.color);
|
|
1472
1586
|
}
|
|
@@ -1490,7 +1604,6 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
|
|
|
1490
1604
|
}
|
|
1491
1605
|
};
|
|
1492
1606
|
}
|
|
1493
|
-
return this;
|
|
1494
1607
|
}
|
|
1495
1608
|
/**
|
|
1496
1609
|
*
|
|
@@ -1535,42 +1648,19 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
|
|
|
1535
1648
|
return this;
|
|
1536
1649
|
}
|
|
1537
1650
|
/**
|
|
1538
|
-
* Creates a new builder instance with the same operations history,
|
|
1539
|
-
*
|
|
1540
|
-
* e.g. `fork('#ff6677')` creates a new builder with the same
|
|
1541
|
-
* roles, variants, tokens, and adjustments, but based on a different input color.
|
|
1651
|
+
* Creates a new builder instance with the same operations history, optionally from a different base color.
|
|
1652
|
+
* To change style options on the fork, chain `.style()` after `.fork()`.
|
|
1542
1653
|
*
|
|
1543
|
-
*
|
|
1544
|
-
*
|
|
1545
|
-
* @param colorOrOptions Either a new base color for the palette, or an object with new generation options to override (e.g. light/dark adjustments, hue shift, contrast ratio).
|
|
1546
|
-
* @param maybeOptions If the first argument is a color, this can be an optional second argument with generation options to override.
|
|
1547
|
-
* @returns A new builder instance with the same operations history but different base color and/or options.
|
|
1654
|
+
* @param color Optional new accent/brand color. If omitted, the fork uses the same color as this builder.
|
|
1548
1655
|
*/
|
|
1549
|
-
fork(
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
newColor = parse(colorOrOptions);
|
|
1554
|
-
newOptions = {
|
|
1555
|
-
...this.options,
|
|
1556
|
-
...maybeOptions
|
|
1557
|
-
};
|
|
1558
|
-
} else if (colorOrOptions !== void 0 && typeof colorOrOptions === "object" && !Array.isArray(colorOrOptions) && !("space" in colorOrOptions)) {
|
|
1559
|
-
newColor = this.inputColor;
|
|
1560
|
-
newOptions = {
|
|
1561
|
-
...this.options,
|
|
1562
|
-
...colorOrOptions
|
|
1563
|
-
};
|
|
1564
|
-
} else if (colorOrOptions !== void 0) {
|
|
1565
|
-
newColor = parse(colorOrOptions);
|
|
1566
|
-
newOptions = { ...this.options };
|
|
1567
|
-
} else {
|
|
1568
|
-
newColor = this.inputColor;
|
|
1569
|
-
newOptions = { ...this.options };
|
|
1570
|
-
}
|
|
1571
|
-
const builder = new _HextimatePaletteBuilder(newColor, newOptions);
|
|
1656
|
+
fork(color) {
|
|
1657
|
+
const newColor = color !== void 0 ? parse(color) : this.inputColor;
|
|
1658
|
+
const builder = new _HextimatePaletteBuilder(newColor);
|
|
1659
|
+
builder.seedOptionsForFork({ ...this.options });
|
|
1572
1660
|
for (const op of this.operations) {
|
|
1573
1661
|
switch (op.method) {
|
|
1662
|
+
case "style":
|
|
1663
|
+
break;
|
|
1574
1664
|
case "addRole":
|
|
1575
1665
|
builder.addRole(...op.args);
|
|
1576
1666
|
break;
|
|
@@ -1587,7 +1677,7 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
|
|
|
1587
1677
|
builder.adaptFor(...op.args);
|
|
1588
1678
|
break;
|
|
1589
1679
|
case "preset":
|
|
1590
|
-
builder.
|
|
1680
|
+
builder.recordPresetWithoutStyleMerge(op.args[0]);
|
|
1591
1681
|
break;
|
|
1592
1682
|
}
|
|
1593
1683
|
}
|
|
@@ -1946,47 +2036,6 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
|
|
|
1946
2036
|
}
|
|
1947
2037
|
};
|
|
1948
2038
|
|
|
1949
|
-
// src/presets/demo.ts
|
|
1950
|
-
var demo = {
|
|
1951
|
-
generation: {
|
|
1952
|
-
minContrastRatio: "AA",
|
|
1953
|
-
baseHueShift: 180,
|
|
1954
|
-
baseMaxChroma: 0.025,
|
|
1955
|
-
hueShift: 10,
|
|
1956
|
-
light: { lightness: 0.55, maxChroma: 0.14 },
|
|
1957
|
-
dark: { lightness: 0.35, maxChroma: 0.12 }
|
|
1958
|
-
},
|
|
1959
|
-
roles: [
|
|
1960
|
-
{ name: "cta", color: "#ff006e" },
|
|
1961
|
-
{ name: "info", color: "#3a86ff" }
|
|
1962
|
-
],
|
|
1963
|
-
variants: [
|
|
1964
|
-
{ name: "muted", placement: { from: "weak" } },
|
|
1965
|
-
{ name: "vivid", placement: { from: "strong" } }
|
|
1966
|
-
],
|
|
1967
|
-
tokens: [
|
|
1968
|
-
{ name: "surface", value: { from: "base.weak" } },
|
|
1969
|
-
{ name: "surface-raised", value: { from: "base", emphasis: -0.04 } },
|
|
1970
|
-
{ name: "border", value: { from: "base", emphasis: 0.1 } },
|
|
1971
|
-
{ name: "border-subtle", value: { from: "base", emphasis: 0.05 } },
|
|
1972
|
-
{ name: "ring", value: { from: "accent" } },
|
|
1973
|
-
{ name: "cta-ring", value: { from: "cta", chroma: -0.05 } }
|
|
1974
|
-
],
|
|
1975
|
-
format: {
|
|
1976
|
-
as: "css",
|
|
1977
|
-
colors: "hex",
|
|
1978
|
-
roleNames: {
|
|
1979
|
-
base: "bg",
|
|
1980
|
-
accent: "brand",
|
|
1981
|
-
positive: "success",
|
|
1982
|
-
negative: "danger"
|
|
1983
|
-
},
|
|
1984
|
-
variantNames: {
|
|
1985
|
-
foreground: "text"
|
|
1986
|
-
}
|
|
1987
|
-
}
|
|
1988
|
-
};
|
|
1989
|
-
|
|
1990
2039
|
// src/presets/mui.ts
|
|
1991
2040
|
var mui = {
|
|
1992
2041
|
roles: [
|
|
@@ -2036,7 +2085,18 @@ var mui = {
|
|
|
2036
2085
|
weak: "light",
|
|
2037
2086
|
strong: "dark",
|
|
2038
2087
|
foreground: "contrastText"
|
|
2039
|
-
}
|
|
2088
|
+
},
|
|
2089
|
+
excludeRoles: ["base"]
|
|
2090
|
+
}
|
|
2091
|
+
};
|
|
2092
|
+
|
|
2093
|
+
// src/presets/muted.ts
|
|
2094
|
+
var muted = {
|
|
2095
|
+
style: {
|
|
2096
|
+
light: { maxChroma: 0.08 },
|
|
2097
|
+
dark: { maxChroma: 0.07 },
|
|
2098
|
+
baseMaxChroma: 5e-3,
|
|
2099
|
+
foregroundMaxChroma: 5e-3
|
|
2040
2100
|
}
|
|
2041
2101
|
};
|
|
2042
2102
|
|
|
@@ -2097,7 +2157,29 @@ var shadcn = {
|
|
|
2097
2157
|
},
|
|
2098
2158
|
variantNames: {
|
|
2099
2159
|
foreground: "foreground"
|
|
2100
|
-
}
|
|
2160
|
+
},
|
|
2161
|
+
excludeRoles: ["warning"],
|
|
2162
|
+
excludeVariants: ["strong", "weak"]
|
|
2163
|
+
}
|
|
2164
|
+
};
|
|
2165
|
+
|
|
2166
|
+
// src/presets/tinted.ts
|
|
2167
|
+
var tinted = {
|
|
2168
|
+
style: {
|
|
2169
|
+
baseMaxChroma: 0.05,
|
|
2170
|
+
baseHueShift: 0,
|
|
2171
|
+
foregroundMaxChroma: 0.015
|
|
2172
|
+
}
|
|
2173
|
+
};
|
|
2174
|
+
|
|
2175
|
+
// src/presets/vibrant.ts
|
|
2176
|
+
var vibrant = {
|
|
2177
|
+
style: {
|
|
2178
|
+
light: { maxChroma: 0.2, lightness: 0.6 },
|
|
2179
|
+
dark: { maxChroma: 0.18, lightness: 0.65 },
|
|
2180
|
+
hueShift: 5,
|
|
2181
|
+
baseHueShift: 180,
|
|
2182
|
+
baseMaxChroma: 0.08
|
|
2101
2183
|
}
|
|
2102
2184
|
};
|
|
2103
2185
|
|
|
@@ -2109,10 +2191,10 @@ var HextimateError = class extends Error {
|
|
|
2109
2191
|
this.name = "HextimateError";
|
|
2110
2192
|
}
|
|
2111
2193
|
};
|
|
2112
|
-
function hextimate(color
|
|
2194
|
+
function hextimate(color) {
|
|
2113
2195
|
try {
|
|
2114
2196
|
const parsedColor = parse(color);
|
|
2115
|
-
return new HextimatePaletteBuilder(parsedColor
|
|
2197
|
+
return new HextimatePaletteBuilder(parsedColor);
|
|
2116
2198
|
} catch (e) {
|
|
2117
2199
|
if (e instanceof HextimateError) {
|
|
2118
2200
|
throw e;
|
|
@@ -2132,7 +2214,9 @@ var PKG_VERSION = JSON.parse(
|
|
|
2132
2214
|
var AVAILABLE_PRESETS = {
|
|
2133
2215
|
shadcn,
|
|
2134
2216
|
mui,
|
|
2135
|
-
|
|
2217
|
+
muted,
|
|
2218
|
+
vibrant,
|
|
2219
|
+
tinted
|
|
2136
2220
|
};
|
|
2137
2221
|
var HELP = `
|
|
2138
2222
|
hextimator <color> [options]
|
|
@@ -2143,16 +2227,19 @@ Arguments:
|
|
|
2143
2227
|
color Input color (quote hex values: '#ff6600')
|
|
2144
2228
|
|
|
2145
2229
|
Presets:
|
|
2146
|
-
-p, --preset <name> Apply a preset
|
|
2147
|
-
|
|
2230
|
+
-p, --preset <name> Apply a preset (repeatable, applied in order):
|
|
2231
|
+
Framework: shadcn, mui
|
|
2232
|
+
Style: muted, vibrant, tinted
|
|
2148
2233
|
|
|
2149
2234
|
Format options:
|
|
2150
2235
|
-f, --format <type> css | object | tailwind | tailwind-css | scss | json (default: css)
|
|
2151
2236
|
-c, --colors <type> hex | rgb | hsl | oklch | p3 and -raw variants (default: hex)
|
|
2152
2237
|
-t, --theme <type> light | dark | both (default: both)
|
|
2153
2238
|
--separator <char> Token separator (default: -)
|
|
2239
|
+
--exclude-role <name> Omit a role from output (repeatable)
|
|
2240
|
+
--exclude-variant <name> Omit a variant from output (repeatable)
|
|
2154
2241
|
|
|
2155
|
-
|
|
2242
|
+
Style options:
|
|
2156
2243
|
--base-color <color> Override base/neutral color
|
|
2157
2244
|
--base-hue-shift <deg> Rotate base hue relative to accent
|
|
2158
2245
|
--hue-shift <deg> Per-variant hue shift in degrees
|
|
@@ -2190,6 +2277,7 @@ Examples:
|
|
|
2190
2277
|
hextimator '#ff6600' --format tailwind-css --colors oklch
|
|
2191
2278
|
hextimator '#3366cc' --format json --theme light
|
|
2192
2279
|
hextimator '#6366F1' --preset shadcn
|
|
2280
|
+
hextimator '#6366F1' --preset muted --preset shadcn
|
|
2193
2281
|
hextimator '#6366F1' --preset shadcn --colors hsl-raw
|
|
2194
2282
|
hextimator '#22aa44' --role cta=#ee2244 --variant hover:from:strong -o theme.css
|
|
2195
2283
|
hextimator '#6A5ACD' --base-color '#FEBA5D' --invert-dark
|
|
@@ -2200,11 +2288,13 @@ function run() {
|
|
|
2200
2288
|
const { values, positionals } = parseArgs({
|
|
2201
2289
|
allowPositionals: true,
|
|
2202
2290
|
options: {
|
|
2203
|
-
preset: { type: "string", short: "p" },
|
|
2291
|
+
preset: { type: "string", short: "p", multiple: true },
|
|
2204
2292
|
format: { type: "string", short: "f" },
|
|
2205
2293
|
colors: { type: "string", short: "c" },
|
|
2206
2294
|
theme: { type: "string", short: "t", default: "both" },
|
|
2207
2295
|
separator: { type: "string" },
|
|
2296
|
+
"exclude-role": { type: "string", multiple: true },
|
|
2297
|
+
"exclude-variant": { type: "string", multiple: true },
|
|
2208
2298
|
"base-color": { type: "string" },
|
|
2209
2299
|
"base-hue-shift": { type: "string" },
|
|
2210
2300
|
"hue-shift": { type: "string" },
|
|
@@ -2242,58 +2332,62 @@ function run() {
|
|
|
2242
2332
|
console.error("Error: missing color argument. Run with --help for usage.");
|
|
2243
2333
|
process.exit(1);
|
|
2244
2334
|
}
|
|
2245
|
-
const
|
|
2246
|
-
if (values["base-color"])
|
|
2335
|
+
const styleOptions = {};
|
|
2336
|
+
if (values["base-color"]) styleOptions.baseColor = values["base-color"];
|
|
2247
2337
|
if (values["base-hue-shift"])
|
|
2248
|
-
|
|
2249
|
-
if (values["hue-shift"])
|
|
2250
|
-
generationOptions.hueShift = Number(values["hue-shift"]);
|
|
2338
|
+
styleOptions.baseHueShift = Number(values["base-hue-shift"]);
|
|
2339
|
+
if (values["hue-shift"]) styleOptions.hueShift = Number(values["hue-shift"]);
|
|
2251
2340
|
if (values["base-max-chroma"])
|
|
2252
|
-
|
|
2341
|
+
styleOptions.baseMaxChroma = Number(values["base-max-chroma"]);
|
|
2253
2342
|
if (values["fg-max-chroma"])
|
|
2254
|
-
|
|
2343
|
+
styleOptions.foregroundMaxChroma = Number(values["fg-max-chroma"]);
|
|
2255
2344
|
if (values["light-lightness"] || values["light-max-chroma"]) {
|
|
2256
|
-
|
|
2345
|
+
styleOptions.light = {};
|
|
2257
2346
|
if (values["light-lightness"])
|
|
2258
|
-
|
|
2347
|
+
styleOptions.light.lightness = Number(values["light-lightness"]);
|
|
2259
2348
|
if (values["light-max-chroma"])
|
|
2260
|
-
|
|
2349
|
+
styleOptions.light.maxChroma = Number(values["light-max-chroma"]);
|
|
2261
2350
|
}
|
|
2262
2351
|
if (values["dark-lightness"] || values["dark-max-chroma"]) {
|
|
2263
|
-
|
|
2352
|
+
styleOptions.dark = {};
|
|
2264
2353
|
if (values["dark-lightness"])
|
|
2265
|
-
|
|
2354
|
+
styleOptions.dark.lightness = Number(values["dark-lightness"]);
|
|
2266
2355
|
if (values["dark-max-chroma"])
|
|
2267
|
-
|
|
2356
|
+
styleOptions.dark.maxChroma = Number(values["dark-max-chroma"]);
|
|
2268
2357
|
}
|
|
2269
2358
|
if (values["min-contrast"]) {
|
|
2270
2359
|
const mc = values["min-contrast"];
|
|
2271
2360
|
if (mc === "AAA" || mc === "AA") {
|
|
2272
|
-
|
|
2361
|
+
styleOptions.minContrastRatio = mc;
|
|
2273
2362
|
} else {
|
|
2274
|
-
|
|
2363
|
+
styleOptions.minContrastRatio = Number(mc);
|
|
2275
2364
|
}
|
|
2276
2365
|
}
|
|
2277
2366
|
if (values["invert-dark"]) {
|
|
2278
|
-
|
|
2367
|
+
styleOptions.invertDarkModeBaseAccent = true;
|
|
2279
2368
|
}
|
|
2280
2369
|
const semanticColors = {};
|
|
2281
2370
|
if (values.positive) semanticColors.positive = values.positive;
|
|
2282
2371
|
if (values.negative) semanticColors.negative = values.negative;
|
|
2283
2372
|
if (values.warning) semanticColors.warning = values.warning;
|
|
2284
2373
|
if (Object.keys(semanticColors).length > 0) {
|
|
2285
|
-
|
|
2374
|
+
styleOptions.semanticColors = semanticColors;
|
|
2375
|
+
}
|
|
2376
|
+
const builder = hextimate(color);
|
|
2377
|
+
if (Object.keys(styleOptions).length > 0) {
|
|
2378
|
+
builder.style(styleOptions);
|
|
2286
2379
|
}
|
|
2287
|
-
const builder = hextimate(color, generationOptions);
|
|
2288
2380
|
if (values.preset) {
|
|
2289
|
-
const
|
|
2290
|
-
|
|
2291
|
-
|
|
2292
|
-
|
|
2293
|
-
|
|
2294
|
-
|
|
2381
|
+
for (const name of values.preset) {
|
|
2382
|
+
const preset = AVAILABLE_PRESETS[name];
|
|
2383
|
+
if (!preset) {
|
|
2384
|
+
console.error(
|
|
2385
|
+
`Error: unknown preset "${name}". Available: ${Object.keys(AVAILABLE_PRESETS).join(", ")}`
|
|
2386
|
+
);
|
|
2387
|
+
process.exit(1);
|
|
2388
|
+
}
|
|
2389
|
+
builder.preset(preset);
|
|
2295
2390
|
}
|
|
2296
|
-
builder.preset(preset);
|
|
2297
2391
|
}
|
|
2298
2392
|
if (values.role) {
|
|
2299
2393
|
for (const r of values.role) {
|
|
@@ -2349,7 +2443,7 @@ function run() {
|
|
|
2349
2443
|
cvdSeverity
|
|
2350
2444
|
);
|
|
2351
2445
|
}
|
|
2352
|
-
const hasPreset =
|
|
2446
|
+
const hasPreset = values.preset && values.preset.length > 0;
|
|
2353
2447
|
const formatOptions = {};
|
|
2354
2448
|
if (values.format) {
|
|
2355
2449
|
formatOptions.as = values.format;
|
|
@@ -2366,6 +2460,12 @@ function run() {
|
|
|
2366
2460
|
} else if (!hasPreset) {
|
|
2367
2461
|
formatOptions.separator = "-";
|
|
2368
2462
|
}
|
|
2463
|
+
if (values["exclude-role"]?.length) {
|
|
2464
|
+
formatOptions.excludeRoles = values["exclude-role"];
|
|
2465
|
+
}
|
|
2466
|
+
if (values["exclude-variant"]?.length) {
|
|
2467
|
+
formatOptions.excludeVariants = values["exclude-variant"];
|
|
2468
|
+
}
|
|
2369
2469
|
const result = builder.format(formatOptions);
|
|
2370
2470
|
const themeFilter = values.theme;
|
|
2371
2471
|
let output;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as Color, a as CVDType, O as OKLCH, b as ColorSpace, c as ColorInSpace, d as ColorInput, H as HextimatePreset, e as
|
|
2
|
-
export { D as DerivedToken, F as FlatTokenMap,
|
|
1
|
+
import { C as Color, a as CVDType, O as OKLCH, b as ColorSpace, c as ColorInSpace, d as ColorInput, H as HextimatePreset, e as HextimatePaletteBuilder } from './HextimatePaletteBuilder-xqJwP_G2.js';
|
|
2
|
+
export { D as DerivedToken, F as FlatTokenMap, f as FormatResult, g as HextimateFormatOptions, h as HextimateOptions, i as HextimateResult, j as HextimateStyleOptions, N as NestedTokenMap, T as ThemeAdjustments, k as TokenValue, V as VariantPlacement } from './HextimatePaletteBuilder-xqJwP_G2.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Daltonize a color for a specific type of color vision deficiency (CVD).
|
|
@@ -64,23 +64,10 @@ declare function convert<S extends ColorSpace>(color: Color, to: S): ColorInSpac
|
|
|
64
64
|
declare function parse(input: ColorInput, assumeSpace?: ColorSpace): Color;
|
|
65
65
|
|
|
66
66
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* and format defaults.
|
|
70
|
-
*
|
|
71
|
-
* Use this as a reference when building your own presets.
|
|
72
|
-
*
|
|
73
|
-
* @example
|
|
74
|
-
* import { hextimate, presets } from 'hextimator';
|
|
75
|
-
*
|
|
76
|
-
* const theme = hextimate('#e63946').preset(presets.demo).format();
|
|
77
|
-
*
|
|
78
|
-
* // Override any preset default:
|
|
79
|
-
* const theme = hextimate('#e63946', { minContrastRatio: 'AAA' })
|
|
80
|
-
* .preset(presets.demo)
|
|
81
|
-
* .format({ colors: 'rgb' });
|
|
67
|
+
* Darker accents on light themes, lighter accents on dark themes.
|
|
68
|
+
* Higher chroma for neutrals.
|
|
82
69
|
*/
|
|
83
|
-
declare const
|
|
70
|
+
declare const bold: HextimatePreset;
|
|
84
71
|
|
|
85
72
|
/**
|
|
86
73
|
* Preset for Material UI (MUI) projects.
|
|
@@ -107,6 +94,9 @@ declare const demo: HextimatePreset;
|
|
|
107
94
|
*/
|
|
108
95
|
declare const mui: HextimatePreset;
|
|
109
96
|
|
|
97
|
+
/** Desaturated, restrained palette. Low chroma across the board. */
|
|
98
|
+
declare const muted: HextimatePreset;
|
|
99
|
+
|
|
110
100
|
/**
|
|
111
101
|
* Preset for shadcn/ui projects.
|
|
112
102
|
*
|
|
@@ -115,9 +105,6 @@ declare const mui: HextimatePreset;
|
|
|
115
105
|
* `--accent`, `--destructive`, `--card`, `--popover`, `--border`, `--input`, `--ring`,
|
|
116
106
|
* plus their `-foreground` counterparts.
|
|
117
107
|
*
|
|
118
|
-
* Also includes hextimator's bonus scale variants (`--primary-strong`, `--primary-weak`, etc.)
|
|
119
|
-
* which you can optionally use beyond what shadcn requires.
|
|
120
|
-
*
|
|
121
108
|
* Defaults to `oklch` color format (modern shadcn). Override with
|
|
122
109
|
* `.format({ colors: 'hsl-raw' })` for older shadcn setups.
|
|
123
110
|
*
|
|
@@ -135,12 +122,21 @@ declare const mui: HextimatePreset;
|
|
|
135
122
|
*/
|
|
136
123
|
declare const shadcn: HextimatePreset;
|
|
137
124
|
|
|
125
|
+
/** Neutrals pick up the accent hue for a cohesive, branded feel. */
|
|
126
|
+
declare const tinted: HextimatePreset;
|
|
127
|
+
|
|
128
|
+
/** High-saturation palette. Colors that pop. */
|
|
129
|
+
declare const vibrant: HextimatePreset;
|
|
130
|
+
|
|
138
131
|
declare const index_HextimatePreset: typeof HextimatePreset;
|
|
139
|
-
declare const
|
|
132
|
+
declare const index_bold: typeof bold;
|
|
140
133
|
declare const index_mui: typeof mui;
|
|
134
|
+
declare const index_muted: typeof muted;
|
|
141
135
|
declare const index_shadcn: typeof shadcn;
|
|
136
|
+
declare const index_tinted: typeof tinted;
|
|
137
|
+
declare const index_vibrant: typeof vibrant;
|
|
142
138
|
declare namespace index {
|
|
143
|
-
export { index_HextimatePreset as HextimatePreset,
|
|
139
|
+
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 };
|
|
144
140
|
}
|
|
145
141
|
|
|
146
142
|
/** Thrown when `hextimate()` fails to parse or generate a palette from the given input. */
|
|
@@ -158,11 +154,12 @@ declare class HextimateError extends Error {
|
|
|
158
154
|
*
|
|
159
155
|
* @example
|
|
160
156
|
* // Extended: add roles and variants before formatting
|
|
161
|
-
* const theme = hextimate('#ff6600'
|
|
157
|
+
* const theme = hextimate('#ff6600')
|
|
158
|
+
* .style({ light: { lightness: 0.5 }, dark: { lightness: 0.65, maxChroma: 0.1 } })
|
|
162
159
|
* .addRole('cta', '#ee2244')
|
|
163
160
|
* .addVariant('hover', { from: 'strong' })
|
|
164
161
|
* .format({ as: 'tailwind' });
|
|
165
162
|
*/
|
|
166
|
-
declare function hextimate(color: ColorInput
|
|
163
|
+
declare function hextimate(color: ColorInput): HextimatePaletteBuilder;
|
|
167
164
|
|
|
168
|
-
export { CVDType, HextimateError,
|
|
165
|
+
export { CVDType, HextimateError, HextimatePaletteBuilder, HextimatePreset, convert as convertColor, daltonizeColor, hextimate, parse as parseColor, index as presets, simulateColor };
|