hextimator 0.4.0 → 0.5.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 +28 -1
- package/README.md +76 -12
- package/dist/{HextimatePaletteBuilder-xqJwP_G2.d.ts → HextimatePaletteBuilder-BY1EjhFs.d.ts} +29 -6
- package/dist/chunk-JODPLAXA.js +183 -0
- package/dist/{chunk-2OMHLWID.js → chunk-RAI6L6AN.js} +81 -198
- package/dist/cli.js +105 -25
- package/dist/index-C2l4fSiA.d.ts +79 -0
- package/dist/index.d.ts +4 -79
- package/dist/index.js +4 -2
- package/dist/presets.d.ts +2 -0
- package/dist/presets.js +16 -0
- package/dist/react.d.ts +3 -3
- package/dist/react.js +11 -12
- package/llms.txt +16 -10
- package/package.json +19 -9
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __export = (target, all) => {
|
|
3
|
-
for (var name in all)
|
|
4
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
5
|
-
};
|
|
6
|
-
|
|
7
1
|
// src/convert/matrices.ts
|
|
8
2
|
var M1 = [
|
|
9
3
|
[0.4122214708, 0.5363325363, 0.0514459929],
|
|
@@ -875,13 +869,6 @@ function formatObject(entries, sep) {
|
|
|
875
869
|
}
|
|
876
870
|
return result;
|
|
877
871
|
}
|
|
878
|
-
function formatCSS(entries, sep) {
|
|
879
|
-
const result = {};
|
|
880
|
-
for (const entry of entries) {
|
|
881
|
-
result[`--${toFlatKey(entry, sep)}`] = entry.value;
|
|
882
|
-
}
|
|
883
|
-
return result;
|
|
884
|
-
}
|
|
885
872
|
function formatSCSS(entries, sep) {
|
|
886
873
|
const result = {};
|
|
887
874
|
for (const entry of entries) {
|
|
@@ -897,41 +884,97 @@ function formatTailwind(entries) {
|
|
|
897
884
|
}
|
|
898
885
|
return result;
|
|
899
886
|
}
|
|
900
|
-
function formatTailwindCSS(entries, sep) {
|
|
901
|
-
const lines = entries.map((entry) => {
|
|
902
|
-
const key = toFlatKey(entry, sep);
|
|
903
|
-
return ` --color-${key}: ${entry.value};`;
|
|
904
|
-
});
|
|
905
|
-
return `@theme {
|
|
906
|
-
${lines.join("\n")}
|
|
907
|
-
}`;
|
|
908
|
-
}
|
|
909
887
|
function formatJSON(entries, sep) {
|
|
910
888
|
return JSON.stringify(formatObject(entries, sep), null, 2);
|
|
911
889
|
}
|
|
890
|
+
function declsFromEntries(entries, sep, prefix, indent) {
|
|
891
|
+
return entries.map((e) => `${indent}${prefix}${toFlatKey(e, sep)}: ${e.value};`).join("\n");
|
|
892
|
+
}
|
|
893
|
+
function darkSelectorFor(mode) {
|
|
894
|
+
return mode === "class" ? ".dark" : '[data-theme="dark"]';
|
|
895
|
+
}
|
|
896
|
+
function formatCSSStylesheet(lightEntries, darkEntries, sep, opts = {}) {
|
|
897
|
+
const selector = opts.selector ?? ":root";
|
|
898
|
+
const darkMode = opts.darkMode ?? "media";
|
|
899
|
+
const lightBlock = `${selector} {
|
|
900
|
+
${declsFromEntries(lightEntries, sep, "--", " ")}
|
|
901
|
+
}`;
|
|
902
|
+
if (darkMode === false) return lightBlock;
|
|
903
|
+
if (darkMode === "media") {
|
|
904
|
+
const darkInner = declsFromEntries(darkEntries, sep, "--", " ");
|
|
905
|
+
return `${lightBlock}
|
|
906
|
+
@media (prefers-color-scheme: dark) {
|
|
907
|
+
${selector} {
|
|
908
|
+
${darkInner}
|
|
909
|
+
}
|
|
910
|
+
}`;
|
|
911
|
+
}
|
|
912
|
+
const darkSel = darkSelectorFor(darkMode);
|
|
913
|
+
const darkBlock = `${darkSel} {
|
|
914
|
+
${declsFromEntries(darkEntries, sep, "--", " ")}
|
|
915
|
+
}`;
|
|
916
|
+
return `${lightBlock}
|
|
917
|
+
${darkBlock}`;
|
|
918
|
+
}
|
|
919
|
+
function formatTailwindStylesheet(lightEntries, darkEntries, sep, opts = {}) {
|
|
920
|
+
const darkMode = opts.darkMode ?? "media";
|
|
921
|
+
const theme = `@theme {
|
|
922
|
+
${declsFromEntries(lightEntries, sep, "--color-", " ")}
|
|
923
|
+
}`;
|
|
924
|
+
if (darkMode === false) return theme;
|
|
925
|
+
if (darkMode === "media") {
|
|
926
|
+
const darkInner = declsFromEntries(darkEntries, sep, "--color-", " ");
|
|
927
|
+
return `${theme}
|
|
928
|
+
@media (prefers-color-scheme: dark) {
|
|
929
|
+
:root {
|
|
930
|
+
${darkInner}
|
|
931
|
+
}
|
|
932
|
+
}`;
|
|
933
|
+
}
|
|
934
|
+
const darkSel = darkSelectorFor(darkMode);
|
|
935
|
+
const darkBlock = `${darkSel} {
|
|
936
|
+
${declsFromEntries(darkEntries, sep, "--color-", " ")}
|
|
937
|
+
}`;
|
|
938
|
+
return `${theme}
|
|
939
|
+
${darkBlock}`;
|
|
940
|
+
}
|
|
912
941
|
|
|
913
942
|
// src/format/format.ts
|
|
914
943
|
function format(palette, options, standaloneTokens) {
|
|
915
944
|
const entries = buildTokenEntries(palette, options);
|
|
916
|
-
if (standaloneTokens)
|
|
917
|
-
entries.push(...standaloneTokens);
|
|
918
|
-
}
|
|
945
|
+
if (standaloneTokens) entries.push(...standaloneTokens);
|
|
919
946
|
const sep = options?.separator ?? "-";
|
|
920
947
|
switch (options?.as) {
|
|
921
|
-
case "css":
|
|
922
|
-
return formatCSS(entries, sep);
|
|
923
948
|
case "scss":
|
|
924
949
|
return formatSCSS(entries, sep);
|
|
925
950
|
case "tailwind":
|
|
926
951
|
return formatTailwind(entries);
|
|
927
|
-
case "tailwind-css":
|
|
928
|
-
return formatTailwindCSS(entries, sep);
|
|
929
952
|
case "json":
|
|
930
953
|
return formatJSON(entries, sep);
|
|
931
954
|
default:
|
|
932
955
|
return formatObject(entries, sep);
|
|
933
956
|
}
|
|
934
957
|
}
|
|
958
|
+
function formatStylesheet(lightPalette, darkPalette, options, lightStandalone, darkStandalone) {
|
|
959
|
+
const lightEntries = buildTokenEntries(lightPalette, options);
|
|
960
|
+
if (lightStandalone) lightEntries.push(...lightStandalone);
|
|
961
|
+
const darkEntries = buildTokenEntries(darkPalette, options);
|
|
962
|
+
if (darkStandalone) darkEntries.push(...darkStandalone);
|
|
963
|
+
const sep = options?.separator ?? "-";
|
|
964
|
+
const stylesheetOpts = {
|
|
965
|
+
selector: options?.selector,
|
|
966
|
+
darkMode: options?.darkMode
|
|
967
|
+
};
|
|
968
|
+
if (options?.as === "tailwind-css") {
|
|
969
|
+
return formatTailwindStylesheet(
|
|
970
|
+
lightEntries,
|
|
971
|
+
darkEntries,
|
|
972
|
+
sep,
|
|
973
|
+
stylesheetOpts
|
|
974
|
+
);
|
|
975
|
+
}
|
|
976
|
+
return formatCSSStylesheet(lightEntries, darkEntries, sep, stylesheetOpts);
|
|
977
|
+
}
|
|
935
978
|
|
|
936
979
|
// src/generate/consts.ts
|
|
937
980
|
var DEFAULT_LIGHT_THEME_LIGHTNESS = 0.7;
|
|
@@ -1705,6 +1748,15 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
|
|
|
1705
1748
|
this.darkPalette,
|
|
1706
1749
|
colorFormat
|
|
1707
1750
|
);
|
|
1751
|
+
if (mergedOptions?.as === "css" || mergedOptions?.as === "tailwind-css") {
|
|
1752
|
+
return formatStylesheet(
|
|
1753
|
+
this.lightPalette,
|
|
1754
|
+
this.darkPalette,
|
|
1755
|
+
mergedOptions,
|
|
1756
|
+
lightTokens,
|
|
1757
|
+
darkTokens
|
|
1758
|
+
);
|
|
1759
|
+
}
|
|
1708
1760
|
return {
|
|
1709
1761
|
light: format(this.lightPalette, mergedOptions, lightTokens),
|
|
1710
1762
|
dark: format(this.darkPalette, mergedOptions, darkTokens)
|
|
@@ -2034,174 +2086,6 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
|
|
|
2034
2086
|
}
|
|
2035
2087
|
};
|
|
2036
2088
|
|
|
2037
|
-
// src/presets/index.ts
|
|
2038
|
-
var presets_exports = {};
|
|
2039
|
-
__export(presets_exports, {
|
|
2040
|
-
bold: () => bold,
|
|
2041
|
-
mui: () => mui,
|
|
2042
|
-
muted: () => muted,
|
|
2043
|
-
shadcn: () => shadcn,
|
|
2044
|
-
tinted: () => tinted,
|
|
2045
|
-
vibrant: () => vibrant
|
|
2046
|
-
});
|
|
2047
|
-
|
|
2048
|
-
// src/presets/bold.ts
|
|
2049
|
-
var bold = {
|
|
2050
|
-
style: {
|
|
2051
|
-
light: { lightness: 0.5 },
|
|
2052
|
-
dark: { lightness: 0.8 },
|
|
2053
|
-
baseMaxChroma: 0.06,
|
|
2054
|
-
foregroundMaxChroma: 0.02
|
|
2055
|
-
}
|
|
2056
|
-
};
|
|
2057
|
-
|
|
2058
|
-
// src/presets/mui.ts
|
|
2059
|
-
var mui = {
|
|
2060
|
-
roles: [
|
|
2061
|
-
{ name: "info", color: "#0288d1" },
|
|
2062
|
-
{ name: "secondary", color: { from: "accent", hue: 180 } }
|
|
2063
|
-
],
|
|
2064
|
-
tokens: [
|
|
2065
|
-
// background
|
|
2066
|
-
{ name: "background-default", value: { from: "base" } },
|
|
2067
|
-
{
|
|
2068
|
-
name: "background-paper",
|
|
2069
|
-
value: { from: "base", emphasis: -0.025 }
|
|
2070
|
-
},
|
|
2071
|
-
// text
|
|
2072
|
-
{ name: "text-primary", value: { from: "base.foreground" } },
|
|
2073
|
-
{
|
|
2074
|
-
name: "text-secondary",
|
|
2075
|
-
value: { from: "base.foreground", emphasis: -0.2 }
|
|
2076
|
-
},
|
|
2077
|
-
{
|
|
2078
|
-
name: "text-disabled",
|
|
2079
|
-
value: { from: "base.foreground", emphasis: -0.4 }
|
|
2080
|
-
},
|
|
2081
|
-
// divider
|
|
2082
|
-
{ name: "divider", value: { from: "base", emphasis: 0.12 } },
|
|
2083
|
-
// action tokens
|
|
2084
|
-
{ name: "action-hover", value: { from: "base", emphasis: 0.04 } },
|
|
2085
|
-
{ name: "action-selected", value: { from: "base", emphasis: 0.08 } },
|
|
2086
|
-
{ name: "action-disabled", value: { from: "base", emphasis: 0.15 } },
|
|
2087
|
-
{
|
|
2088
|
-
name: "action-disabledBackground",
|
|
2089
|
-
value: { from: "base", emphasis: 0.06 }
|
|
2090
|
-
},
|
|
2091
|
-
{ name: "action-focus", value: { from: "base", emphasis: 0.06 } }
|
|
2092
|
-
],
|
|
2093
|
-
format: {
|
|
2094
|
-
as: "object",
|
|
2095
|
-
colors: "hex",
|
|
2096
|
-
separator: "-",
|
|
2097
|
-
roleNames: {
|
|
2098
|
-
accent: "primary",
|
|
2099
|
-
negative: "error",
|
|
2100
|
-
positive: "success"
|
|
2101
|
-
},
|
|
2102
|
-
variantNames: {
|
|
2103
|
-
DEFAULT: "main",
|
|
2104
|
-
weak: "light",
|
|
2105
|
-
strong: "dark",
|
|
2106
|
-
foreground: "contrastText"
|
|
2107
|
-
},
|
|
2108
|
-
excludeRoles: ["base"]
|
|
2109
|
-
}
|
|
2110
|
-
};
|
|
2111
|
-
|
|
2112
|
-
// src/presets/muted.ts
|
|
2113
|
-
var muted = {
|
|
2114
|
-
style: {
|
|
2115
|
-
light: { maxChroma: 0.08 },
|
|
2116
|
-
dark: { maxChroma: 0.07 },
|
|
2117
|
-
baseMaxChroma: 5e-3,
|
|
2118
|
-
foregroundMaxChroma: 5e-3
|
|
2119
|
-
}
|
|
2120
|
-
};
|
|
2121
|
-
|
|
2122
|
-
// src/presets/shadcn.ts
|
|
2123
|
-
var shadcn = {
|
|
2124
|
-
tokens: [
|
|
2125
|
-
// shadcn uses bare --foreground (not --background-foreground)
|
|
2126
|
-
{ name: "foreground", value: { from: "base.foreground" } },
|
|
2127
|
-
// card / popover — same as background
|
|
2128
|
-
{ name: "card", value: { from: "base" } },
|
|
2129
|
-
{ name: "card-foreground", value: { from: "base.foreground" } },
|
|
2130
|
-
{ name: "popover", value: { from: "base" } },
|
|
2131
|
-
{ name: "popover-foreground", value: { from: "base.foreground" } },
|
|
2132
|
-
// secondary — subtle contrast from background
|
|
2133
|
-
{ name: "secondary", value: { from: "base" } },
|
|
2134
|
-
{ name: "secondary-foreground", value: { from: "base.foreground" } },
|
|
2135
|
-
// muted — similar to secondary, but with dimmer foreground
|
|
2136
|
-
{ name: "muted", value: { from: "base" } },
|
|
2137
|
-
{
|
|
2138
|
-
name: "muted-foreground",
|
|
2139
|
-
value: {
|
|
2140
|
-
from: "base.foreground",
|
|
2141
|
-
emphasis: -0.25
|
|
2142
|
-
}
|
|
2143
|
-
},
|
|
2144
|
-
// accent (shadcn meaning: subtle hover highlight, not the brand color)
|
|
2145
|
-
{ name: "accent", value: { from: "base" } },
|
|
2146
|
-
{ name: "accent-foreground", value: { from: "base.foreground" } },
|
|
2147
|
-
// border / input
|
|
2148
|
-
{
|
|
2149
|
-
name: "border",
|
|
2150
|
-
value: { from: "base", emphasis: 0.8 }
|
|
2151
|
-
},
|
|
2152
|
-
{
|
|
2153
|
-
name: "input",
|
|
2154
|
-
value: {
|
|
2155
|
-
from: "base",
|
|
2156
|
-
emphasis: 0.8
|
|
2157
|
-
}
|
|
2158
|
-
},
|
|
2159
|
-
// ring — uses the brand/primary color
|
|
2160
|
-
{ name: "ring", value: { from: "accent" } },
|
|
2161
|
-
// chart tokens colors use brand/priamry color
|
|
2162
|
-
{ name: "chart-1", value: { from: "accent" } },
|
|
2163
|
-
{ name: "chart-2", value: { from: "chart-1", emphasis: -0.04 } },
|
|
2164
|
-
{ name: "chart-3", value: { from: "chart-2", emphasis: -0.04 } },
|
|
2165
|
-
{ name: "chart-4", value: { from: "chart-3", emphasis: -0.04 } },
|
|
2166
|
-
{ name: "chart-5", value: { from: "chart-4", emphasis: -0.04 } }
|
|
2167
|
-
],
|
|
2168
|
-
format: {
|
|
2169
|
-
as: "css",
|
|
2170
|
-
colors: "oklch",
|
|
2171
|
-
roleNames: {
|
|
2172
|
-
base: "background",
|
|
2173
|
-
accent: "primary",
|
|
2174
|
-
negative: "destructive",
|
|
2175
|
-
positive: "success"
|
|
2176
|
-
},
|
|
2177
|
-
variantNames: {
|
|
2178
|
-
foreground: "foreground"
|
|
2179
|
-
},
|
|
2180
|
-
excludeRoles: ["warning"],
|
|
2181
|
-
excludeVariants: ["strong", "weak"]
|
|
2182
|
-
}
|
|
2183
|
-
};
|
|
2184
|
-
|
|
2185
|
-
// src/presets/tinted.ts
|
|
2186
|
-
var tinted = {
|
|
2187
|
-
style: {
|
|
2188
|
-
baseMaxChroma: 0.05,
|
|
2189
|
-
baseHueShift: 0,
|
|
2190
|
-
foregroundMaxChroma: 0.015
|
|
2191
|
-
}
|
|
2192
|
-
};
|
|
2193
|
-
|
|
2194
|
-
// src/presets/vibrant.ts
|
|
2195
|
-
var vibrant = {
|
|
2196
|
-
style: {
|
|
2197
|
-
light: { maxChroma: 0.2, lightness: 0.6 },
|
|
2198
|
-
dark: { maxChroma: 0.18, lightness: 0.65 },
|
|
2199
|
-
hueShift: 5,
|
|
2200
|
-
baseHueShift: 180,
|
|
2201
|
-
baseMaxChroma: 0.08
|
|
2202
|
-
}
|
|
2203
|
-
};
|
|
2204
|
-
|
|
2205
2089
|
// src/index.ts
|
|
2206
2090
|
var HextimateError = class extends Error {
|
|
2207
2091
|
constructor(input, message) {
|
|
@@ -2231,7 +2115,6 @@ export {
|
|
|
2231
2115
|
daltonizeColor,
|
|
2232
2116
|
simulateColor,
|
|
2233
2117
|
HextimatePaletteBuilder,
|
|
2234
|
-
presets_exports,
|
|
2235
2118
|
HextimateError,
|
|
2236
2119
|
hextimate
|
|
2237
2120
|
};
|
package/dist/cli.js
CHANGED
|
@@ -877,13 +877,6 @@ function formatObject(entries, sep) {
|
|
|
877
877
|
}
|
|
878
878
|
return result;
|
|
879
879
|
}
|
|
880
|
-
function formatCSS(entries, sep) {
|
|
881
|
-
const result = {};
|
|
882
|
-
for (const entry of entries) {
|
|
883
|
-
result[`--${toFlatKey(entry, sep)}`] = entry.value;
|
|
884
|
-
}
|
|
885
|
-
return result;
|
|
886
|
-
}
|
|
887
880
|
function formatSCSS(entries, sep) {
|
|
888
881
|
const result = {};
|
|
889
882
|
for (const entry of entries) {
|
|
@@ -899,41 +892,97 @@ function formatTailwind(entries) {
|
|
|
899
892
|
}
|
|
900
893
|
return result;
|
|
901
894
|
}
|
|
902
|
-
function formatTailwindCSS(entries, sep) {
|
|
903
|
-
const lines = entries.map((entry) => {
|
|
904
|
-
const key = toFlatKey(entry, sep);
|
|
905
|
-
return ` --color-${key}: ${entry.value};`;
|
|
906
|
-
});
|
|
907
|
-
return `@theme {
|
|
908
|
-
${lines.join("\n")}
|
|
909
|
-
}`;
|
|
910
|
-
}
|
|
911
895
|
function formatJSON(entries, sep) {
|
|
912
896
|
return JSON.stringify(formatObject(entries, sep), null, 2);
|
|
913
897
|
}
|
|
898
|
+
function declsFromEntries(entries, sep, prefix, indent) {
|
|
899
|
+
return entries.map((e) => `${indent}${prefix}${toFlatKey(e, sep)}: ${e.value};`).join("\n");
|
|
900
|
+
}
|
|
901
|
+
function darkSelectorFor(mode) {
|
|
902
|
+
return mode === "class" ? ".dark" : '[data-theme="dark"]';
|
|
903
|
+
}
|
|
904
|
+
function formatCSSStylesheet(lightEntries, darkEntries, sep, opts = {}) {
|
|
905
|
+
const selector = opts.selector ?? ":root";
|
|
906
|
+
const darkMode = opts.darkMode ?? "media";
|
|
907
|
+
const lightBlock = `${selector} {
|
|
908
|
+
${declsFromEntries(lightEntries, sep, "--", " ")}
|
|
909
|
+
}`;
|
|
910
|
+
if (darkMode === false) return lightBlock;
|
|
911
|
+
if (darkMode === "media") {
|
|
912
|
+
const darkInner = declsFromEntries(darkEntries, sep, "--", " ");
|
|
913
|
+
return `${lightBlock}
|
|
914
|
+
@media (prefers-color-scheme: dark) {
|
|
915
|
+
${selector} {
|
|
916
|
+
${darkInner}
|
|
917
|
+
}
|
|
918
|
+
}`;
|
|
919
|
+
}
|
|
920
|
+
const darkSel = darkSelectorFor(darkMode);
|
|
921
|
+
const darkBlock = `${darkSel} {
|
|
922
|
+
${declsFromEntries(darkEntries, sep, "--", " ")}
|
|
923
|
+
}`;
|
|
924
|
+
return `${lightBlock}
|
|
925
|
+
${darkBlock}`;
|
|
926
|
+
}
|
|
927
|
+
function formatTailwindStylesheet(lightEntries, darkEntries, sep, opts = {}) {
|
|
928
|
+
const darkMode = opts.darkMode ?? "media";
|
|
929
|
+
const theme = `@theme {
|
|
930
|
+
${declsFromEntries(lightEntries, sep, "--color-", " ")}
|
|
931
|
+
}`;
|
|
932
|
+
if (darkMode === false) return theme;
|
|
933
|
+
if (darkMode === "media") {
|
|
934
|
+
const darkInner = declsFromEntries(darkEntries, sep, "--color-", " ");
|
|
935
|
+
return `${theme}
|
|
936
|
+
@media (prefers-color-scheme: dark) {
|
|
937
|
+
:root {
|
|
938
|
+
${darkInner}
|
|
939
|
+
}
|
|
940
|
+
}`;
|
|
941
|
+
}
|
|
942
|
+
const darkSel = darkSelectorFor(darkMode);
|
|
943
|
+
const darkBlock = `${darkSel} {
|
|
944
|
+
${declsFromEntries(darkEntries, sep, "--color-", " ")}
|
|
945
|
+
}`;
|
|
946
|
+
return `${theme}
|
|
947
|
+
${darkBlock}`;
|
|
948
|
+
}
|
|
914
949
|
|
|
915
950
|
// src/format/format.ts
|
|
916
951
|
function format(palette, options, standaloneTokens) {
|
|
917
952
|
const entries = buildTokenEntries(palette, options);
|
|
918
|
-
if (standaloneTokens)
|
|
919
|
-
entries.push(...standaloneTokens);
|
|
920
|
-
}
|
|
953
|
+
if (standaloneTokens) entries.push(...standaloneTokens);
|
|
921
954
|
const sep = options?.separator ?? "-";
|
|
922
955
|
switch (options?.as) {
|
|
923
|
-
case "css":
|
|
924
|
-
return formatCSS(entries, sep);
|
|
925
956
|
case "scss":
|
|
926
957
|
return formatSCSS(entries, sep);
|
|
927
958
|
case "tailwind":
|
|
928
959
|
return formatTailwind(entries);
|
|
929
|
-
case "tailwind-css":
|
|
930
|
-
return formatTailwindCSS(entries, sep);
|
|
931
960
|
case "json":
|
|
932
961
|
return formatJSON(entries, sep);
|
|
933
962
|
default:
|
|
934
963
|
return formatObject(entries, sep);
|
|
935
964
|
}
|
|
936
965
|
}
|
|
966
|
+
function formatStylesheet(lightPalette, darkPalette, options, lightStandalone, darkStandalone) {
|
|
967
|
+
const lightEntries = buildTokenEntries(lightPalette, options);
|
|
968
|
+
if (lightStandalone) lightEntries.push(...lightStandalone);
|
|
969
|
+
const darkEntries = buildTokenEntries(darkPalette, options);
|
|
970
|
+
if (darkStandalone) darkEntries.push(...darkStandalone);
|
|
971
|
+
const sep = options?.separator ?? "-";
|
|
972
|
+
const stylesheetOpts = {
|
|
973
|
+
selector: options?.selector,
|
|
974
|
+
darkMode: options?.darkMode
|
|
975
|
+
};
|
|
976
|
+
if (options?.as === "tailwind-css") {
|
|
977
|
+
return formatTailwindStylesheet(
|
|
978
|
+
lightEntries,
|
|
979
|
+
darkEntries,
|
|
980
|
+
sep,
|
|
981
|
+
stylesheetOpts
|
|
982
|
+
);
|
|
983
|
+
}
|
|
984
|
+
return formatCSSStylesheet(lightEntries, darkEntries, sep, stylesheetOpts);
|
|
985
|
+
}
|
|
937
986
|
|
|
938
987
|
// src/generate/consts.ts
|
|
939
988
|
var DEFAULT_LIGHT_THEME_LIGHTNESS = 0.7;
|
|
@@ -1707,6 +1756,15 @@ var HextimatePaletteBuilder = class _HextimatePaletteBuilder {
|
|
|
1707
1756
|
this.darkPalette,
|
|
1708
1757
|
colorFormat
|
|
1709
1758
|
);
|
|
1759
|
+
if (mergedOptions?.as === "css" || mergedOptions?.as === "tailwind-css") {
|
|
1760
|
+
return formatStylesheet(
|
|
1761
|
+
this.lightPalette,
|
|
1762
|
+
this.darkPalette,
|
|
1763
|
+
mergedOptions,
|
|
1764
|
+
lightTokens,
|
|
1765
|
+
darkTokens
|
|
1766
|
+
);
|
|
1767
|
+
}
|
|
1710
1768
|
return {
|
|
1711
1769
|
light: format(this.lightPalette, mergedOptions, lightTokens),
|
|
1712
1770
|
dark: format(this.darkPalette, mergedOptions, darkTokens)
|
|
@@ -2234,7 +2292,9 @@ Presets:
|
|
|
2234
2292
|
Format options:
|
|
2235
2293
|
-f, --format <type> css | object | tailwind | tailwind-css | scss | json (default: css)
|
|
2236
2294
|
-c, --colors <type> hex | rgb | hsl | oklch | p3 and -raw variants (default: hex)
|
|
2237
|
-
-t, --theme <type> light | dark | both
|
|
2295
|
+
-t, --theme <type> light | dark | both (ignored for css/tailwind-css) (default: both)
|
|
2296
|
+
--dark-mode <strategy> media | class | data-attribute | off (css/tailwind-css only, default: media)
|
|
2297
|
+
--selector <css> Root selector for css output (default: :root)
|
|
2238
2298
|
--separator <char> Token separator (default: -)
|
|
2239
2299
|
--exclude-role <name> Omit a role from output (repeatable)
|
|
2240
2300
|
--exclude-variant <name> Omit a variant from output (repeatable)
|
|
@@ -2292,6 +2352,8 @@ function run() {
|
|
|
2292
2352
|
format: { type: "string", short: "f" },
|
|
2293
2353
|
colors: { type: "string", short: "c" },
|
|
2294
2354
|
theme: { type: "string", short: "t", default: "both" },
|
|
2355
|
+
"dark-mode": { type: "string" },
|
|
2356
|
+
selector: { type: "string" },
|
|
2295
2357
|
separator: { type: "string" },
|
|
2296
2358
|
"exclude-role": { type: "string", multiple: true },
|
|
2297
2359
|
"exclude-variant": { type: "string", multiple: true },
|
|
@@ -2466,10 +2528,28 @@ function run() {
|
|
|
2466
2528
|
if (values["exclude-variant"]?.length) {
|
|
2467
2529
|
formatOptions.excludeVariants = values["exclude-variant"];
|
|
2468
2530
|
}
|
|
2531
|
+
if (values["dark-mode"]) {
|
|
2532
|
+
const dm = values["dark-mode"];
|
|
2533
|
+
if (dm === "off" || dm === "false") {
|
|
2534
|
+
formatOptions.darkMode = false;
|
|
2535
|
+
} else if (dm === "media" || dm === "class" || dm === "data-attribute") {
|
|
2536
|
+
formatOptions.darkMode = dm;
|
|
2537
|
+
} else {
|
|
2538
|
+
console.error(
|
|
2539
|
+
`Error: invalid --dark-mode "${dm}". Expected: media | class | data-attribute | off`
|
|
2540
|
+
);
|
|
2541
|
+
process.exit(1);
|
|
2542
|
+
}
|
|
2543
|
+
}
|
|
2544
|
+
if (values.selector) {
|
|
2545
|
+
formatOptions.selector = values.selector;
|
|
2546
|
+
}
|
|
2469
2547
|
const result = builder.format(formatOptions);
|
|
2470
2548
|
const themeFilter = values.theme;
|
|
2471
2549
|
let output;
|
|
2472
|
-
if (
|
|
2550
|
+
if (typeof result === "string") {
|
|
2551
|
+
output = result;
|
|
2552
|
+
} else if (themeFilter === "light") {
|
|
2473
2553
|
output = serialize(result.light);
|
|
2474
2554
|
} else if (themeFilter === "dark") {
|
|
2475
2555
|
output = serialize(result.dark);
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { h as HextimatePreset } from './HextimatePaletteBuilder-BY1EjhFs.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Darker accents on light themes, lighter accents on dark themes.
|
|
5
|
+
* Higher chroma for neutrals.
|
|
6
|
+
*/
|
|
7
|
+
declare const bold: HextimatePreset;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Preset for Material UI (MUI) projects.
|
|
11
|
+
*
|
|
12
|
+
* Generates palette tokens matching MUI's theme structure:
|
|
13
|
+
* `primary`, `secondary`, `error`, `warning`, `info`, `success` —
|
|
14
|
+
* each with `main`, `light`, `dark`, and `contrastText` variants.
|
|
15
|
+
*
|
|
16
|
+
* Also generates `background` (`default`, `paper`), `text` (`primary`,
|
|
17
|
+
* `secondary`, `disabled`), `divider`, and `action` tokens.
|
|
18
|
+
*
|
|
19
|
+
* Defaults to `object` format for use with `createTheme()`. Override with
|
|
20
|
+
* `.format({ as: 'css' })` for MUI's CSS variables mode.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* import { hextimate, presets } from 'hextimator';
|
|
24
|
+
* import { createTheme } from '@mui/material/styles';
|
|
25
|
+
*
|
|
26
|
+
* const palette = hextimate('#6366F1')
|
|
27
|
+
* .preset(presets.mui)
|
|
28
|
+
* .format();
|
|
29
|
+
*
|
|
30
|
+
* const theme = createTheme({ palette: palette.light });
|
|
31
|
+
*/
|
|
32
|
+
declare const mui: HextimatePreset;
|
|
33
|
+
|
|
34
|
+
/** Desaturated, restrained palette. Low chroma across the board. */
|
|
35
|
+
declare const muted: HextimatePreset;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Preset for shadcn/ui projects.
|
|
39
|
+
*
|
|
40
|
+
* Generates all CSS variables that shadcn/ui components expect:
|
|
41
|
+
* `--background`, `--foreground`, `--primary`, `--secondary`, `--muted`,
|
|
42
|
+
* `--accent`, `--destructive`, `--card`, `--popover`, `--border`, `--input`, `--ring`,
|
|
43
|
+
* plus their `-foreground` counterparts.
|
|
44
|
+
*
|
|
45
|
+
* Defaults to `oklch` color format (modern shadcn). Override with
|
|
46
|
+
* `.format({ colors: 'hsl-raw' })` for older shadcn setups.
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* import { hextimate, presets } from 'hextimator';
|
|
50
|
+
*
|
|
51
|
+
* const theme = hextimate('#6366F1')
|
|
52
|
+
* .preset(presets.shadcn)
|
|
53
|
+
* .format();
|
|
54
|
+
*
|
|
55
|
+
* // Use with React hook:
|
|
56
|
+
* const palette = useHextimator('#6366F1', {
|
|
57
|
+
* configure: (b) => b.preset(presets.shadcn),
|
|
58
|
+
* });
|
|
59
|
+
*/
|
|
60
|
+
declare const shadcn: HextimatePreset;
|
|
61
|
+
|
|
62
|
+
/** Neutrals pick up the accent hue for a cohesive, branded feel. */
|
|
63
|
+
declare const tinted: HextimatePreset;
|
|
64
|
+
|
|
65
|
+
/** High-saturation palette. Colors that pop. */
|
|
66
|
+
declare const vibrant: HextimatePreset;
|
|
67
|
+
|
|
68
|
+
declare const index_HextimatePreset: typeof HextimatePreset;
|
|
69
|
+
declare const index_bold: typeof bold;
|
|
70
|
+
declare const index_mui: typeof mui;
|
|
71
|
+
declare const index_muted: typeof muted;
|
|
72
|
+
declare const index_shadcn: typeof shadcn;
|
|
73
|
+
declare const index_tinted: typeof tinted;
|
|
74
|
+
declare const index_vibrant: typeof vibrant;
|
|
75
|
+
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 };
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export { muted as a, bold as b, index as i, mui as m, shadcn as s, tinted as t, vibrant as v };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { C as Color, a as CVDType, O as OKLCH, b as ColorSpace, c as ColorInSpace, d as ColorInput, H 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 HextimatePaletteBuilder } from './HextimatePaletteBuilder-BY1EjhFs.js';
|
|
2
|
+
export { D as DerivedToken, F as FlatTokenMap, e as FormatResult, f as HextimateFormatOptions, g as HextimateOptions, h as HextimatePreset, i as HextimateResult, j as HextimateStyleOptions, N as NestedTokenMap, T as ThemeAdjustments, k as TokenValue, V as VariantPlacement } from './HextimatePaletteBuilder-BY1EjhFs.js';
|
|
3
|
+
export { i as presets } from './index-C2l4fSiA.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Daltonize a color for a specific type of color vision deficiency (CVD).
|
|
@@ -63,82 +64,6 @@ declare function convert<S extends ColorSpace>(color: Color, to: S): ColorInSpac
|
|
|
63
64
|
*/
|
|
64
65
|
declare function parse(input: ColorInput, assumeSpace?: ColorSpace): Color;
|
|
65
66
|
|
|
66
|
-
/**
|
|
67
|
-
* Darker accents on light themes, lighter accents on dark themes.
|
|
68
|
-
* Higher chroma for neutrals.
|
|
69
|
-
*/
|
|
70
|
-
declare const bold: HextimatePreset;
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Preset for Material UI (MUI) projects.
|
|
74
|
-
*
|
|
75
|
-
* Generates palette tokens matching MUI's theme structure:
|
|
76
|
-
* `primary`, `secondary`, `error`, `warning`, `info`, `success` —
|
|
77
|
-
* each with `main`, `light`, `dark`, and `contrastText` variants.
|
|
78
|
-
*
|
|
79
|
-
* Also generates `background` (`default`, `paper`), `text` (`primary`,
|
|
80
|
-
* `secondary`, `disabled`), `divider`, and `action` tokens.
|
|
81
|
-
*
|
|
82
|
-
* Defaults to `object` format for use with `createTheme()`. Override with
|
|
83
|
-
* `.format({ as: 'css' })` for MUI's CSS variables mode.
|
|
84
|
-
*
|
|
85
|
-
* @example
|
|
86
|
-
* import { hextimate, presets } from 'hextimator';
|
|
87
|
-
* import { createTheme } from '@mui/material/styles';
|
|
88
|
-
*
|
|
89
|
-
* const palette = hextimate('#6366F1')
|
|
90
|
-
* .preset(presets.mui)
|
|
91
|
-
* .format();
|
|
92
|
-
*
|
|
93
|
-
* const theme = createTheme({ palette: palette.light });
|
|
94
|
-
*/
|
|
95
|
-
declare const mui: HextimatePreset;
|
|
96
|
-
|
|
97
|
-
/** Desaturated, restrained palette. Low chroma across the board. */
|
|
98
|
-
declare const muted: HextimatePreset;
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* Preset for shadcn/ui projects.
|
|
102
|
-
*
|
|
103
|
-
* Generates all CSS variables that shadcn/ui components expect:
|
|
104
|
-
* `--background`, `--foreground`, `--primary`, `--secondary`, `--muted`,
|
|
105
|
-
* `--accent`, `--destructive`, `--card`, `--popover`, `--border`, `--input`, `--ring`,
|
|
106
|
-
* plus their `-foreground` counterparts.
|
|
107
|
-
*
|
|
108
|
-
* Defaults to `oklch` color format (modern shadcn). Override with
|
|
109
|
-
* `.format({ colors: 'hsl-raw' })` for older shadcn setups.
|
|
110
|
-
*
|
|
111
|
-
* @example
|
|
112
|
-
* import { hextimate, presets } from 'hextimator';
|
|
113
|
-
*
|
|
114
|
-
* const theme = hextimate('#6366F1')
|
|
115
|
-
* .preset(presets.shadcn)
|
|
116
|
-
* .format();
|
|
117
|
-
*
|
|
118
|
-
* // Use with React hook:
|
|
119
|
-
* const palette = useHextimator('#6366F1', {
|
|
120
|
-
* configure: (b) => b.preset(presets.shadcn),
|
|
121
|
-
* });
|
|
122
|
-
*/
|
|
123
|
-
declare const shadcn: HextimatePreset;
|
|
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
|
-
|
|
131
|
-
declare const index_HextimatePreset: typeof HextimatePreset;
|
|
132
|
-
declare const index_bold: typeof bold;
|
|
133
|
-
declare const index_mui: typeof mui;
|
|
134
|
-
declare const index_muted: typeof muted;
|
|
135
|
-
declare const index_shadcn: typeof shadcn;
|
|
136
|
-
declare const index_tinted: typeof tinted;
|
|
137
|
-
declare const index_vibrant: typeof vibrant;
|
|
138
|
-
declare namespace index {
|
|
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 };
|
|
140
|
-
}
|
|
141
|
-
|
|
142
67
|
/** Thrown when `hextimate()` fails to parse or generate a palette from the given input. */
|
|
143
68
|
declare class HextimateError extends Error {
|
|
144
69
|
readonly input: ColorInput;
|
|
@@ -162,4 +87,4 @@ declare class HextimateError extends Error {
|
|
|
162
87
|
*/
|
|
163
88
|
declare function hextimate(color: ColorInput): HextimatePaletteBuilder;
|
|
164
89
|
|
|
165
|
-
export { CVDType, HextimateError, HextimatePaletteBuilder,
|
|
90
|
+
export { CVDType, HextimateError, HextimatePaletteBuilder, convert as convertColor, daltonizeColor, hextimate, parse as parseColor, simulateColor };
|