@digdir/designsystemet 1.5.0 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/configs/test-tokens.config.json +15 -1
- package/dist/bin/config.js +14 -3
- package/dist/bin/designsystemet.js +105 -43
- package/dist/config.schema.json +52 -0
- package/dist/src/colors/colorMetadata.d.ts +1 -0
- package/dist/src/colors/colorMetadata.d.ts.map +1 -1
- package/dist/src/colors/colorMetadata.js +2 -0
- package/dist/src/colors/index.js +2 -0
- package/dist/src/colors/theme.js +1 -0
- package/dist/src/config.d.ts +70 -0
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +12 -1
- package/dist/src/index.js +90 -37
- package/dist/src/scripts/createJsonSchema.js +12 -1
- package/dist/src/scripts/update-preview-tokens.js +80 -28
- package/dist/src/tokens/build.js +45 -27
- package/dist/src/tokens/create/generators/$designsystemet.js +9 -9
- package/dist/src/tokens/create/generators/color.d.ts +2 -1
- package/dist/src/tokens/create/generators/color.d.ts.map +1 -1
- package/dist/src/tokens/create/generators/color.js +40 -6
- package/dist/src/tokens/create/write.js +9 -9
- package/dist/src/tokens/create.js +44 -10
- package/dist/src/tokens/format.js +89 -37
- package/dist/src/tokens/index.js +89 -37
- package/dist/src/tokens/process/configs/color.js +31 -13
- package/dist/src/tokens/process/configs/semantic.js +31 -13
- package/dist/src/tokens/process/configs/size-mode.js +31 -13
- package/dist/src/tokens/process/configs/size.js +31 -13
- package/dist/src/tokens/process/configs/type-scale.js +31 -13
- package/dist/src/tokens/process/configs/typography.js +31 -13
- package/dist/src/tokens/process/configs.js +36 -18
- package/dist/src/tokens/process/formats/css/color.js +31 -13
- package/dist/src/tokens/process/formats/css/semantic.js +31 -13
- package/dist/src/tokens/process/formats/css/size-mode.js +31 -13
- package/dist/src/tokens/process/formats/css/size.d.ts +4 -0
- package/dist/src/tokens/process/formats/css/size.d.ts.map +1 -1
- package/dist/src/tokens/process/formats/css/size.js +33 -14
- package/dist/src/tokens/process/formats/css/type-scale.d.ts.map +1 -1
- package/dist/src/tokens/process/formats/css/type-scale.js +31 -13
- package/dist/src/tokens/process/formats/css/typography.js +33 -15
- package/dist/src/tokens/process/formats/css.js +31 -13
- package/dist/src/tokens/process/output/declarations.js +40 -22
- package/dist/src/tokens/process/output/theme.js +9 -9
- package/dist/src/tokens/process/platform.js +36 -18
- package/dist/src/tokens/process/utils/getMultidimensionalThemes.js +31 -13
- package/dist/src/tokens/types.d.ts +1 -1
- package/dist/src/tokens/types.d.ts.map +1 -1
- package/package.json +9 -9
|
@@ -20,7 +20,21 @@
|
|
|
20
20
|
"typography": {
|
|
21
21
|
"fontFamily": "Inter"
|
|
22
22
|
},
|
|
23
|
-
"borderRadius": 8
|
|
23
|
+
"borderRadius": 8,
|
|
24
|
+
"overrides": {
|
|
25
|
+
"colors": {
|
|
26
|
+
"dominant": {
|
|
27
|
+
"background-default": {
|
|
28
|
+
"light": "#ff0000",
|
|
29
|
+
"dark": "#000fff"
|
|
30
|
+
},
|
|
31
|
+
"background-tinted": {
|
|
32
|
+
"light": "#f0ff00",
|
|
33
|
+
"dark": "#ff00ff"
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
24
38
|
},
|
|
25
39
|
"other-org": {
|
|
26
40
|
"colors": {
|
package/dist/bin/config.js
CHANGED
|
@@ -254,6 +254,7 @@ var colorMetadata = {
|
|
|
254
254
|
}
|
|
255
255
|
};
|
|
256
256
|
var colorMetadataByNumber = R.indexBy((metadata) => metadata.number, Object.values(colorMetadata));
|
|
257
|
+
var colorNames = Object.keys(colorMetadata);
|
|
257
258
|
|
|
258
259
|
// src/colors/theme.ts
|
|
259
260
|
import chroma2 from "chroma-js";
|
|
@@ -389,6 +390,15 @@ var colorCategorySchema = z.record(
|
|
|
389
390
|
).refine((colors) => !Object.keys(colors).some((key) => RESERVED_COLORS.includes(key.toLowerCase())), {
|
|
390
391
|
error: `Color names cannot include reserved names: ${RESERVED_COLORS.join(", ")}`
|
|
391
392
|
}).describe("An object with one or more color definitions. The property name is used as the color name.");
|
|
393
|
+
var colorModeOverrideSchema = z.object({
|
|
394
|
+
light: colorSchema.optional(),
|
|
395
|
+
dark: colorSchema.optional()
|
|
396
|
+
}).describe('Override values for semantic color tokens like "background-subtle", "border-default", etc.');
|
|
397
|
+
var colorWeightOverrideSchema = z.partialRecord(z.enum(colorNames), colorModeOverrideSchema).describe('The name of the color to add overrides for, e.g. "accent"');
|
|
398
|
+
var semanticColorOverrideSchema = z.record(z.string(), colorWeightOverrideSchema).describe("An object with color names as keys");
|
|
399
|
+
var overridesSchema = z.object({
|
|
400
|
+
colors: semanticColorOverrideSchema.optional()
|
|
401
|
+
}).describe("Overrides for generated design tokens. Currently only supports colors defined in your theme").optional();
|
|
392
402
|
var themeSchema = z.object({
|
|
393
403
|
colors: z.object({
|
|
394
404
|
main: colorCategorySchema,
|
|
@@ -398,7 +408,8 @@ var themeSchema = z.object({
|
|
|
398
408
|
typography: z.object({
|
|
399
409
|
fontFamily: z.string().meta({ description: "Sets the font-family for this theme" })
|
|
400
410
|
}).describe("Defines the typography for a given theme").optional(),
|
|
401
|
-
borderRadius: z.number().meta({ description: "Defines the border-radius for this theme" }).optional()
|
|
411
|
+
borderRadius: z.number().meta({ description: "Defines the border-radius for this theme" }).optional(),
|
|
412
|
+
overrides: overridesSchema
|
|
402
413
|
}).meta({ description: "An object defining a theme. The property name holding the object becomes the theme name." });
|
|
403
414
|
var commonConfig = z.object({
|
|
404
415
|
clean: z.boolean().meta({ description: "Delete the output directory before building or creating tokens" }).optional()
|
|
@@ -468,8 +479,8 @@ async function parseCreateConfig(configFile, options) {
|
|
|
468
479
|
console.error(pc3.redBright(`In config, all themes must have the same custom color names, but we found:`));
|
|
469
480
|
const themeNames = R8.keys(configParsed.themes ?? {});
|
|
470
481
|
themeColors.forEach((colors, index) => {
|
|
471
|
-
const
|
|
472
|
-
console.log(` - ${themeNames[index]}: ${
|
|
482
|
+
const colorNames2 = Array.from(colors);
|
|
483
|
+
console.log(` - ${themeNames[index]}: ${colorNames2.join(", ")}`);
|
|
473
484
|
});
|
|
474
485
|
console.log();
|
|
475
486
|
process.exit(1);
|
|
@@ -257,6 +257,7 @@ var colorMetadata = {
|
|
|
257
257
|
}
|
|
258
258
|
};
|
|
259
259
|
var colorMetadataByNumber = R.indexBy((metadata) => metadata.number, Object.values(colorMetadata));
|
|
260
|
+
var colorNames = Object.keys(colorMetadata);
|
|
260
261
|
|
|
261
262
|
// src/colors/theme.ts
|
|
262
263
|
import chroma2 from "chroma-js";
|
|
@@ -378,7 +379,7 @@ var cssClassRename = (dictionary) => ({
|
|
|
378
379
|
var cssVarRename = (dictionary) => ({
|
|
379
380
|
postcssPlugin: `Replaces CSS variables ${hash(dictionary)}`,
|
|
380
381
|
Declaration(decl) {
|
|
381
|
-
const { value, prop:
|
|
382
|
+
const { value, prop: prop4 } = decl;
|
|
382
383
|
const deleted = /* @__PURE__ */ new Set();
|
|
383
384
|
for (const [from, to] of Object.entries(dictionary)) {
|
|
384
385
|
if (R3.isNotEmpty(to)) {
|
|
@@ -389,8 +390,8 @@ var cssVarRename = (dictionary) => ({
|
|
|
389
390
|
decl.value = value.replace(from, to);
|
|
390
391
|
continue;
|
|
391
392
|
}
|
|
392
|
-
if (R3.includes(from,
|
|
393
|
-
decl.prop =
|
|
393
|
+
if (R3.includes(from, prop4) && decl.variable) {
|
|
394
|
+
decl.prop = prop4.replace(from, to);
|
|
394
395
|
}
|
|
395
396
|
}
|
|
396
397
|
}
|
|
@@ -870,11 +871,11 @@ import pc5 from "picocolors";
|
|
|
870
871
|
// package.json
|
|
871
872
|
var package_default = {
|
|
872
873
|
name: "@digdir/designsystemet",
|
|
873
|
-
version: "1.
|
|
874
|
+
version: "1.6.0",
|
|
874
875
|
description: "CLI for Designsystemet",
|
|
875
876
|
author: "Designsystemet team",
|
|
876
877
|
engines: {
|
|
877
|
-
node: ">=
|
|
878
|
+
node: ">=20 <25"
|
|
878
879
|
},
|
|
879
880
|
repository: {
|
|
880
881
|
type: "git",
|
|
@@ -922,7 +923,7 @@ var package_default = {
|
|
|
922
923
|
"test:tokens-build-config-tailwind": "pnpm run designsystemet tokens build -t ./temp/config/design-tokens -o ./temp/config/build --clean --experimental-tailwind",
|
|
923
924
|
"test:tokens-create-and-build-options": "pnpm test:tokens-create-options && pnpm test:tokens-build",
|
|
924
925
|
"test:tokens-create-and-build-config": "pnpm test:tokens-create-config && pnpm test:tokens-build-config",
|
|
925
|
-
test: "pnpm test:tokens-create-and-build-options && pnpm test:tokens-create-and-build-config",
|
|
926
|
+
test: "node -v && pnpm test:tokens-create-and-build-options && pnpm test:tokens-create-and-build-config",
|
|
926
927
|
"digdir:tokens-build": "pnpm run designsystemet tokens build -t ../../internal/design-tokens -o ../../packages/theme/brand --clean --experimental-tailwind",
|
|
927
928
|
"digdir:tokens-create": "pnpm run designsystemet tokens create --config ./configs/digdir.config.json",
|
|
928
929
|
"update:template": "tsx ./src/scripts/update-template.ts",
|
|
@@ -937,7 +938,7 @@ var package_default = {
|
|
|
937
938
|
"change-case": "^5.4.4",
|
|
938
939
|
"chroma-js": "^3.1.2",
|
|
939
940
|
"colorjs.io": "^0.6.0-alpha.1",
|
|
940
|
-
commander: "^14.0.
|
|
941
|
+
commander: "^14.0.1",
|
|
941
942
|
"fast-glob": "^3.3.3",
|
|
942
943
|
hsluv: "^1.0.1",
|
|
943
944
|
"object-hash": "^3.0.0",
|
|
@@ -945,18 +946,18 @@ var package_default = {
|
|
|
945
946
|
postcss: "^8.5.6",
|
|
946
947
|
ramda: "^0.31.3",
|
|
947
948
|
"style-dictionary": "^5.0.4",
|
|
948
|
-
zod: "^4.1.
|
|
949
|
-
"zod-validation-error": "^4.0.
|
|
949
|
+
zod: "^4.1.11",
|
|
950
|
+
"zod-validation-error": "^4.0.2"
|
|
950
951
|
},
|
|
951
952
|
devDependencies: {
|
|
952
953
|
"@tokens-studio/types": "0.5.2",
|
|
953
954
|
"@types/apca-w3": "^0.1.3",
|
|
954
955
|
"@types/chroma-js": "^3.1.1",
|
|
955
956
|
"@types/fs-extra": "^11.0.4",
|
|
956
|
-
"@types/node": "^22.18.
|
|
957
|
+
"@types/node": "^22.18.6",
|
|
957
958
|
"@types/object-hash": "^3.0.6",
|
|
958
|
-
"@types/ramda": "^0.31.
|
|
959
|
-
"fs-extra": "^11.3.
|
|
959
|
+
"@types/ramda": "^0.31.1",
|
|
960
|
+
"fs-extra": "^11.3.2",
|
|
960
961
|
tslib: "^2.8.1",
|
|
961
962
|
tsup: "^8.5.0",
|
|
962
963
|
tsx: "^4.20.5",
|
|
@@ -1027,11 +1028,11 @@ function isColorCategoryToken(token, category) {
|
|
|
1027
1028
|
var isDigit = (s) => /^\d+$/.test(s);
|
|
1028
1029
|
function traverseObj(obj, fn) {
|
|
1029
1030
|
for (const key in obj) {
|
|
1030
|
-
const
|
|
1031
|
-
if (
|
|
1032
|
-
fn.apply(null, [obj, key,
|
|
1033
|
-
if (typeof
|
|
1034
|
-
traverseObj(
|
|
1031
|
+
const prop4 = obj[key];
|
|
1032
|
+
if (prop4 != null) {
|
|
1033
|
+
fn.apply(null, [obj, key, prop4]);
|
|
1034
|
+
if (typeof prop4 === "object") {
|
|
1035
|
+
traverseObj(prop4, fn);
|
|
1035
1036
|
}
|
|
1036
1037
|
}
|
|
1037
1038
|
}
|
|
@@ -1470,13 +1471,33 @@ ${content}
|
|
|
1470
1471
|
// src/tokens/process/formats/css/type-scale.ts
|
|
1471
1472
|
import * as R12 from "ramda";
|
|
1472
1473
|
import { createPropertyFormatter as createPropertyFormatter6 } from "style-dictionary/utils";
|
|
1473
|
-
var
|
|
1474
|
+
var isTypographyFontFamilyToken = R12.allPass([
|
|
1474
1475
|
R12.pathSatisfies(R12.includes("typography"), ["path"]),
|
|
1475
1476
|
R12.pathSatisfies(R12.includes("fontFamily"), ["path"])
|
|
1476
1477
|
]);
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1478
|
+
var formatTypographySizeToken = (format, token) => {
|
|
1479
|
+
const [name, value] = format(token).replace(/;$/, "").split(": ");
|
|
1480
|
+
let calc;
|
|
1481
|
+
let round;
|
|
1482
|
+
if (R12.startsWith(["font-size"], token.path)) {
|
|
1483
|
+
calc = `calc(${value} * var(--_ds-font-size-factor))`;
|
|
1484
|
+
round = `round(${calc}, 1px)`;
|
|
1485
|
+
} else {
|
|
1486
|
+
calc = value;
|
|
1487
|
+
}
|
|
1488
|
+
return { name, calc, round: round ?? calc };
|
|
1489
|
+
};
|
|
1490
|
+
var formatTypographySizeTokens = (format, tokens) => R12.reduce(
|
|
1491
|
+
(acc, token) => {
|
|
1492
|
+
const { name, calc, round } = formatTypographySizeToken(format, token);
|
|
1493
|
+
acc.tokens.push(token);
|
|
1494
|
+
acc.calc.push(`${name}: ${calc};`);
|
|
1495
|
+
acc.round.push(`${name}: ${round};`);
|
|
1496
|
+
return acc;
|
|
1497
|
+
},
|
|
1498
|
+
{ tokens: [], calc: [], round: [] },
|
|
1499
|
+
tokens
|
|
1500
|
+
);
|
|
1480
1501
|
var typeScale = {
|
|
1481
1502
|
name: "ds/css-type-scale",
|
|
1482
1503
|
format: async ({ dictionary, file, options, platform }) => {
|
|
@@ -1489,18 +1510,16 @@ var typeScale = {
|
|
|
1489
1510
|
format: "css",
|
|
1490
1511
|
usesDtcg
|
|
1491
1512
|
});
|
|
1492
|
-
const filteredTokens = R12.reject(
|
|
1493
|
-
const
|
|
1494
|
-
const formattedMap =
|
|
1495
|
-
token,
|
|
1496
|
-
formatted:
|
|
1513
|
+
const filteredTokens = R12.reject(R12.anyPass([isTypographyFontFamilyToken]), dictionary.allTokens);
|
|
1514
|
+
const formattedTokens = formatTypographySizeTokens(format, filteredTokens);
|
|
1515
|
+
const formattedMap = formattedTokens.round.map((t, i) => ({
|
|
1516
|
+
token: formattedTokens.tokens[i],
|
|
1517
|
+
formatted: t
|
|
1497
1518
|
}));
|
|
1498
1519
|
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
1499
|
-
const formattedTokens = formattedMap.map(R12.prop("formatted")).join("\n");
|
|
1500
1520
|
const sizeFactor = ` --_ds-font-size-factor: calc(var(--ds-size-mode-font-size) / (var(--ds-size-base) / ${basePxFontSize}));`;
|
|
1501
1521
|
const content = `${selector} {
|
|
1502
|
-
${sizeFactor}
|
|
1503
|
-
${formattedTokens}
|
|
1522
|
+
${sizeFactor}${sizingTemplate(formattedTokens)}
|
|
1504
1523
|
}`;
|
|
1505
1524
|
const body = R12.isNotNil(layer) ? `@layer ${layer} {
|
|
1506
1525
|
${content}
|
|
@@ -1713,7 +1732,7 @@ var sizeModeVariables = ({ theme, size: size2 }) => {
|
|
|
1713
1732
|
};
|
|
1714
1733
|
|
|
1715
1734
|
// src/tokens/process/configs/type-scale.ts
|
|
1716
|
-
var typeScaleVariables = ({ theme
|
|
1735
|
+
var typeScaleVariables = ({ theme }) => {
|
|
1717
1736
|
const selector = ":root, [data-size]";
|
|
1718
1737
|
const layer = `ds.theme.type-scale`;
|
|
1719
1738
|
return {
|
|
@@ -3805,18 +3824,51 @@ var getDefaultToken = (tokenPath) => {
|
|
|
3805
3824
|
|
|
3806
3825
|
// src/tokens/create/generators/color.ts
|
|
3807
3826
|
import * as R24 from "ramda";
|
|
3808
|
-
var generateColor = (colorArray) => {
|
|
3827
|
+
var generateColor = (colorArray, overrides) => {
|
|
3809
3828
|
const obj = {};
|
|
3810
3829
|
const $type = "color";
|
|
3811
3830
|
for (const index in colorArray) {
|
|
3812
|
-
|
|
3831
|
+
const position = Number(index) + 1;
|
|
3832
|
+
const overrideValue = overrides?.[position];
|
|
3833
|
+
obj[position] = {
|
|
3834
|
+
$type,
|
|
3835
|
+
$value: overrideValue || colorArray[index].hex
|
|
3836
|
+
};
|
|
3813
3837
|
}
|
|
3814
3838
|
return obj;
|
|
3815
3839
|
};
|
|
3816
|
-
var generateColorScheme = (themeName, colorScheme2, colors2) => {
|
|
3817
|
-
const
|
|
3818
|
-
|
|
3819
|
-
|
|
3840
|
+
var generateColorScheme = (themeName, colorScheme2, colors2, overrides) => {
|
|
3841
|
+
const createColorOverrides = (colorName) => {
|
|
3842
|
+
if (!overrides?.colors || !(colorName in overrides.colors)) {
|
|
3843
|
+
return void 0;
|
|
3844
|
+
}
|
|
3845
|
+
const colorOverrides = overrides.colors[colorName];
|
|
3846
|
+
const positionOverrides = {};
|
|
3847
|
+
Object.entries(colorOverrides).forEach(([semanticTokenName, modeOverrides]) => {
|
|
3848
|
+
const position = colorMetadata[semanticTokenName].number;
|
|
3849
|
+
if (position) {
|
|
3850
|
+
let overrideValue;
|
|
3851
|
+
if (colorScheme2 === "light" && modeOverrides.light) {
|
|
3852
|
+
overrideValue = modeOverrides.light;
|
|
3853
|
+
} else if (colorScheme2 === "dark" && modeOverrides.dark) {
|
|
3854
|
+
overrideValue = modeOverrides.dark;
|
|
3855
|
+
}
|
|
3856
|
+
if (overrideValue) {
|
|
3857
|
+
positionOverrides[position] = overrideValue;
|
|
3858
|
+
}
|
|
3859
|
+
}
|
|
3860
|
+
});
|
|
3861
|
+
return Object.keys(positionOverrides).length > 0 ? positionOverrides : void 0;
|
|
3862
|
+
};
|
|
3863
|
+
const main = R24.mapObjIndexed(
|
|
3864
|
+
(color, colorName) => generateColor(generateColorScale(color, colorScheme2), createColorOverrides(colorName)),
|
|
3865
|
+
colors2.main
|
|
3866
|
+
);
|
|
3867
|
+
const support = R24.mapObjIndexed(
|
|
3868
|
+
(color, colorName) => generateColor(generateColorScale(color, colorScheme2), createColorOverrides(colorName)),
|
|
3869
|
+
colors2.support
|
|
3870
|
+
);
|
|
3871
|
+
const neutral = generateColor(generateColorScale(colors2.neutral, colorScheme2), createColorOverrides("neutral"));
|
|
3820
3872
|
return {
|
|
3821
3873
|
[themeName]: {
|
|
3822
3874
|
...main,
|
|
@@ -4281,8 +4333,8 @@ var generateSemantic = (colors2) => {
|
|
|
4281
4333
|
["main-color", mainColorNames],
|
|
4282
4334
|
["support-color", supportColorNames]
|
|
4283
4335
|
];
|
|
4284
|
-
for (const [colorCategory2,
|
|
4285
|
-
for (const colorName of
|
|
4336
|
+
for (const [colorCategory2, colorNames2] of categories) {
|
|
4337
|
+
for (const colorName of colorNames2) {
|
|
4286
4338
|
const category = colorCategory2.replace("-color", "");
|
|
4287
4339
|
const customColorTokens = {
|
|
4288
4340
|
color: {
|
|
@@ -4538,7 +4590,7 @@ var cliOptions = {
|
|
|
4538
4590
|
}
|
|
4539
4591
|
};
|
|
4540
4592
|
var createTokens = async (opts) => {
|
|
4541
|
-
const { colors: colors2, typography: typography2, name, borderRadius } = opts;
|
|
4593
|
+
const { colors: colors2, typography: typography2, name, borderRadius, overrides } = opts;
|
|
4542
4594
|
const colorSchemes = ["light", "dark"];
|
|
4543
4595
|
const semantic2 = generateSemantic(colors2);
|
|
4544
4596
|
const tokenSets = new Map([
|
|
@@ -4556,7 +4608,7 @@ var createTokens = async (opts) => {
|
|
|
4556
4608
|
[`primitives/modes/typography/secondary/${name}`, generateTypography(name, typography2)],
|
|
4557
4609
|
...colorSchemes.flatMap((scheme) => [
|
|
4558
4610
|
[`primitives/modes/color-scheme/${scheme}/global`, generateColorGlobal(scheme)],
|
|
4559
|
-
[`primitives/modes/color-scheme/${scheme}/${name}`, generateColorScheme(name, scheme, colors2)]
|
|
4611
|
+
[`primitives/modes/color-scheme/${scheme}/${name}`, generateColorScheme(name, scheme, colors2, overrides)]
|
|
4560
4612
|
]),
|
|
4561
4613
|
[`themes/${name}`, generateTheme(colors2, name, borderRadius)],
|
|
4562
4614
|
["semantic/color", semantic2.color],
|
|
@@ -4650,6 +4702,15 @@ var colorCategorySchema = z.record(
|
|
|
4650
4702
|
).refine((colors2) => !Object.keys(colors2).some((key) => RESERVED_COLORS.includes(key.toLowerCase())), {
|
|
4651
4703
|
error: `Color names cannot include reserved names: ${RESERVED_COLORS.join(", ")}`
|
|
4652
4704
|
}).describe("An object with one or more color definitions. The property name is used as the color name.");
|
|
4705
|
+
var colorModeOverrideSchema = z.object({
|
|
4706
|
+
light: colorSchema.optional(),
|
|
4707
|
+
dark: colorSchema.optional()
|
|
4708
|
+
}).describe('Override values for semantic color tokens like "background-subtle", "border-default", etc.');
|
|
4709
|
+
var colorWeightOverrideSchema = z.partialRecord(z.enum(colorNames), colorModeOverrideSchema).describe('The name of the color to add overrides for, e.g. "accent"');
|
|
4710
|
+
var semanticColorOverrideSchema = z.record(z.string(), colorWeightOverrideSchema).describe("An object with color names as keys");
|
|
4711
|
+
var overridesSchema = z.object({
|
|
4712
|
+
colors: semanticColorOverrideSchema.optional()
|
|
4713
|
+
}).describe("Overrides for generated design tokens. Currently only supports colors defined in your theme").optional();
|
|
4653
4714
|
var themeSchema = z.object({
|
|
4654
4715
|
colors: z.object({
|
|
4655
4716
|
main: colorCategorySchema,
|
|
@@ -4659,7 +4720,8 @@ var themeSchema = z.object({
|
|
|
4659
4720
|
typography: z.object({
|
|
4660
4721
|
fontFamily: z.string().meta({ description: "Sets the font-family for this theme" })
|
|
4661
4722
|
}).describe("Defines the typography for a given theme").optional(),
|
|
4662
|
-
borderRadius: z.number().meta({ description: "Defines the border-radius for this theme" }).optional()
|
|
4723
|
+
borderRadius: z.number().meta({ description: "Defines the border-radius for this theme" }).optional(),
|
|
4724
|
+
overrides: overridesSchema
|
|
4663
4725
|
}).meta({ description: "An object defining a theme. The property name holding the object becomes the theme name." });
|
|
4664
4726
|
var commonConfig = z.object({
|
|
4665
4727
|
clean: z.boolean().meta({ description: "Delete the output directory before building or creating tokens" }).optional()
|
|
@@ -4711,8 +4773,8 @@ async function parseCreateConfig(configFile, options) {
|
|
|
4711
4773
|
console.error(pc10.redBright(`In config, all themes must have the same custom color names, but we found:`));
|
|
4712
4774
|
const themeNames = R28.keys(configParsed.themes ?? {});
|
|
4713
4775
|
themeColors.forEach((colors2, index) => {
|
|
4714
|
-
const
|
|
4715
|
-
console.log(` - ${themeNames[index]}: ${
|
|
4776
|
+
const colorNames2 = Array.from(colors2);
|
|
4777
|
+
console.log(` - ${themeNames[index]}: ${colorNames2.join(", ")}`);
|
|
4716
4778
|
});
|
|
4717
4779
|
console.log();
|
|
4718
4780
|
process.exit(1);
|
package/dist/config.schema.json
CHANGED
|
@@ -74,6 +74,58 @@
|
|
|
74
74
|
"borderRadius": {
|
|
75
75
|
"description": "Defines the border-radius for this theme",
|
|
76
76
|
"type": "number"
|
|
77
|
+
},
|
|
78
|
+
"overrides": {
|
|
79
|
+
"description": "Overrides for generated design tokens. Currently only supports colors defined in your theme",
|
|
80
|
+
"type": "object",
|
|
81
|
+
"properties": {
|
|
82
|
+
"colors": {
|
|
83
|
+
"description": "An object with color names as keys",
|
|
84
|
+
"type": "object",
|
|
85
|
+
"propertyNames": {
|
|
86
|
+
"type": "string"
|
|
87
|
+
},
|
|
88
|
+
"additionalProperties": {
|
|
89
|
+
"description": "The name of the color to add overrides for, e.g. \"accent\"",
|
|
90
|
+
"type": "object",
|
|
91
|
+
"propertyNames": {
|
|
92
|
+
"type": "string",
|
|
93
|
+
"enum": [
|
|
94
|
+
"background-default",
|
|
95
|
+
"background-tinted",
|
|
96
|
+
"surface-default",
|
|
97
|
+
"surface-tinted",
|
|
98
|
+
"surface-hover",
|
|
99
|
+
"surface-active",
|
|
100
|
+
"border-subtle",
|
|
101
|
+
"border-default",
|
|
102
|
+
"border-strong",
|
|
103
|
+
"text-subtle",
|
|
104
|
+
"text-default",
|
|
105
|
+
"base-default",
|
|
106
|
+
"base-hover",
|
|
107
|
+
"base-active",
|
|
108
|
+
"base-contrast-subtle",
|
|
109
|
+
"base-contrast-default"
|
|
110
|
+
]
|
|
111
|
+
},
|
|
112
|
+
"additionalProperties": {
|
|
113
|
+
"description": "Override values for semantic color tokens like \"background-subtle\", \"border-default\", etc.",
|
|
114
|
+
"type": "object",
|
|
115
|
+
"properties": {
|
|
116
|
+
"light": {
|
|
117
|
+
"description": "A hex color, which is used for creating a color scale. Invalid color names: neutral, success, warning, danger, info, blue, green, orange, purple, red"
|
|
118
|
+
},
|
|
119
|
+
"dark": {
|
|
120
|
+
"description": "A hex color, which is used for creating a color scale. Invalid color names: neutral, success, warning, danger, info, blue, green, orange, purple, red"
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
"additionalProperties": false
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
"additionalProperties": false
|
|
77
129
|
}
|
|
78
130
|
},
|
|
79
131
|
"required": [
|
|
@@ -50,4 +50,5 @@ export declare const getColorMetadataByNumber: (number: ColorNumber) => ({
|
|
|
50
50
|
name: "base-contrast-default";
|
|
51
51
|
number: 16;
|
|
52
52
|
} & import("./types.js").ColorMetadata);
|
|
53
|
+
export declare const colorNames: Array<keyof typeof colorMetadata>;
|
|
53
54
|
//# sourceMappingURL=colorMetadata.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"colorMetadata.d.ts","sourceRoot":"","sources":["../../../src/colors/colorMetadata.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE3F,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,YAAY,EAAE,QAAQ,CAMrD,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,mBAiP3B,CAAC;AAIF,eAAO,MAAM,wBAAwB,GAAI,QAAQ,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uCAE3D,CAAC"}
|
|
1
|
+
{"version":3,"file":"colorMetadata.d.ts","sourceRoot":"","sources":["../../../src/colors/colorMetadata.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE3F,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,YAAY,EAAE,QAAQ,CAMrD,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,mBAiP3B,CAAC;AAIF,eAAO,MAAM,wBAAwB,GAAI,QAAQ,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uCAE3D,CAAC;AAEF,eAAO,MAAM,UAAU,EAAiC,KAAK,CAAC,MAAM,OAAO,aAAa,CAAC,CAAC"}
|
|
@@ -253,8 +253,10 @@ var colorMetadataByNumber = R.indexBy((metadata) => metadata.number, Object.valu
|
|
|
253
253
|
var getColorMetadataByNumber = (number) => {
|
|
254
254
|
return colorMetadataByNumber[number];
|
|
255
255
|
};
|
|
256
|
+
var colorNames = Object.keys(colorMetadata);
|
|
256
257
|
export {
|
|
257
258
|
baseColors,
|
|
258
259
|
colorMetadata,
|
|
260
|
+
colorNames,
|
|
259
261
|
getColorMetadataByNumber
|
|
260
262
|
};
|
package/dist/src/colors/index.js
CHANGED
|
@@ -253,6 +253,7 @@ var colorMetadataByNumber = R.indexBy((metadata) => metadata.number, Object.valu
|
|
|
253
253
|
var getColorMetadataByNumber = (number) => {
|
|
254
254
|
return colorMetadataByNumber[number];
|
|
255
255
|
};
|
|
256
|
+
var colorNames = Object.keys(colorMetadata);
|
|
256
257
|
|
|
257
258
|
// src/colors/theme.ts
|
|
258
259
|
import chroma2 from "chroma-js";
|
|
@@ -480,6 +481,7 @@ export {
|
|
|
480
481
|
baseColors,
|
|
481
482
|
canTextBeUsedOnColors,
|
|
482
483
|
colorMetadata,
|
|
484
|
+
colorNames,
|
|
483
485
|
convertColor,
|
|
484
486
|
convertToHex,
|
|
485
487
|
generateColorContrast,
|
package/dist/src/colors/theme.js
CHANGED
|
@@ -250,6 +250,7 @@ var colorMetadataByNumber = R.indexBy((metadata) => metadata.number, Object.valu
|
|
|
250
250
|
var getColorMetadataByNumber = (number) => {
|
|
251
251
|
return colorMetadataByNumber[number];
|
|
252
252
|
};
|
|
253
|
+
var colorNames = Object.keys(colorMetadata);
|
|
253
254
|
|
|
254
255
|
// src/colors/utils.ts
|
|
255
256
|
import chroma from "chroma-js";
|
package/dist/src/config.d.ts
CHANGED
|
@@ -11,6 +11,29 @@ import { z } from 'zod';
|
|
|
11
11
|
export declare function validateConfig<T>(schema: z.ZodType<T>, unvalidatedConfig: Record<string, unknown>, configPath: string): T;
|
|
12
12
|
export declare function parseConfig<T>(configFile: string, configPath: string): T;
|
|
13
13
|
export declare const colorRegex: RegExp;
|
|
14
|
+
declare const overridesSchema: z.ZodOptional<z.ZodObject<{
|
|
15
|
+
colors: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodEnum<{
|
|
16
|
+
"background-default": "background-default";
|
|
17
|
+
"background-tinted": "background-tinted";
|
|
18
|
+
"surface-default": "surface-default";
|
|
19
|
+
"surface-tinted": "surface-tinted";
|
|
20
|
+
"surface-hover": "surface-hover";
|
|
21
|
+
"surface-active": "surface-active";
|
|
22
|
+
"border-subtle": "border-subtle";
|
|
23
|
+
"border-default": "border-default";
|
|
24
|
+
"border-strong": "border-strong";
|
|
25
|
+
"text-subtle": "text-subtle";
|
|
26
|
+
"text-default": "text-default";
|
|
27
|
+
"base-default": "base-default";
|
|
28
|
+
"base-hover": "base-hover";
|
|
29
|
+
"base-active": "base-active";
|
|
30
|
+
"base-contrast-subtle": "base-contrast-subtle";
|
|
31
|
+
"base-contrast-default": "base-contrast-default";
|
|
32
|
+
}> & z.core.$partial, z.ZodObject<{
|
|
33
|
+
light: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`#${string}`, string>>>;
|
|
34
|
+
dark: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`#${string}`, string>>>;
|
|
35
|
+
}, z.core.$strip>>>>;
|
|
36
|
+
}, z.core.$strip>>;
|
|
14
37
|
declare const themeSchema: z.ZodObject<{
|
|
15
38
|
colors: z.ZodObject<{
|
|
16
39
|
main: z.ZodRecord<z.ZodString, z.ZodPipe<z.ZodString, z.ZodTransform<`#${string}`, string>>>;
|
|
@@ -21,6 +44,29 @@ declare const themeSchema: z.ZodObject<{
|
|
|
21
44
|
fontFamily: z.ZodString;
|
|
22
45
|
}, z.core.$strip>>;
|
|
23
46
|
borderRadius: z.ZodOptional<z.ZodNumber>;
|
|
47
|
+
overrides: z.ZodOptional<z.ZodObject<{
|
|
48
|
+
colors: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodEnum<{
|
|
49
|
+
"background-default": "background-default";
|
|
50
|
+
"background-tinted": "background-tinted";
|
|
51
|
+
"surface-default": "surface-default";
|
|
52
|
+
"surface-tinted": "surface-tinted";
|
|
53
|
+
"surface-hover": "surface-hover";
|
|
54
|
+
"surface-active": "surface-active";
|
|
55
|
+
"border-subtle": "border-subtle";
|
|
56
|
+
"border-default": "border-default";
|
|
57
|
+
"border-strong": "border-strong";
|
|
58
|
+
"text-subtle": "text-subtle";
|
|
59
|
+
"text-default": "text-default";
|
|
60
|
+
"base-default": "base-default";
|
|
61
|
+
"base-hover": "base-hover";
|
|
62
|
+
"base-active": "base-active";
|
|
63
|
+
"base-contrast-subtle": "base-contrast-subtle";
|
|
64
|
+
"base-contrast-default": "base-contrast-default";
|
|
65
|
+
}> & z.core.$partial, z.ZodObject<{
|
|
66
|
+
light: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`#${string}`, string>>>;
|
|
67
|
+
dark: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`#${string}`, string>>>;
|
|
68
|
+
}, z.core.$strip>>>>;
|
|
69
|
+
}, z.core.$strip>>;
|
|
24
70
|
}, z.core.$strip>;
|
|
25
71
|
export declare const commonConfig: z.ZodObject<{
|
|
26
72
|
clean: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -40,6 +86,29 @@ export declare const configFileCreateSchema: z.ZodObject<{
|
|
|
40
86
|
fontFamily: z.ZodString;
|
|
41
87
|
}, z.core.$strip>>;
|
|
42
88
|
borderRadius: z.ZodOptional<z.ZodNumber>;
|
|
89
|
+
overrides: z.ZodOptional<z.ZodObject<{
|
|
90
|
+
colors: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodRecord<z.ZodEnum<{
|
|
91
|
+
"background-default": "background-default";
|
|
92
|
+
"background-tinted": "background-tinted";
|
|
93
|
+
"surface-default": "surface-default";
|
|
94
|
+
"surface-tinted": "surface-tinted";
|
|
95
|
+
"surface-hover": "surface-hover";
|
|
96
|
+
"surface-active": "surface-active";
|
|
97
|
+
"border-subtle": "border-subtle";
|
|
98
|
+
"border-default": "border-default";
|
|
99
|
+
"border-strong": "border-strong";
|
|
100
|
+
"text-subtle": "text-subtle";
|
|
101
|
+
"text-default": "text-default";
|
|
102
|
+
"base-default": "base-default";
|
|
103
|
+
"base-hover": "base-hover";
|
|
104
|
+
"base-active": "base-active";
|
|
105
|
+
"base-contrast-subtle": "base-contrast-subtle";
|
|
106
|
+
"base-contrast-default": "base-contrast-default";
|
|
107
|
+
}> & z.core.$partial, z.ZodObject<{
|
|
108
|
+
light: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`#${string}`, string>>>;
|
|
109
|
+
dark: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<`#${string}`, string>>>;
|
|
110
|
+
}, z.core.$strip>>>>;
|
|
111
|
+
}, z.core.$strip>>;
|
|
43
112
|
}, z.core.$strip>>>;
|
|
44
113
|
clean: z.ZodOptional<z.ZodBoolean>;
|
|
45
114
|
}, z.core.$strip>;
|
|
@@ -47,5 +116,6 @@ export type CommonConfigSchema = z.infer<typeof commonConfig>;
|
|
|
47
116
|
export type BuildConfigSchema = z.infer<typeof commonConfig>;
|
|
48
117
|
export type CreateConfigSchema = z.infer<typeof configFileCreateSchema>;
|
|
49
118
|
export type ConfigSchemaTheme = z.infer<typeof themeSchema>;
|
|
119
|
+
export type ColorOverrideSchema = z.infer<typeof overridesSchema>;
|
|
50
120
|
export {};
|
|
51
121
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/src/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAuCxB;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAC9B,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EACpB,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC1C,UAAU,EAAE,MAAM,GACjB,CAAC,CAUH;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,CAAC,CAexE;AAWD,eAAO,MAAM,UAAU,QAA2C,CAAC;AAwCnE,QAAA,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;kBAKR,CAAC;AAEd,QAAA,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAkBmG,CAAC;AAErH,eAAO,MAAM,YAAY;;iBAEvB,CAAC;AAYH;;GAEG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAAqD,CAAC;AACzF,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAC9D,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAC7D,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AACxE,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAC5D,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAC"}
|
package/dist/src/config.js
CHANGED
|
@@ -249,6 +249,7 @@ var colorMetadata = {
|
|
|
249
249
|
}
|
|
250
250
|
};
|
|
251
251
|
var colorMetadataByNumber = R.indexBy((metadata) => metadata.number, Object.values(colorMetadata));
|
|
252
|
+
var colorNames = Object.keys(colorMetadata);
|
|
252
253
|
|
|
253
254
|
// src/colors/theme.ts
|
|
254
255
|
import chroma2 from "chroma-js";
|
|
@@ -384,6 +385,15 @@ var colorCategorySchema = z.record(
|
|
|
384
385
|
).refine((colors) => !Object.keys(colors).some((key) => RESERVED_COLORS.includes(key.toLowerCase())), {
|
|
385
386
|
error: `Color names cannot include reserved names: ${RESERVED_COLORS.join(", ")}`
|
|
386
387
|
}).describe("An object with one or more color definitions. The property name is used as the color name.");
|
|
388
|
+
var colorModeOverrideSchema = z.object({
|
|
389
|
+
light: colorSchema.optional(),
|
|
390
|
+
dark: colorSchema.optional()
|
|
391
|
+
}).describe('Override values for semantic color tokens like "background-subtle", "border-default", etc.');
|
|
392
|
+
var colorWeightOverrideSchema = z.partialRecord(z.enum(colorNames), colorModeOverrideSchema).describe('The name of the color to add overrides for, e.g. "accent"');
|
|
393
|
+
var semanticColorOverrideSchema = z.record(z.string(), colorWeightOverrideSchema).describe("An object with color names as keys");
|
|
394
|
+
var overridesSchema = z.object({
|
|
395
|
+
colors: semanticColorOverrideSchema.optional()
|
|
396
|
+
}).describe("Overrides for generated design tokens. Currently only supports colors defined in your theme").optional();
|
|
387
397
|
var themeSchema = z.object({
|
|
388
398
|
colors: z.object({
|
|
389
399
|
main: colorCategorySchema,
|
|
@@ -393,7 +403,8 @@ var themeSchema = z.object({
|
|
|
393
403
|
typography: z.object({
|
|
394
404
|
fontFamily: z.string().meta({ description: "Sets the font-family for this theme" })
|
|
395
405
|
}).describe("Defines the typography for a given theme").optional(),
|
|
396
|
-
borderRadius: z.number().meta({ description: "Defines the border-radius for this theme" }).optional()
|
|
406
|
+
borderRadius: z.number().meta({ description: "Defines the border-radius for this theme" }).optional(),
|
|
407
|
+
overrides: overridesSchema
|
|
397
408
|
}).meta({ description: "An object defining a theme. The property name holding the object becomes the theme name." });
|
|
398
409
|
var commonConfig = z.object({
|
|
399
410
|
clean: z.boolean().meta({ description: "Delete the output directory before building or creating tokens" }).optional()
|