hextimator 0.5.1 → 0.7.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 +33 -3
- package/README.md +11 -8
- package/dist/{HextimatePaletteBuilder-BY1EjhFs.d.ts → HextimatePaletteBuilder-Bc-GHsBy.d.ts} +69 -35
- package/dist/{chunk-RAI6L6AN.js → chunk-4WWRI5QJ.js} +107 -64
- package/dist/{chunk-JODPLAXA.js → chunk-NTF3K3U3.js} +36 -36
- package/dist/cli.js +157 -113
- package/dist/{index-C2l4fSiA.d.ts → index-B9eHpF-F.d.ts} +1 -1
- package/dist/index.d.ts +4 -4
- 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 +42 -42
- package/package.json +3 -1
- package/tailwind-inverted.css +22 -0
- package/tailwind.css +4 -4
|
@@ -18,9 +18,9 @@ __export(presets_exports, {
|
|
|
18
18
|
// src/presets/bold.ts
|
|
19
19
|
var bold = {
|
|
20
20
|
style: {
|
|
21
|
-
light: {
|
|
22
|
-
dark: {
|
|
23
|
-
|
|
21
|
+
light: { baseLightness: 0.5 },
|
|
22
|
+
dark: { baseLightness: 0.8 },
|
|
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
|
};
|
|
@@ -164,11 +164,11 @@ var tinted = {
|
|
|
164
164
|
// src/presets/vibrant.ts
|
|
165
165
|
var vibrant = {
|
|
166
166
|
style: {
|
|
167
|
-
light: { maxChroma: 0.2,
|
|
168
|
-
dark: { maxChroma: 0.18,
|
|
167
|
+
light: { maxChroma: 0.2, baseLightness: 0.6 },
|
|
168
|
+
dark: { maxChroma: 0.18, baseLightness: 0.65 },
|
|
169
169
|
hueShift: 5,
|
|
170
|
-
|
|
171
|
-
|
|
170
|
+
surfaceHueShift: 180,
|
|
171
|
+
surfaceMaxChroma: 0.08
|
|
172
172
|
}
|
|
173
173
|
};
|
|
174
174
|
|
package/dist/cli.js
CHANGED
|
@@ -864,6 +864,12 @@ function buildTokenEntries(palette, options) {
|
|
|
864
864
|
}
|
|
865
865
|
return entries;
|
|
866
866
|
}
|
|
867
|
+
function withInvertedSuffix(entry, sep) {
|
|
868
|
+
if (entry.isDefault && entry.variant === "DEFAULT") {
|
|
869
|
+
return { ...entry, isDefault: false, variant: "inverted" };
|
|
870
|
+
}
|
|
871
|
+
return { ...entry, variant: `${entry.variant}${sep}inverted` };
|
|
872
|
+
}
|
|
867
873
|
|
|
868
874
|
// src/format/formatters.ts
|
|
869
875
|
function toFlatKey(entry, sep) {
|
|
@@ -1172,11 +1178,19 @@ function expandColorToScale(color, themeType, options) {
|
|
|
1172
1178
|
}
|
|
1173
1179
|
var LIGHT_THEME_LIGHTNESS_RANGE = [0.4, 0.99];
|
|
1174
1180
|
var DARK_THEME_LIGHTNESS_RANGE = [0.2, 0.8];
|
|
1181
|
+
var warnedLegacyLightness = false;
|
|
1175
1182
|
function resolveThemeLightness(themeType, options) {
|
|
1176
1183
|
const themeAdjustments = themeType === "light" ? options?.light : options?.dark;
|
|
1177
1184
|
const range = themeType === "light" ? LIGHT_THEME_LIGHTNESS_RANGE : DARK_THEME_LIGHTNESS_RANGE;
|
|
1178
|
-
|
|
1179
|
-
|
|
1185
|
+
const value = themeAdjustments?.baseLightness ?? themeAdjustments?.lightness;
|
|
1186
|
+
if (themeAdjustments?.baseLightness === void 0 && themeAdjustments?.lightness !== void 0 && !warnedLegacyLightness && typeof console !== "undefined") {
|
|
1187
|
+
warnedLegacyLightness = true;
|
|
1188
|
+
console.warn(
|
|
1189
|
+
"[hextimator] `style({ light/dark: { lightness } })` is deprecated. Rename to `baseLightness` to disambiguate from the relative `lightness` offset used by `addToken({ from, lightness })`. Will be removed in a future release."
|
|
1190
|
+
);
|
|
1191
|
+
}
|
|
1192
|
+
if (value !== void 0) {
|
|
1193
|
+
return Math.min(Math.max(value, range[0]), range[1]);
|
|
1180
1194
|
}
|
|
1181
1195
|
return themeType === "light" ? DEFAULT_LIGHT_THEME_LIGHTNESS : DEFAULT_DARK_THEME_LIGHTNESS;
|
|
1182
1196
|
}
|
|
@@ -1240,20 +1254,20 @@ function calculateContrast(colorA, colorB) {
|
|
|
1240
1254
|
|
|
1241
1255
|
// src/generate/generateAccent.ts
|
|
1242
1256
|
function generateAccent(accent, themeType, options) {
|
|
1243
|
-
const
|
|
1244
|
-
if (
|
|
1257
|
+
const invertSurfaceAndAccent = themeType === "dark" && options?.invertDarkModeSurfaceAccent;
|
|
1258
|
+
if (invertSurfaceAndAccent) {
|
|
1245
1259
|
const accentOklch = convert(accent, "oklch");
|
|
1246
|
-
const
|
|
1247
|
-
let
|
|
1248
|
-
if (
|
|
1249
|
-
|
|
1250
|
-
...
|
|
1251
|
-
h: wrapHue(accentOklch.h +
|
|
1260
|
+
const surfaceHueShift = options?.surfaceHueShift ?? 0;
|
|
1261
|
+
let surfaceOklch = options?.surfaceColor ? convert(parse(options.surfaceColor), "oklch") : convert(accent, "oklch");
|
|
1262
|
+
if (surfaceHueShift !== 0 && !options?.surfaceColor) {
|
|
1263
|
+
surfaceOklch = {
|
|
1264
|
+
...surfaceOklch,
|
|
1265
|
+
h: wrapHue(accentOklch.h + surfaceHueShift)
|
|
1252
1266
|
};
|
|
1253
1267
|
}
|
|
1254
1268
|
const maxChroma = options?.dark?.maxChroma;
|
|
1255
1269
|
const invertedAccent = {
|
|
1256
|
-
...
|
|
1270
|
+
...surfaceOklch,
|
|
1257
1271
|
c: maxChroma !== void 0 ? Math.min(accentOklch.c, maxChroma) : accentOklch.c
|
|
1258
1272
|
};
|
|
1259
1273
|
return expandColorToScale(invertedAccent, themeType, options);
|
|
@@ -1261,47 +1275,6 @@ function generateAccent(accent, themeType, options) {
|
|
|
1261
1275
|
return expandColorToScale(accent, themeType, options);
|
|
1262
1276
|
}
|
|
1263
1277
|
|
|
1264
|
-
// src/generate/generateBase.ts
|
|
1265
|
-
var BASELINE_DARK_L_VALUE = 0.2;
|
|
1266
|
-
var BASELINE_LIGHT_L_VALUE = 0.97;
|
|
1267
|
-
var BASELINE_MAX_CHROMA = 0.01;
|
|
1268
|
-
var STRONG_DELTA_DARK = -0.1;
|
|
1269
|
-
var STRONG_DELTA_LIGHT = 0.02;
|
|
1270
|
-
var WEAK_DELTA_DARK = 0.1;
|
|
1271
|
-
var WEAK_DELTA_LIGHT = -0.03;
|
|
1272
|
-
function generateBase(color, themeType, options) {
|
|
1273
|
-
const invertBaseAndAccent = themeType === "dark" && options?.invertDarkModeBaseAccent;
|
|
1274
|
-
const preferredBaseColorInput = invertBaseAndAccent ? color ?? options?.baseColor : options?.baseColor ?? color;
|
|
1275
|
-
const themeAdjustments = themeType === "light" ? options?.light : options?.dark;
|
|
1276
|
-
const baselineMaxChroma = themeAdjustments?.baseMaxChroma ?? options?.baseMaxChroma ?? BASELINE_MAX_CHROMA;
|
|
1277
|
-
const preferredBaseColor = convert(parse(preferredBaseColorInput), "oklch");
|
|
1278
|
-
let baseHue = preferredBaseColor.h;
|
|
1279
|
-
const baseChroma = Math.min(preferredBaseColor.c, baselineMaxChroma);
|
|
1280
|
-
const baseHueShift = options?.baseHueShift ?? 0;
|
|
1281
|
-
if (baseHueShift !== 0 && !options?.baseColor && !invertBaseAndAccent) {
|
|
1282
|
-
baseHue = wrapHue(convert(color, "oklch").h + baseHueShift);
|
|
1283
|
-
}
|
|
1284
|
-
const normalizedPreferredBaseColor = {
|
|
1285
|
-
...preferredBaseColor,
|
|
1286
|
-
h: baseHue,
|
|
1287
|
-
c: baseChroma,
|
|
1288
|
-
l: themeType === "light" ? BASELINE_LIGHT_L_VALUE : BASELINE_DARK_L_VALUE
|
|
1289
|
-
};
|
|
1290
|
-
return expandColorToScale(normalizedPreferredBaseColor, themeType, {
|
|
1291
|
-
baselineLValueDark: BASELINE_DARK_L_VALUE,
|
|
1292
|
-
baselineLValueLight: BASELINE_LIGHT_L_VALUE,
|
|
1293
|
-
strongDeltaDark: STRONG_DELTA_DARK,
|
|
1294
|
-
strongDeltaLight: STRONG_DELTA_LIGHT,
|
|
1295
|
-
weakDeltaDark: WEAK_DELTA_DARK,
|
|
1296
|
-
weakDeltaLight: WEAK_DELTA_LIGHT,
|
|
1297
|
-
minContrastRatio: options?.minContrastRatio,
|
|
1298
|
-
hueShift: options?.hueShift,
|
|
1299
|
-
foregroundMaxChroma: options?.foregroundMaxChroma,
|
|
1300
|
-
light: options?.light,
|
|
1301
|
-
dark: options?.dark
|
|
1302
|
-
});
|
|
1303
|
-
}
|
|
1304
|
-
|
|
1305
1278
|
// src/generate/generateSemanticColors.ts
|
|
1306
1279
|
var POSITIVE_RANGE = [135, 160];
|
|
1307
1280
|
var NEGATIVE_RANGE = [5, 25];
|
|
@@ -1403,10 +1376,54 @@ function _getSplitComplementaryColors(color) {
|
|
|
1403
1376
|
];
|
|
1404
1377
|
}
|
|
1405
1378
|
|
|
1379
|
+
// src/generate/generateSurface.ts
|
|
1380
|
+
var BASELINE_DARK_L_VALUE = 0.2;
|
|
1381
|
+
var BASELINE_LIGHT_L_VALUE = 0.97;
|
|
1382
|
+
var BASELINE_MAX_CHROMA = 0.01;
|
|
1383
|
+
var STRONG_DELTA_DARK = -0.1;
|
|
1384
|
+
var STRONG_DELTA_LIGHT = 0.02;
|
|
1385
|
+
var WEAK_DELTA_DARK = 0.1;
|
|
1386
|
+
var WEAK_DELTA_LIGHT = -0.03;
|
|
1387
|
+
function generateSurface(color, themeType, options) {
|
|
1388
|
+
const invertSurfaceAndAccent = themeType === "dark" && options?.invertDarkModeSurfaceAccent;
|
|
1389
|
+
const preferredSurfaceColorInput = invertSurfaceAndAccent ? color ?? options?.surfaceColor : options?.surfaceColor ?? color;
|
|
1390
|
+
const themeAdjustments = themeType === "light" ? options?.light : options?.dark;
|
|
1391
|
+
const surfaceMaxChroma = themeAdjustments?.surfaceMaxChroma ?? options?.surfaceMaxChroma ?? BASELINE_MAX_CHROMA;
|
|
1392
|
+
const preferredSurfaceColor = convert(
|
|
1393
|
+
parse(preferredSurfaceColorInput),
|
|
1394
|
+
"oklch"
|
|
1395
|
+
);
|
|
1396
|
+
let surfaceHue = preferredSurfaceColor.h;
|
|
1397
|
+
const surfaceChroma = Math.min(preferredSurfaceColor.c, surfaceMaxChroma);
|
|
1398
|
+
const surfaceHueShift = options?.surfaceHueShift ?? 0;
|
|
1399
|
+
if (surfaceHueShift !== 0 && !options?.surfaceColor && !invertSurfaceAndAccent) {
|
|
1400
|
+
surfaceHue = wrapHue(convert(color, "oklch").h + surfaceHueShift);
|
|
1401
|
+
}
|
|
1402
|
+
const normalizedPreferredSurfaceColor = {
|
|
1403
|
+
...preferredSurfaceColor,
|
|
1404
|
+
h: surfaceHue,
|
|
1405
|
+
c: surfaceChroma,
|
|
1406
|
+
l: themeType === "light" ? BASELINE_LIGHT_L_VALUE : BASELINE_DARK_L_VALUE
|
|
1407
|
+
};
|
|
1408
|
+
return expandColorToScale(normalizedPreferredSurfaceColor, themeType, {
|
|
1409
|
+
baselineLValueDark: BASELINE_DARK_L_VALUE,
|
|
1410
|
+
baselineLValueLight: BASELINE_LIGHT_L_VALUE,
|
|
1411
|
+
strongDeltaDark: STRONG_DELTA_DARK,
|
|
1412
|
+
strongDeltaLight: STRONG_DELTA_LIGHT,
|
|
1413
|
+
weakDeltaDark: WEAK_DELTA_DARK,
|
|
1414
|
+
weakDeltaLight: WEAK_DELTA_LIGHT,
|
|
1415
|
+
minContrastRatio: options?.minContrastRatio,
|
|
1416
|
+
hueShift: options?.hueShift,
|
|
1417
|
+
foregroundMaxChroma: options?.foregroundMaxChroma,
|
|
1418
|
+
light: options?.light,
|
|
1419
|
+
dark: options?.dark
|
|
1420
|
+
});
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1406
1423
|
// src/generate/generate.ts
|
|
1407
1424
|
function generate(color, themeType, options) {
|
|
1408
1425
|
return {
|
|
1409
|
-
|
|
1426
|
+
surface: generateSurface(color, themeType, options),
|
|
1410
1427
|
accent: generateAccent(color, themeType, options),
|
|
1411
1428
|
...generateSemanticColors(color, themeType, options)
|
|
1412
1429
|
};
|
|
@@ -1451,7 +1468,7 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
|
|
|
1451
1468
|
this.seedOptionsForFork({});
|
|
1452
1469
|
}
|
|
1453
1470
|
/**
|
|
1454
|
-
* Merges style options into the builder and regenerates the
|
|
1471
|
+
* Merges style options into the builder and regenerates the palettes,
|
|
1455
1472
|
* then replays recorded operations so roles and variants reflect the new style.
|
|
1456
1473
|
*/
|
|
1457
1474
|
style(partial) {
|
|
@@ -1540,7 +1557,7 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
|
|
|
1540
1557
|
*
|
|
1541
1558
|
* The color can be a direct color value or a derived token referencing an existing role.
|
|
1542
1559
|
*
|
|
1543
|
-
* e.g. `addRole('cta', '#ff0066')` adds a "cta" role with the specified
|
|
1560
|
+
* e.g. `addRole('cta', '#ff0066')` adds a "cta" role with the specified color.
|
|
1544
1561
|
* `addRole('cta', { from: 'accent', hue: 180 })` adds a "cta" role with a complementary hue to accent.
|
|
1545
1562
|
*
|
|
1546
1563
|
* @param name Role name (e.g. "cta", "banner")
|
|
@@ -1573,7 +1590,7 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
|
|
|
1573
1590
|
* `addToken('brand', { light: '#3a86ff', dark: '#ff0066' })` adds a "brand" token with different colors in light and dark themes.
|
|
1574
1591
|
*
|
|
1575
1592
|
* It can also be used to override specific tokens after generation.
|
|
1576
|
-
* `addToken('
|
|
1593
|
+
* `addToken('surface-strong', '#ff0066')` overrides the automatically generated "surface-strong" variant with a custom color.
|
|
1577
1594
|
*
|
|
1578
1595
|
* @param name Token name (e.g. "brand", "logo")
|
|
1579
1596
|
* @param value Token value, which can be an exact color, or derived from an existing role+variant.
|
|
@@ -1587,7 +1604,7 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
|
|
|
1587
1604
|
* Applies a preset that configures roles, tokens, and format defaults
|
|
1588
1605
|
* for a specific framework or convention (e.g. shadcn/ui).
|
|
1589
1606
|
*
|
|
1590
|
-
* Preset format defaults are used as
|
|
1607
|
+
* Preset format defaults are used as defaults in `.format()` — any options
|
|
1591
1608
|
* you pass to `.format()` will override the preset's defaults.
|
|
1592
1609
|
*
|
|
1593
1610
|
* @example
|
|
@@ -1628,7 +1645,7 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
|
|
|
1628
1645
|
this.operations.push({ method: "preset", args: [preset] });
|
|
1629
1646
|
this.applyPresetRolesTokensFormat(preset);
|
|
1630
1647
|
}
|
|
1631
|
-
/** Roles, variants, tokens, and format only — `this.options` and
|
|
1648
|
+
/** Roles, variants, tokens, and format only — `this.options` and palettes are already correct. */
|
|
1632
1649
|
applyPresetRolesTokensFormat(preset) {
|
|
1633
1650
|
for (const role of preset.roles ?? []) {
|
|
1634
1651
|
this.applyRole(role.name, role.color);
|
|
@@ -1697,7 +1714,7 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
|
|
|
1697
1714
|
return this;
|
|
1698
1715
|
}
|
|
1699
1716
|
/**
|
|
1700
|
-
* Creates a new builder instance with the same operations history, optionally from a different
|
|
1717
|
+
* Creates a new builder instance with the same operations history, optionally from a different accent color.
|
|
1701
1718
|
* To change style options on the fork, chain `.style()` after `.fork()`.
|
|
1702
1719
|
*
|
|
1703
1720
|
* @param color Optional new accent/brand color. If omitted, the fork uses the same color as this builder.
|
|
@@ -1756,18 +1773,42 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
|
|
|
1756
1773
|
this.darkPalette,
|
|
1757
1774
|
colorFormat
|
|
1758
1775
|
);
|
|
1776
|
+
const inverted = mergedOptions?.invertedVariants ? this.buildInvertedEntries(mergedOptions, lightTokens, darkTokens) : { lightBlock: [], darkBlock: [] };
|
|
1759
1777
|
if (mergedOptions?.as === "css" || mergedOptions?.as === "tailwind-css") {
|
|
1760
1778
|
return formatStylesheet(
|
|
1761
1779
|
this.lightPalette,
|
|
1762
1780
|
this.darkPalette,
|
|
1763
1781
|
mergedOptions,
|
|
1764
|
-
lightTokens,
|
|
1765
|
-
darkTokens
|
|
1782
|
+
[...lightTokens, ...inverted.lightBlock],
|
|
1783
|
+
[...darkTokens, ...inverted.darkBlock]
|
|
1766
1784
|
);
|
|
1767
1785
|
}
|
|
1768
1786
|
return {
|
|
1769
|
-
light: format(this.lightPalette, mergedOptions,
|
|
1770
|
-
|
|
1787
|
+
light: format(this.lightPalette, mergedOptions, [
|
|
1788
|
+
...lightTokens,
|
|
1789
|
+
...inverted.lightBlock
|
|
1790
|
+
]),
|
|
1791
|
+
dark: format(this.darkPalette, mergedOptions, [
|
|
1792
|
+
...darkTokens,
|
|
1793
|
+
...inverted.darkBlock
|
|
1794
|
+
])
|
|
1795
|
+
};
|
|
1796
|
+
}
|
|
1797
|
+
buildInvertedEntries(options, lightStandalone, darkStandalone) {
|
|
1798
|
+
const sep = options.separator ?? "-";
|
|
1799
|
+
const lightBase = buildTokenEntries(this.lightPalette, options);
|
|
1800
|
+
const darkBase = buildTokenEntries(this.darkPalette, options);
|
|
1801
|
+
return {
|
|
1802
|
+
// Light block carries dark values under -inverted suffix.
|
|
1803
|
+
lightBlock: [
|
|
1804
|
+
...darkBase.map((e) => withInvertedSuffix(e, sep)),
|
|
1805
|
+
...darkStandalone.map((e) => withInvertedSuffix(e, sep))
|
|
1806
|
+
],
|
|
1807
|
+
// Dark block carries light values under -inverted suffix.
|
|
1808
|
+
darkBlock: [
|
|
1809
|
+
...lightBase.map((e) => withInvertedSuffix(e, sep)),
|
|
1810
|
+
...lightStandalone.map((e) => withInvertedSuffix(e, sep))
|
|
1811
|
+
]
|
|
1771
1812
|
};
|
|
1772
1813
|
}
|
|
1773
1814
|
applyRole(name, color) {
|
|
@@ -1938,7 +1979,9 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
|
|
|
1938
1979
|
if (this.strongSideVariants.includes(variantName)) {
|
|
1939
1980
|
return this.strongSideVariants;
|
|
1940
1981
|
}
|
|
1941
|
-
const sampleRole = Object.keys(this.lightPalette).find(
|
|
1982
|
+
const sampleRole = Object.keys(this.lightPalette).find(
|
|
1983
|
+
(r) => r !== "surface"
|
|
1984
|
+
);
|
|
1942
1985
|
if (!sampleRole) return null;
|
|
1943
1986
|
const scale = this.lightPalette[sampleRole];
|
|
1944
1987
|
if (!scale[variantName]) return null;
|
|
@@ -2102,32 +2145,32 @@ var mui = {
|
|
|
2102
2145
|
],
|
|
2103
2146
|
tokens: [
|
|
2104
2147
|
// background
|
|
2105
|
-
{ name: "background-default", value: { from: "
|
|
2148
|
+
{ name: "background-default", value: { from: "surface" } },
|
|
2106
2149
|
{
|
|
2107
2150
|
name: "background-paper",
|
|
2108
|
-
value: { from: "
|
|
2151
|
+
value: { from: "surface", emphasis: -0.025 }
|
|
2109
2152
|
},
|
|
2110
2153
|
// text
|
|
2111
|
-
{ name: "text-primary", value: { from: "
|
|
2154
|
+
{ name: "text-primary", value: { from: "surface.foreground" } },
|
|
2112
2155
|
{
|
|
2113
2156
|
name: "text-secondary",
|
|
2114
|
-
value: { from: "
|
|
2157
|
+
value: { from: "surface.foreground", emphasis: -0.2 }
|
|
2115
2158
|
},
|
|
2116
2159
|
{
|
|
2117
2160
|
name: "text-disabled",
|
|
2118
|
-
value: { from: "
|
|
2161
|
+
value: { from: "surface.foreground", emphasis: -0.4 }
|
|
2119
2162
|
},
|
|
2120
2163
|
// divider
|
|
2121
|
-
{ name: "divider", value: { from: "
|
|
2164
|
+
{ name: "divider", value: { from: "surface", emphasis: 0.12 } },
|
|
2122
2165
|
// action tokens
|
|
2123
|
-
{ name: "action-hover", value: { from: "
|
|
2124
|
-
{ name: "action-selected", value: { from: "
|
|
2125
|
-
{ name: "action-disabled", value: { from: "
|
|
2166
|
+
{ name: "action-hover", value: { from: "surface", emphasis: 0.04 } },
|
|
2167
|
+
{ name: "action-selected", value: { from: "surface", emphasis: 0.08 } },
|
|
2168
|
+
{ name: "action-disabled", value: { from: "surface", emphasis: 0.15 } },
|
|
2126
2169
|
{
|
|
2127
2170
|
name: "action-disabledBackground",
|
|
2128
|
-
value: { from: "
|
|
2171
|
+
value: { from: "surface", emphasis: 0.06 }
|
|
2129
2172
|
},
|
|
2130
|
-
{ name: "action-focus", value: { from: "
|
|
2173
|
+
{ name: "action-focus", value: { from: "surface", emphasis: 0.06 } }
|
|
2131
2174
|
],
|
|
2132
2175
|
format: {
|
|
2133
2176
|
as: "object",
|
|
@@ -2144,7 +2187,7 @@ var mui = {
|
|
|
2144
2187
|
strong: "dark",
|
|
2145
2188
|
foreground: "contrastText"
|
|
2146
2189
|
},
|
|
2147
|
-
excludeRoles: ["
|
|
2190
|
+
excludeRoles: ["surface"]
|
|
2148
2191
|
}
|
|
2149
2192
|
};
|
|
2150
2193
|
|
|
@@ -2153,7 +2196,7 @@ var muted = {
|
|
|
2153
2196
|
style: {
|
|
2154
2197
|
light: { maxChroma: 0.08 },
|
|
2155
2198
|
dark: { maxChroma: 0.07 },
|
|
2156
|
-
|
|
2199
|
+
surfaceMaxChroma: 5e-3,
|
|
2157
2200
|
foregroundMaxChroma: 5e-3
|
|
2158
2201
|
}
|
|
2159
2202
|
};
|
|
@@ -2162,36 +2205,36 @@ var muted = {
|
|
|
2162
2205
|
var shadcn = {
|
|
2163
2206
|
tokens: [
|
|
2164
2207
|
// shadcn uses bare --foreground (not --background-foreground)
|
|
2165
|
-
{ name: "foreground", value: { from: "
|
|
2208
|
+
{ name: "foreground", value: { from: "surface.foreground" } },
|
|
2166
2209
|
// card / popover — same as background
|
|
2167
|
-
{ name: "card", value: { from: "
|
|
2168
|
-
{ name: "card-foreground", value: { from: "
|
|
2169
|
-
{ name: "popover", value: { from: "
|
|
2170
|
-
{ name: "popover-foreground", value: { from: "
|
|
2210
|
+
{ name: "card", value: { from: "surface" } },
|
|
2211
|
+
{ name: "card-foreground", value: { from: "surface.foreground" } },
|
|
2212
|
+
{ name: "popover", value: { from: "surface" } },
|
|
2213
|
+
{ name: "popover-foreground", value: { from: "surface.foreground" } },
|
|
2171
2214
|
// secondary — subtle contrast from background
|
|
2172
|
-
{ name: "secondary", value: { from: "
|
|
2173
|
-
{ name: "secondary-foreground", value: { from: "
|
|
2215
|
+
{ name: "secondary", value: { from: "surface" } },
|
|
2216
|
+
{ name: "secondary-foreground", value: { from: "surface.foreground" } },
|
|
2174
2217
|
// muted — similar to secondary, but with dimmer foreground
|
|
2175
|
-
{ name: "muted", value: { from: "
|
|
2218
|
+
{ name: "muted", value: { from: "surface" } },
|
|
2176
2219
|
{
|
|
2177
2220
|
name: "muted-foreground",
|
|
2178
2221
|
value: {
|
|
2179
|
-
from: "
|
|
2222
|
+
from: "surface.foreground",
|
|
2180
2223
|
emphasis: -0.25
|
|
2181
2224
|
}
|
|
2182
2225
|
},
|
|
2183
2226
|
// accent (shadcn meaning: subtle hover highlight, not the brand color)
|
|
2184
|
-
{ name: "accent", value: { from: "
|
|
2185
|
-
{ name: "accent-foreground", value: { from: "
|
|
2227
|
+
{ name: "accent", value: { from: "surface" } },
|
|
2228
|
+
{ name: "accent-foreground", value: { from: "surface.foreground" } },
|
|
2186
2229
|
// border / input
|
|
2187
2230
|
{
|
|
2188
2231
|
name: "border",
|
|
2189
|
-
value: { from: "
|
|
2232
|
+
value: { from: "surface", emphasis: 0.8 }
|
|
2190
2233
|
},
|
|
2191
2234
|
{
|
|
2192
2235
|
name: "input",
|
|
2193
2236
|
value: {
|
|
2194
|
-
from: "
|
|
2237
|
+
from: "surface",
|
|
2195
2238
|
emphasis: 0.8
|
|
2196
2239
|
}
|
|
2197
2240
|
},
|
|
@@ -2208,7 +2251,7 @@ var shadcn = {
|
|
|
2208
2251
|
as: "css",
|
|
2209
2252
|
colors: "oklch",
|
|
2210
2253
|
roleNames: {
|
|
2211
|
-
|
|
2254
|
+
surface: "background",
|
|
2212
2255
|
accent: "primary",
|
|
2213
2256
|
negative: "destructive",
|
|
2214
2257
|
positive: "success"
|
|
@@ -2224,8 +2267,8 @@ var shadcn = {
|
|
|
2224
2267
|
// src/presets/tinted.ts
|
|
2225
2268
|
var tinted = {
|
|
2226
2269
|
style: {
|
|
2227
|
-
|
|
2228
|
-
|
|
2270
|
+
surfaceMaxChroma: 0.05,
|
|
2271
|
+
surfaceHueShift: 0,
|
|
2229
2272
|
foregroundMaxChroma: 0.015
|
|
2230
2273
|
}
|
|
2231
2274
|
};
|
|
@@ -2233,11 +2276,11 @@ var tinted = {
|
|
|
2233
2276
|
// src/presets/vibrant.ts
|
|
2234
2277
|
var vibrant = {
|
|
2235
2278
|
style: {
|
|
2236
|
-
light: { maxChroma: 0.2,
|
|
2237
|
-
dark: { maxChroma: 0.18,
|
|
2279
|
+
light: { maxChroma: 0.2, baseLightness: 0.6 },
|
|
2280
|
+
dark: { maxChroma: 0.18, baseLightness: 0.65 },
|
|
2238
2281
|
hueShift: 5,
|
|
2239
|
-
|
|
2240
|
-
|
|
2282
|
+
surfaceHueShift: 180,
|
|
2283
|
+
surfaceMaxChroma: 0.08
|
|
2241
2284
|
}
|
|
2242
2285
|
};
|
|
2243
2286
|
|
|
@@ -2300,17 +2343,17 @@ Format options:
|
|
|
2300
2343
|
--exclude-variant <name> Omit a variant from output (repeatable)
|
|
2301
2344
|
|
|
2302
2345
|
Style options:
|
|
2303
|
-
--
|
|
2304
|
-
--
|
|
2346
|
+
--surface-color <color> Override surface/neutral color
|
|
2347
|
+
--surface-hue-shift <deg> Rotate surface hue relative to accent
|
|
2305
2348
|
--hue-shift <deg> Per-variant hue shift in degrees
|
|
2306
|
-
--
|
|
2349
|
+
--surface-max-chroma <n> Max chroma for surface colors (default: 0.01)
|
|
2307
2350
|
--fg-max-chroma <n> Max chroma for foreground colors (default: 0.01)
|
|
2308
2351
|
--light-lightness <n> Light theme lightness 0-1 (default: 0.7)
|
|
2309
2352
|
--light-max-chroma <n> Light theme max chroma
|
|
2310
2353
|
--dark-lightness <n> Dark theme lightness 0-1 (default: 0.6)
|
|
2311
2354
|
--dark-max-chroma <n> Dark theme max chroma
|
|
2312
2355
|
--min-contrast <value> AAA | AA | <number> (default: AAA)
|
|
2313
|
-
--invert-dark Swap
|
|
2356
|
+
--invert-dark Swap surface/accent hues in dark mode (requires --surface-color)
|
|
2314
2357
|
|
|
2315
2358
|
Semantic colors:
|
|
2316
2359
|
--positive <color> Override positive/success color (default: auto green)
|
|
@@ -2340,7 +2383,7 @@ Examples:
|
|
|
2340
2383
|
hextimator '#6366F1' --preset muted --preset shadcn
|
|
2341
2384
|
hextimator '#6366F1' --preset shadcn --colors hsl-raw
|
|
2342
2385
|
hextimator '#22aa44' --role cta=#ee2244 --variant hover:from:strong -o theme.css
|
|
2343
|
-
hextimator '#6A5ACD' --
|
|
2386
|
+
hextimator '#6A5ACD' --surface-color '#FEBA5D' --invert-dark
|
|
2344
2387
|
hextimator '#ff6600' --simulate deuteranopia
|
|
2345
2388
|
hextimator '#ff6600' --adapt deuteranopia --cvd-severity 0.8
|
|
2346
2389
|
`.trim();
|
|
@@ -2357,10 +2400,10 @@ function run() {
|
|
|
2357
2400
|
separator: { type: "string" },
|
|
2358
2401
|
"exclude-role": { type: "string", multiple: true },
|
|
2359
2402
|
"exclude-variant": { type: "string", multiple: true },
|
|
2360
|
-
"
|
|
2361
|
-
"
|
|
2403
|
+
"surface-color": { type: "string" },
|
|
2404
|
+
"surface-hue-shift": { type: "string" },
|
|
2362
2405
|
"hue-shift": { type: "string" },
|
|
2363
|
-
"
|
|
2406
|
+
"surface-max-chroma": { type: "string" },
|
|
2364
2407
|
"fg-max-chroma": { type: "string" },
|
|
2365
2408
|
"light-lightness": { type: "string" },
|
|
2366
2409
|
"light-max-chroma": { type: "string" },
|
|
@@ -2395,25 +2438,26 @@ function run() {
|
|
|
2395
2438
|
process.exit(1);
|
|
2396
2439
|
}
|
|
2397
2440
|
const styleOptions = {};
|
|
2398
|
-
if (values["
|
|
2399
|
-
|
|
2400
|
-
|
|
2441
|
+
if (values["surface-color"])
|
|
2442
|
+
styleOptions.surfaceColor = values["surface-color"];
|
|
2443
|
+
if (values["surface-hue-shift"])
|
|
2444
|
+
styleOptions.surfaceHueShift = Number(values["surface-hue-shift"]);
|
|
2401
2445
|
if (values["hue-shift"]) styleOptions.hueShift = Number(values["hue-shift"]);
|
|
2402
|
-
if (values["
|
|
2403
|
-
styleOptions.
|
|
2446
|
+
if (values["surface-max-chroma"])
|
|
2447
|
+
styleOptions.surfaceMaxChroma = Number(values["surface-max-chroma"]);
|
|
2404
2448
|
if (values["fg-max-chroma"])
|
|
2405
2449
|
styleOptions.foregroundMaxChroma = Number(values["fg-max-chroma"]);
|
|
2406
2450
|
if (values["light-lightness"] || values["light-max-chroma"]) {
|
|
2407
2451
|
styleOptions.light = {};
|
|
2408
2452
|
if (values["light-lightness"])
|
|
2409
|
-
styleOptions.light.
|
|
2453
|
+
styleOptions.light.baseLightness = Number(values["light-lightness"]);
|
|
2410
2454
|
if (values["light-max-chroma"])
|
|
2411
2455
|
styleOptions.light.maxChroma = Number(values["light-max-chroma"]);
|
|
2412
2456
|
}
|
|
2413
2457
|
if (values["dark-lightness"] || values["dark-max-chroma"]) {
|
|
2414
2458
|
styleOptions.dark = {};
|
|
2415
2459
|
if (values["dark-lightness"])
|
|
2416
|
-
styleOptions.dark.
|
|
2460
|
+
styleOptions.dark.baseLightness = Number(values["dark-lightness"]);
|
|
2417
2461
|
if (values["dark-max-chroma"])
|
|
2418
2462
|
styleOptions.dark.maxChroma = Number(values["dark-max-chroma"]);
|
|
2419
2463
|
}
|
|
@@ -2426,7 +2470,7 @@ function run() {
|
|
|
2426
2470
|
}
|
|
2427
2471
|
}
|
|
2428
2472
|
if (values["invert-dark"]) {
|
|
2429
|
-
styleOptions.
|
|
2473
|
+
styleOptions.invertDarkModeSurfaceAccent = true;
|
|
2430
2474
|
}
|
|
2431
2475
|
const semanticColors = {};
|
|
2432
2476
|
if (values.positive) semanticColors.positive = values.positive;
|