@digdir/designsystemet 1.6.1 → 1.7.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/README.md +1 -1
- package/configs/test-tokens.config.json +9 -0
- package/dist/bin/config.js +12 -14
- package/dist/bin/designsystemet.d.ts +1 -1
- package/dist/bin/designsystemet.d.ts.map +1 -1
- package/dist/bin/designsystemet.js +60 -317
- package/dist/color.base.template-QGZJKXMN.json +22 -0
- package/dist/config.schema.json +23 -7
- package/dist/src/colors/colorMetadata.d.ts +2 -0
- package/dist/src/colors/colorMetadata.d.ts.map +1 -1
- package/dist/src/colors/colorMetadata.js +8 -5
- package/dist/src/colors/index.js +9 -17
- package/dist/src/colors/theme.d.ts.map +1 -1
- package/dist/src/colors/theme.js +14 -18
- package/dist/src/colors/types.d.ts +1 -1
- package/dist/src/colors/types.d.ts.map +1 -1
- package/dist/src/config.d.ts +18 -0
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +12 -14
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +211 -416
- package/dist/src/scripts/createJsonSchema.js +12 -14
- package/dist/src/scripts/update-preview-tokens.js +33 -294
- package/dist/src/scripts/update-template.d.ts.map +1 -1
- package/dist/src/scripts/update-template.js +349 -71
- package/dist/src/tokens/build.js +5 -5
- package/dist/src/tokens/create/generators/$designsystemet.js +5 -5
- package/dist/src/tokens/create/generators/$metadata.d.ts.map +1 -1
- package/dist/src/tokens/create/generators/$metadata.js +1 -4
- package/dist/src/tokens/create/generators/$themes.js +0 -1
- package/dist/src/tokens/create/generators/color.d.ts +0 -1
- package/dist/src/tokens/create/generators/color.d.ts.map +1 -1
- package/dist/src/tokens/create/generators/color.js +20 -23
- package/dist/src/tokens/create/generators/semantic.d.ts +1 -265
- package/dist/src/tokens/create/generators/semantic.d.ts.map +1 -1
- package/dist/src/tokens/create/generators/semantic.js +261 -270
- package/dist/src/tokens/create/generators/theme.d.ts.map +1 -1
- package/dist/src/tokens/create/generators/theme.js +265 -5
- package/dist/src/tokens/create/write.js +6 -10
- package/dist/src/tokens/create.d.ts.map +1 -1
- package/dist/src/tokens/create.js +33 -293
- package/dist/src/tokens/format.js +38 -299
- package/dist/src/tokens/index.js +38 -299
- package/dist/src/tokens/process/output/declarations.js +5 -5
- package/dist/src/tokens/process/output/theme.js +5 -5
- package/dist/src/tokens/template/design-tokens/semantic/color.base.template.js +1 -1
- package/package.json +5 -5
- package/dist/color.base.template-M7BHS4OV.json +0 -286
package/README.md
CHANGED
|
@@ -49,7 +49,7 @@ Whenever a new version of the CLI is released, or you have done changes, we reco
|
|
|
49
49
|
### Using a config file
|
|
50
50
|
|
|
51
51
|
> ⚠️ **WARNING** ⚠️
|
|
52
|
-
>
|
|
52
|
+
> The typography feature is experimental. The config schema may change at any time.
|
|
53
53
|
|
|
54
54
|
|
|
55
55
|
The `tokens create` command supports a config file. It will auto-detect a `designsystemet.config.json` file in the current directory. You can also use the `--config <path>` option to supply a different config name and location.
|
package/dist/bin/config.js
CHANGED
|
@@ -11,6 +11,12 @@ import { fromError } from "zod-validation-error";
|
|
|
11
11
|
|
|
12
12
|
// src/colors/colorMetadata.ts
|
|
13
13
|
import * as R from "ramda";
|
|
14
|
+
var baseColors = {
|
|
15
|
+
info: "#0A71C0",
|
|
16
|
+
success: "#068718",
|
|
17
|
+
warning: "#EA9B1B",
|
|
18
|
+
danger: "#C01B1B"
|
|
19
|
+
};
|
|
14
20
|
var colorMetadata = {
|
|
15
21
|
"background-default": {
|
|
16
22
|
number: 1,
|
|
@@ -255,6 +261,7 @@ var colorMetadata = {
|
|
|
255
261
|
};
|
|
256
262
|
var colorMetadataByNumber = R.indexBy((metadata) => metadata.number, Object.values(colorMetadata));
|
|
257
263
|
var colorNames = Object.keys(colorMetadata);
|
|
264
|
+
var baseColorNames = Object.keys(baseColors);
|
|
258
265
|
|
|
259
266
|
// src/colors/theme.ts
|
|
260
267
|
import chroma2 from "chroma-js";
|
|
@@ -275,18 +282,7 @@ var convertToHex = (color) => {
|
|
|
275
282
|
};
|
|
276
283
|
|
|
277
284
|
// src/colors/theme.ts
|
|
278
|
-
var RESERVED_COLORS = [
|
|
279
|
-
"neutral",
|
|
280
|
-
"success",
|
|
281
|
-
"warning",
|
|
282
|
-
"danger",
|
|
283
|
-
"info",
|
|
284
|
-
"blue",
|
|
285
|
-
"green",
|
|
286
|
-
"orange",
|
|
287
|
-
"purple",
|
|
288
|
-
"red"
|
|
289
|
-
];
|
|
285
|
+
var RESERVED_COLORS = ["neutral", "success", "warning", "danger", "info"];
|
|
290
286
|
|
|
291
287
|
// src/tokens/create/defaults.ts
|
|
292
288
|
import * as R3 from "ramda";
|
|
@@ -394,10 +390,12 @@ var colorModeOverrideSchema = z.object({
|
|
|
394
390
|
light: colorSchema.optional(),
|
|
395
391
|
dark: colorSchema.optional()
|
|
396
392
|
}).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"');
|
|
393
|
+
var colorWeightOverrideSchema = z.partialRecord(z.enum([...colorNames]), colorModeOverrideSchema).describe('The name of the color to add overrides for, e.g. "accent"');
|
|
398
394
|
var semanticColorOverrideSchema = z.record(z.string(), colorWeightOverrideSchema).describe("An object with color names as keys");
|
|
395
|
+
var severityColorOverrideSchema = z.partialRecord(z.enum(baseColorNames), colorSchema.describe("A hex color, which is used for creating a color scale")).optional().describe("An object with severity color names as keys");
|
|
399
396
|
var overridesSchema = z.object({
|
|
400
|
-
colors: semanticColorOverrideSchema.optional()
|
|
397
|
+
colors: semanticColorOverrideSchema.optional(),
|
|
398
|
+
severity: severityColorOverrideSchema.optional()
|
|
401
399
|
}).describe("Overrides for generated design tokens. Currently only supports colors defined in your theme").optional();
|
|
402
400
|
var themeSchema = z.object({
|
|
403
401
|
colors: z.object({
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
export
|
|
2
|
+
export declare const figletAscii = "\n _____ _ _ _\n| __ \\ (_) | | | |\n| | | | ___ ___ _ __ _ _ __ ___ _ _ ___| |_ ___ _ __ ___ ___| |_\n| | | |/ _ \\/ __| |/ _` | '_ \\/ __| | | / __| __/ _ \\ '_ ` _ \\ / _ \\ __|\n| |__| | __/\\__ \\ | (_| | | | \\__ \\ |_| \\__ \\ || __/ | | | | | __/ |_\n|_____/ \\___||___/_|\\__, |_| |_|___/\\__, |___/\\__\\___|_| |_| |_|\\___|\\__|\n __/ | __/ |\n |___/ |___/\n";
|
|
3
3
|
//# sourceMappingURL=designsystemet.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"designsystemet.d.ts","sourceRoot":"","sources":["../../bin/designsystemet.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"designsystemet.d.ts","sourceRoot":"","sources":["../../bin/designsystemet.ts"],"names":[],"mappings":";AAcA,eAAO,MAAM,WAAW,4iBASvB,CAAC"}
|
|
@@ -8,12 +8,12 @@ import * as R29 from "ramda";
|
|
|
8
8
|
// src/colors/colorMetadata.ts
|
|
9
9
|
import * as R from "ramda";
|
|
10
10
|
var baseColors = {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
red: "#C01B1B"
|
|
11
|
+
info: "#0A71C0",
|
|
12
|
+
success: "#068718",
|
|
13
|
+
warning: "#EA9B1B",
|
|
14
|
+
danger: "#C01B1B"
|
|
16
15
|
};
|
|
16
|
+
var dsLinkColor = "#663299";
|
|
17
17
|
var colorMetadata = {
|
|
18
18
|
"background-default": {
|
|
19
19
|
number: 1,
|
|
@@ -258,6 +258,7 @@ var colorMetadata = {
|
|
|
258
258
|
};
|
|
259
259
|
var colorMetadataByNumber = R.indexBy((metadata) => metadata.number, Object.values(colorMetadata));
|
|
260
260
|
var colorNames = Object.keys(colorMetadata);
|
|
261
|
+
var baseColorNames = Object.keys(baseColors);
|
|
261
262
|
|
|
262
263
|
// src/colors/theme.ts
|
|
263
264
|
import chroma2 from "chroma-js";
|
|
@@ -290,18 +291,7 @@ var convertToHex = (color) => {
|
|
|
290
291
|
};
|
|
291
292
|
|
|
292
293
|
// src/colors/theme.ts
|
|
293
|
-
var RESERVED_COLORS = [
|
|
294
|
-
"neutral",
|
|
295
|
-
"success",
|
|
296
|
-
"warning",
|
|
297
|
-
"danger",
|
|
298
|
-
"info",
|
|
299
|
-
"blue",
|
|
300
|
-
"green",
|
|
301
|
-
"orange",
|
|
302
|
-
"purple",
|
|
303
|
-
"red"
|
|
304
|
-
];
|
|
294
|
+
var RESERVED_COLORS = ["neutral", "success", "warning", "danger", "info"];
|
|
305
295
|
var generateColorScale = (color, colorScheme2) => {
|
|
306
296
|
let interpolationColor = color;
|
|
307
297
|
if (colorScheme2 === "dark") {
|
|
@@ -871,7 +861,7 @@ import pc5 from "picocolors";
|
|
|
871
861
|
// package.json
|
|
872
862
|
var package_default = {
|
|
873
863
|
name: "@digdir/designsystemet",
|
|
874
|
-
version: "1.
|
|
864
|
+
version: "1.7.1",
|
|
875
865
|
description: "CLI for Designsystemet",
|
|
876
866
|
author: "Designsystemet team",
|
|
877
867
|
engines: {
|
|
@@ -944,9 +934,9 @@ var package_default = {
|
|
|
944
934
|
"object-hash": "^3.0.0",
|
|
945
935
|
picocolors: "^1.1.1",
|
|
946
936
|
postcss: "^8.5.6",
|
|
947
|
-
ramda: "^0.
|
|
948
|
-
"style-dictionary": "^5.1.
|
|
949
|
-
zod: "^4.1.
|
|
937
|
+
ramda: "^0.32.0",
|
|
938
|
+
"style-dictionary": "^5.1.1",
|
|
939
|
+
zod: "^4.1.12",
|
|
950
940
|
"zod-validation-error": "^4.0.2"
|
|
951
941
|
},
|
|
952
942
|
devDependencies: {
|
|
@@ -954,7 +944,7 @@ var package_default = {
|
|
|
954
944
|
"@types/apca-w3": "^0.1.3",
|
|
955
945
|
"@types/chroma-js": "^3.1.1",
|
|
956
946
|
"@types/fs-extra": "^11.0.4",
|
|
957
|
-
"@types/node": "^22.18.
|
|
947
|
+
"@types/node": "^22.18.11",
|
|
958
948
|
"@types/object-hash": "^3.0.6",
|
|
959
949
|
"@types/ramda": "^0.31.1",
|
|
960
950
|
"fs-extra": "^11.3.2",
|
|
@@ -2599,10 +2589,7 @@ function generate$Metadata(schemes, themes, colors2) {
|
|
|
2599
2589
|
"primitives/modes/typography/size/large",
|
|
2600
2590
|
...themes.map((theme) => `primitives/modes/typography/primary/${theme}`),
|
|
2601
2591
|
...themes.map((theme) => `primitives/modes/typography/secondary/${theme}`),
|
|
2602
|
-
...schemes.flatMap((scheme) => [
|
|
2603
|
-
`primitives/modes/color-scheme/${scheme}/global`,
|
|
2604
|
-
...themes.map((theme) => `primitives/modes/color-scheme/${scheme}/${theme}`)
|
|
2605
|
-
]),
|
|
2592
|
+
...schemes.flatMap((scheme) => [...themes.map((theme) => `primitives/modes/color-scheme/${scheme}/${theme}`)]),
|
|
2606
2593
|
...themes.map((theme) => `themes/${theme}`),
|
|
2607
2594
|
"semantic/color",
|
|
2608
2595
|
...Object.entries(colors2.main).map(([color]) => `semantic/modes/main-color/${color}`),
|
|
@@ -2703,7 +2690,6 @@ function generateColorSchemesGroup(colorSchemes, themes) {
|
|
|
2703
2690
|
(scheme) => ({
|
|
2704
2691
|
...colorSchemeDefaults[scheme],
|
|
2705
2692
|
selectedTokenSets: Object.fromEntries([
|
|
2706
|
-
[`primitives/modes/color-scheme/${scheme}/global`, TokenSetStatus.ENABLED],
|
|
2707
2693
|
...themes.map((theme) => [`primitives/modes/color-scheme/${scheme}/${theme}`, TokenSetStatus.ENABLED])
|
|
2708
2694
|
]),
|
|
2709
2695
|
group: "Color scheme"
|
|
@@ -3869,27 +3855,24 @@ var generateColorScheme = (themeName, colorScheme2, colors2, overrides) => {
|
|
|
3869
3855
|
colors2.support
|
|
3870
3856
|
);
|
|
3871
3857
|
const neutral = generateColor(generateColorScale(colors2.neutral, colorScheme2), createColorOverrides("neutral"));
|
|
3858
|
+
const baseColorsWithOverrides = {
|
|
3859
|
+
...baseColors,
|
|
3860
|
+
...overrides?.severity
|
|
3861
|
+
};
|
|
3862
|
+
const globalColors = R24.mapObjIndexed(
|
|
3863
|
+
(color, colorName) => generateColor(generateColorScale(color, colorScheme2), createColorOverrides(colorName)),
|
|
3864
|
+
baseColorsWithOverrides
|
|
3865
|
+
);
|
|
3866
|
+
const linkColor = generateColor(generateColorScale(dsLinkColor, colorScheme2));
|
|
3872
3867
|
return {
|
|
3873
3868
|
[themeName]: {
|
|
3874
3869
|
...main,
|
|
3875
3870
|
...support,
|
|
3876
|
-
neutral
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
|
|
3880
|
-
|
|
3881
|
-
const blueScale = generateColorScale(baseColors.blue, colorScheme2);
|
|
3882
|
-
const greenScale = generateColorScale(baseColors.green, colorScheme2);
|
|
3883
|
-
const orangeScale = generateColorScale(baseColors.orange, colorScheme2);
|
|
3884
|
-
const purpleScale = generateColorScale(baseColors.purple, colorScheme2);
|
|
3885
|
-
const redScale = generateColorScale(baseColors.red, colorScheme2);
|
|
3886
|
-
return {
|
|
3887
|
-
global: {
|
|
3888
|
-
blue: generateColor(blueScale),
|
|
3889
|
-
green: generateColor(greenScale),
|
|
3890
|
-
orange: generateColor(orangeScale),
|
|
3891
|
-
purple: generateColor(purpleScale),
|
|
3892
|
-
red: generateColor(redScale)
|
|
3871
|
+
neutral,
|
|
3872
|
+
...globalColors,
|
|
3873
|
+
link: {
|
|
3874
|
+
visited: linkColor[12]
|
|
3875
|
+
}
|
|
3893
3876
|
}
|
|
3894
3877
|
};
|
|
3895
3878
|
};
|
|
@@ -3900,270 +3883,6 @@ import * as R25 from "ramda";
|
|
|
3900
3883
|
// src/tokens/template/design-tokens/semantic/color.base.template.json with { type: 'json' }
|
|
3901
3884
|
var color_base_template_default = {
|
|
3902
3885
|
color: {
|
|
3903
|
-
success: {
|
|
3904
|
-
"background-default": {
|
|
3905
|
-
$type: "color",
|
|
3906
|
-
$value: "{global.green.1}"
|
|
3907
|
-
},
|
|
3908
|
-
"background-tinted": {
|
|
3909
|
-
$type: "color",
|
|
3910
|
-
$value: "{global.green.2}"
|
|
3911
|
-
},
|
|
3912
|
-
"surface-default": {
|
|
3913
|
-
$type: "color",
|
|
3914
|
-
$value: "{global.green.3}"
|
|
3915
|
-
},
|
|
3916
|
-
"surface-tinted": {
|
|
3917
|
-
$type: "color",
|
|
3918
|
-
$value: "{global.green.4}"
|
|
3919
|
-
},
|
|
3920
|
-
"surface-hover": {
|
|
3921
|
-
$type: "color",
|
|
3922
|
-
$value: "{global.green.5}"
|
|
3923
|
-
},
|
|
3924
|
-
"surface-active": {
|
|
3925
|
-
$type: "color",
|
|
3926
|
-
$value: "{global.green.6}"
|
|
3927
|
-
},
|
|
3928
|
-
"border-subtle": {
|
|
3929
|
-
$type: "color",
|
|
3930
|
-
$value: "{global.green.7}"
|
|
3931
|
-
},
|
|
3932
|
-
"border-default": {
|
|
3933
|
-
$type: "color",
|
|
3934
|
-
$value: "{global.green.8}"
|
|
3935
|
-
},
|
|
3936
|
-
"border-strong": {
|
|
3937
|
-
$type: "color",
|
|
3938
|
-
$value: "{global.green.9}"
|
|
3939
|
-
},
|
|
3940
|
-
"text-subtle": {
|
|
3941
|
-
$type: "color",
|
|
3942
|
-
$value: "{global.green.10}"
|
|
3943
|
-
},
|
|
3944
|
-
"text-default": {
|
|
3945
|
-
$type: "color",
|
|
3946
|
-
$value: "{global.green.11}"
|
|
3947
|
-
},
|
|
3948
|
-
"base-default": {
|
|
3949
|
-
$type: "color",
|
|
3950
|
-
$value: "{global.green.12}"
|
|
3951
|
-
},
|
|
3952
|
-
"base-hover": {
|
|
3953
|
-
$type: "color",
|
|
3954
|
-
$value: "{global.green.13}"
|
|
3955
|
-
},
|
|
3956
|
-
"base-active": {
|
|
3957
|
-
$type: "color",
|
|
3958
|
-
$value: "{global.green.14}"
|
|
3959
|
-
},
|
|
3960
|
-
"base-contrast-subtle": {
|
|
3961
|
-
$type: "color",
|
|
3962
|
-
$value: "{global.green.15}"
|
|
3963
|
-
},
|
|
3964
|
-
"base-contrast-default": {
|
|
3965
|
-
$type: "color",
|
|
3966
|
-
$value: "{global.green.16}"
|
|
3967
|
-
}
|
|
3968
|
-
},
|
|
3969
|
-
danger: {
|
|
3970
|
-
"background-default": {
|
|
3971
|
-
$type: "color",
|
|
3972
|
-
$value: "{global.red.1}"
|
|
3973
|
-
},
|
|
3974
|
-
"background-tinted": {
|
|
3975
|
-
$type: "color",
|
|
3976
|
-
$value: "{global.red.2}"
|
|
3977
|
-
},
|
|
3978
|
-
"surface-default": {
|
|
3979
|
-
$type: "color",
|
|
3980
|
-
$value: "{global.red.3}"
|
|
3981
|
-
},
|
|
3982
|
-
"surface-tinted": {
|
|
3983
|
-
$type: "color",
|
|
3984
|
-
$value: "{global.red.4}"
|
|
3985
|
-
},
|
|
3986
|
-
"surface-hover": {
|
|
3987
|
-
$type: "color",
|
|
3988
|
-
$value: "{global.red.5}"
|
|
3989
|
-
},
|
|
3990
|
-
"surface-active": {
|
|
3991
|
-
$type: "color",
|
|
3992
|
-
$value: "{global.red.6}"
|
|
3993
|
-
},
|
|
3994
|
-
"border-subtle": {
|
|
3995
|
-
$type: "color",
|
|
3996
|
-
$value: "{global.red.7}"
|
|
3997
|
-
},
|
|
3998
|
-
"border-default": {
|
|
3999
|
-
$type: "color",
|
|
4000
|
-
$value: "{global.red.8}"
|
|
4001
|
-
},
|
|
4002
|
-
"border-strong": {
|
|
4003
|
-
$type: "color",
|
|
4004
|
-
$value: "{global.red.9}"
|
|
4005
|
-
},
|
|
4006
|
-
"text-subtle": {
|
|
4007
|
-
$type: "color",
|
|
4008
|
-
$value: "{global.red.10}"
|
|
4009
|
-
},
|
|
4010
|
-
"text-default": {
|
|
4011
|
-
$type: "color",
|
|
4012
|
-
$value: "{global.red.11}"
|
|
4013
|
-
},
|
|
4014
|
-
"base-default": {
|
|
4015
|
-
$type: "color",
|
|
4016
|
-
$value: "{global.red.12}"
|
|
4017
|
-
},
|
|
4018
|
-
"base-hover": {
|
|
4019
|
-
$type: "color",
|
|
4020
|
-
$value: "{global.red.13}"
|
|
4021
|
-
},
|
|
4022
|
-
"base-active": {
|
|
4023
|
-
$type: "color",
|
|
4024
|
-
$value: "{global.red.14}"
|
|
4025
|
-
},
|
|
4026
|
-
"base-contrast-subtle": {
|
|
4027
|
-
$type: "color",
|
|
4028
|
-
$value: "{global.red.15}"
|
|
4029
|
-
},
|
|
4030
|
-
"base-contrast-default": {
|
|
4031
|
-
$type: "color",
|
|
4032
|
-
$value: "{global.red.16}"
|
|
4033
|
-
}
|
|
4034
|
-
},
|
|
4035
|
-
info: {
|
|
4036
|
-
"background-default": {
|
|
4037
|
-
$type: "color",
|
|
4038
|
-
$value: "{global.blue.1}"
|
|
4039
|
-
},
|
|
4040
|
-
"background-tinted": {
|
|
4041
|
-
$type: "color",
|
|
4042
|
-
$value: "{global.blue.2}"
|
|
4043
|
-
},
|
|
4044
|
-
"surface-default": {
|
|
4045
|
-
$type: "color",
|
|
4046
|
-
$value: "{global.blue.3}"
|
|
4047
|
-
},
|
|
4048
|
-
"surface-tinted": {
|
|
4049
|
-
$type: "color",
|
|
4050
|
-
$value: "{global.blue.4}"
|
|
4051
|
-
},
|
|
4052
|
-
"surface-hover": {
|
|
4053
|
-
$type: "color",
|
|
4054
|
-
$value: "{global.blue.5}"
|
|
4055
|
-
},
|
|
4056
|
-
"surface-active": {
|
|
4057
|
-
$type: "color",
|
|
4058
|
-
$value: "{global.blue.6}"
|
|
4059
|
-
},
|
|
4060
|
-
"border-subtle": {
|
|
4061
|
-
$type: "color",
|
|
4062
|
-
$value: "{global.blue.7}"
|
|
4063
|
-
},
|
|
4064
|
-
"border-default": {
|
|
4065
|
-
$type: "color",
|
|
4066
|
-
$value: "{global.blue.8}"
|
|
4067
|
-
},
|
|
4068
|
-
"border-strong": {
|
|
4069
|
-
$type: "color",
|
|
4070
|
-
$value: "{global.blue.9}"
|
|
4071
|
-
},
|
|
4072
|
-
"text-subtle": {
|
|
4073
|
-
$type: "color",
|
|
4074
|
-
$value: "{global.blue.10}"
|
|
4075
|
-
},
|
|
4076
|
-
"text-default": {
|
|
4077
|
-
$type: "color",
|
|
4078
|
-
$value: "{global.blue.11}"
|
|
4079
|
-
},
|
|
4080
|
-
"base-default": {
|
|
4081
|
-
$type: "color",
|
|
4082
|
-
$value: "{global.blue.12}"
|
|
4083
|
-
},
|
|
4084
|
-
"base-hover": {
|
|
4085
|
-
$type: "color",
|
|
4086
|
-
$value: "{global.blue.13}"
|
|
4087
|
-
},
|
|
4088
|
-
"base-active": {
|
|
4089
|
-
$type: "color",
|
|
4090
|
-
$value: "{global.blue.14}"
|
|
4091
|
-
},
|
|
4092
|
-
"base-contrast-subtle": {
|
|
4093
|
-
$type: "color",
|
|
4094
|
-
$value: "{global.blue.15}"
|
|
4095
|
-
},
|
|
4096
|
-
"base-contrast-default": {
|
|
4097
|
-
$type: "color",
|
|
4098
|
-
$value: "{global.blue.16}"
|
|
4099
|
-
}
|
|
4100
|
-
},
|
|
4101
|
-
warning: {
|
|
4102
|
-
"background-default": {
|
|
4103
|
-
$type: "color",
|
|
4104
|
-
$value: "{global.orange.1}"
|
|
4105
|
-
},
|
|
4106
|
-
"background-tinted": {
|
|
4107
|
-
$type: "color",
|
|
4108
|
-
$value: "{global.orange.2}"
|
|
4109
|
-
},
|
|
4110
|
-
"surface-default": {
|
|
4111
|
-
$type: "color",
|
|
4112
|
-
$value: "{global.orange.3}"
|
|
4113
|
-
},
|
|
4114
|
-
"surface-tinted": {
|
|
4115
|
-
$type: "color",
|
|
4116
|
-
$value: "{global.orange.4}"
|
|
4117
|
-
},
|
|
4118
|
-
"surface-hover": {
|
|
4119
|
-
$type: "color",
|
|
4120
|
-
$value: "{global.orange.5}"
|
|
4121
|
-
},
|
|
4122
|
-
"surface-active": {
|
|
4123
|
-
$type: "color",
|
|
4124
|
-
$value: "{global.orange.6}"
|
|
4125
|
-
},
|
|
4126
|
-
"border-subtle": {
|
|
4127
|
-
$type: "color",
|
|
4128
|
-
$value: "{global.orange.7}"
|
|
4129
|
-
},
|
|
4130
|
-
"border-default": {
|
|
4131
|
-
$type: "color",
|
|
4132
|
-
$value: "{global.orange.8}"
|
|
4133
|
-
},
|
|
4134
|
-
"border-strong": {
|
|
4135
|
-
$type: "color",
|
|
4136
|
-
$value: "{global.orange.9}"
|
|
4137
|
-
},
|
|
4138
|
-
"text-subtle": {
|
|
4139
|
-
$type: "color",
|
|
4140
|
-
$value: "{global.orange.10}"
|
|
4141
|
-
},
|
|
4142
|
-
"text-default": {
|
|
4143
|
-
$type: "color",
|
|
4144
|
-
$value: "{global.orange.11}"
|
|
4145
|
-
},
|
|
4146
|
-
"base-default": {
|
|
4147
|
-
$type: "color",
|
|
4148
|
-
$value: "{global.orange.12}"
|
|
4149
|
-
},
|
|
4150
|
-
"base-hover": {
|
|
4151
|
-
$type: "color",
|
|
4152
|
-
$value: "{global.orange.13}"
|
|
4153
|
-
},
|
|
4154
|
-
"base-active": {
|
|
4155
|
-
$type: "color",
|
|
4156
|
-
$value: "{global.orange.14}"
|
|
4157
|
-
},
|
|
4158
|
-
"base-contrast-subtle": {
|
|
4159
|
-
$type: "color",
|
|
4160
|
-
$value: "{global.orange.15}"
|
|
4161
|
-
},
|
|
4162
|
-
"base-contrast-default": {
|
|
4163
|
-
$type: "color",
|
|
4164
|
-
$value: "{global.orange.16}"
|
|
4165
|
-
}
|
|
4166
|
-
},
|
|
4167
3886
|
focus: {
|
|
4168
3887
|
inner: {
|
|
4169
3888
|
$type: "color",
|
|
@@ -4179,7 +3898,7 @@ var color_base_template_default = {
|
|
|
4179
3898
|
color: {
|
|
4180
3899
|
visited: {
|
|
4181
3900
|
$type: "color",
|
|
4182
|
-
$value: "{
|
|
3901
|
+
$value: "{color.link.visited}"
|
|
4183
3902
|
}
|
|
4184
3903
|
}
|
|
4185
3904
|
}
|
|
@@ -4322,7 +4041,7 @@ var color_template_default2 = {
|
|
|
4322
4041
|
};
|
|
4323
4042
|
|
|
4324
4043
|
// src/tokens/create/generators/semantic.ts
|
|
4325
|
-
var generateSemantic = (colors2) => {
|
|
4044
|
+
var generateSemantic = (colors2, _themeName) => {
|
|
4326
4045
|
const mainColorNames = Object.keys(colors2.main);
|
|
4327
4046
|
const supportColorNames = Object.keys(colors2.support);
|
|
4328
4047
|
const modes = {
|
|
@@ -4356,7 +4075,8 @@ var generateSemantic = (colors2) => {
|
|
|
4356
4075
|
}
|
|
4357
4076
|
}
|
|
4358
4077
|
const customColors = [...mainColorNames, "neutral", ...supportColorNames];
|
|
4359
|
-
const
|
|
4078
|
+
const allColors = [...customColors, ...baseColorNames];
|
|
4079
|
+
const semanticColorTokens = allColors.map(
|
|
4360
4080
|
(colorName) => [
|
|
4361
4081
|
colorName,
|
|
4362
4082
|
R25.map((x) => ({ ...x, $value: x.$value.replace("<color>", colorName) }), color_template_default)
|
|
@@ -4507,7 +4227,7 @@ var theme_template_default = {
|
|
|
4507
4227
|
var generateTheme = (colors2, themeName, borderRadius) => {
|
|
4508
4228
|
const mainColorNames = Object.keys(colors2.main);
|
|
4509
4229
|
const supportColorNames = Object.keys(colors2.support);
|
|
4510
|
-
const customColors = [...mainColorNames, "neutral", ...supportColorNames];
|
|
4230
|
+
const customColors = [...mainColorNames, "neutral", ...supportColorNames, ...baseColorNames];
|
|
4511
4231
|
const themeColorTokens = Object.fromEntries(
|
|
4512
4232
|
customColors.map(
|
|
4513
4233
|
(colorName) => [
|
|
@@ -4520,7 +4240,13 @@ var generateTheme = (colors2, themeName, borderRadius) => {
|
|
|
4520
4240
|
const themeFile = {
|
|
4521
4241
|
color: {
|
|
4522
4242
|
...themeColorTokens,
|
|
4523
|
-
...themeBaseFileColor
|
|
4243
|
+
...themeBaseFileColor,
|
|
4244
|
+
link: {
|
|
4245
|
+
visited: {
|
|
4246
|
+
$type: "color",
|
|
4247
|
+
$value: `{${themeName}.link.visited}`
|
|
4248
|
+
}
|
|
4249
|
+
}
|
|
4524
4250
|
},
|
|
4525
4251
|
...remainingThemeFile
|
|
4526
4252
|
};
|
|
@@ -4592,7 +4318,7 @@ var cliOptions = {
|
|
|
4592
4318
|
var createTokens = async (opts) => {
|
|
4593
4319
|
const { colors: colors2, typography: typography2, name, borderRadius, overrides } = opts;
|
|
4594
4320
|
const colorSchemes = ["light", "dark"];
|
|
4595
|
-
const semantic2 = generateSemantic(colors2);
|
|
4321
|
+
const semantic2 = generateSemantic(colors2, name);
|
|
4596
4322
|
const tokenSets = new Map([
|
|
4597
4323
|
...getDefaultTokens([
|
|
4598
4324
|
"primitives/globals",
|
|
@@ -4607,7 +4333,6 @@ var createTokens = async (opts) => {
|
|
|
4607
4333
|
[`primitives/modes/typography/primary/${name}`, generateTypography(name, typography2)],
|
|
4608
4334
|
[`primitives/modes/typography/secondary/${name}`, generateTypography(name, typography2)],
|
|
4609
4335
|
...colorSchemes.flatMap((scheme) => [
|
|
4610
|
-
[`primitives/modes/color-scheme/${scheme}/global`, generateColorGlobal(scheme)],
|
|
4611
4336
|
[`primitives/modes/color-scheme/${scheme}/${name}`, generateColorScheme(name, scheme, colors2, overrides)]
|
|
4612
4337
|
]),
|
|
4613
4338
|
[`themes/${name}`, generateTheme(colors2, name, borderRadius)],
|
|
@@ -4706,10 +4431,12 @@ var colorModeOverrideSchema = z.object({
|
|
|
4706
4431
|
light: colorSchema.optional(),
|
|
4707
4432
|
dark: colorSchema.optional()
|
|
4708
4433
|
}).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"');
|
|
4434
|
+
var colorWeightOverrideSchema = z.partialRecord(z.enum([...colorNames]), colorModeOverrideSchema).describe('The name of the color to add overrides for, e.g. "accent"');
|
|
4710
4435
|
var semanticColorOverrideSchema = z.record(z.string(), colorWeightOverrideSchema).describe("An object with color names as keys");
|
|
4436
|
+
var severityColorOverrideSchema = z.partialRecord(z.enum(baseColorNames), colorSchema.describe("A hex color, which is used for creating a color scale")).optional().describe("An object with severity color names as keys");
|
|
4711
4437
|
var overridesSchema = z.object({
|
|
4712
|
-
colors: semanticColorOverrideSchema.optional()
|
|
4438
|
+
colors: semanticColorOverrideSchema.optional(),
|
|
4439
|
+
severity: severityColorOverrideSchema.optional()
|
|
4713
4440
|
}).describe("Overrides for generated design tokens. Currently only supports colors defined in your theme").optional();
|
|
4714
4441
|
var themeSchema = z.object({
|
|
4715
4442
|
colors: z.object({
|
|
@@ -4816,6 +4543,16 @@ async function parseBuildConfig(configFile, { configPath }) {
|
|
|
4816
4543
|
}
|
|
4817
4544
|
|
|
4818
4545
|
// bin/designsystemet.ts
|
|
4546
|
+
var figletAscii = `
|
|
4547
|
+
_____ _ _ _
|
|
4548
|
+
| __ \\ (_) | | | |
|
|
4549
|
+
| | | | ___ ___ _ __ _ _ __ ___ _ _ ___| |_ ___ _ __ ___ ___| |_
|
|
4550
|
+
| | | |/ _ \\/ __| |/ _\` | '_ \\/ __| | | / __| __/ _ \\ '_ \` _ \\ / _ \\ __|
|
|
4551
|
+
| |__| | __/\\__ \\ | (_| | | | \\__ \\ |_| \\__ \\ || __/ | | | | | __/ |_
|
|
4552
|
+
|_____/ \\___||___/_|\\__, |_| |_|___/\\__, |___/\\__\\___|_| |_| |_|\\___|\\__|
|
|
4553
|
+
__/ | __/ |
|
|
4554
|
+
|___/ |___/
|
|
4555
|
+
`;
|
|
4819
4556
|
program.name("designsystemet").description("CLI for working with Designsystemet").showHelpAfterError();
|
|
4820
4557
|
var DEFAULT_TOKENS_CREATE_DIR = "./design-tokens";
|
|
4821
4558
|
var DEFAULT_TOKENS_BUILD_DIR = "./design-tokens-build";
|
|
@@ -4829,6 +4566,7 @@ function makeTokenCommands() {
|
|
|
4829
4566
|
`Output directory for built ${pc11.blue("design-tokens")}`,
|
|
4830
4567
|
DEFAULT_TOKENS_BUILD_DIR
|
|
4831
4568
|
).option(`--${cliOptions.clean} [boolean]`, "Clean output directory before building tokens", parseBoolean, false).option("--dry [boolean]", `Dry run for built ${pc11.blue("design-tokens")}`, parseBoolean, false).option("--verbose", "Enable verbose output", false).option("--config <string>", `Path to config file (default: "${DEFAULT_CONFIG_FILE}")`).option("--experimental-tailwind", "Generate Tailwind CSS classes for tokens", false).action(async (opts) => {
|
|
4569
|
+
console.log(figletAscii);
|
|
4832
4570
|
const { verbose, clean, dry, experimentalTailwind } = opts;
|
|
4833
4571
|
const tokensDir = typeof opts.tokens === "string" ? opts.tokens : DEFAULT_TOKENS_CREATE_DIR;
|
|
4834
4572
|
const outDir = typeof opts.outDir === "string" ? opts.outDir : "./dist/tokens";
|
|
@@ -4853,6 +4591,7 @@ function makeTokenCommands() {
|
|
|
4853
4591
|
(radiusAsString) => Number(radiusAsString),
|
|
4854
4592
|
4
|
|
4855
4593
|
).option("--theme <string>", "Theme name (ignored when using JSON config file)", DEFAULT_THEME_NAME).option("--config <string>", `Path to config file (default: "${DEFAULT_CONFIG_FILE}")`).action(async (opts, cmd) => {
|
|
4594
|
+
console.log(figletAscii);
|
|
4856
4595
|
if (opts.dry) {
|
|
4857
4596
|
console.log(`Performing dry run, no files will be written`);
|
|
4858
4597
|
}
|
|
@@ -4877,6 +4616,7 @@ function makeTokenCommands() {
|
|
|
4877
4616
|
}
|
|
4878
4617
|
program.addCommand(makeTokenCommands());
|
|
4879
4618
|
program.command("migrate").description("run a Designsystemet migration").addArgument(new Argument("[migration]", "Available migrations").choices(Object.keys(migrations_default))).option("-l --list", "List available migrations").option("-g --glob <glob>", "Glob for files upon which to apply the migration", "./**/*.(tsx|css)").action((migrationKey, opts) => {
|
|
4619
|
+
console.log(figletAscii);
|
|
4880
4620
|
const { glob: glob2, list } = opts;
|
|
4881
4621
|
if (list) {
|
|
4882
4622
|
for (const key of Object.keys(migrations_default)) {
|
|
@@ -4909,3 +4649,6 @@ async function getConfigFile(config) {
|
|
|
4909
4649
|
const configFile = await readConfigFile(configPath, allowFileNotFound);
|
|
4910
4650
|
return { configFile, configPath };
|
|
4911
4651
|
}
|
|
4652
|
+
export {
|
|
4653
|
+
figletAscii
|
|
4654
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"color": {
|
|
3
|
+
"focus": {
|
|
4
|
+
"inner": {
|
|
5
|
+
"$type": "color",
|
|
6
|
+
"$value": "{color.neutral.background-default}"
|
|
7
|
+
},
|
|
8
|
+
"outer": {
|
|
9
|
+
"$type": "color",
|
|
10
|
+
"$value": "{color.neutral.text-default}"
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"link": {
|
|
15
|
+
"color": {
|
|
16
|
+
"visited": {
|
|
17
|
+
"$type": "color",
|
|
18
|
+
"$value": "{color.link.visited}"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|