@digdir/designsystemet 1.13.3 → 1.14.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/dist/bin/designsystemet.d.ts.map +1 -1
- package/dist/bin/designsystemet.js +20 -15
- package/dist/package.js +1 -1
- package/dist/src/scripts/update-preview-tokens.d.ts.map +1 -1
- package/dist/src/tokens/create/files.d.ts +10 -5
- package/dist/src/tokens/create/files.d.ts.map +1 -1
- package/dist/src/tokens/create/files.js +15 -13
- package/dist/src/tokens/create/generators/$metadata.d.ts +7 -3
- package/dist/src/tokens/create/generators/$metadata.d.ts.map +1 -1
- package/dist/src/tokens/create/generators/$metadata.js +13 -7
- package/dist/src/tokens/create/generators/$themes.d.ts +2 -4
- package/dist/src/tokens/create/generators/$themes.d.ts.map +1 -1
- package/dist/src/tokens/create/generators/$themes.js +8 -7
- package/dist/src/tokens/create.d.ts +2 -1
- package/dist/src/tokens/create.d.ts.map +1 -1
- package/dist/src/tokens/create.js +10 -7
- package/dist/src/tokens/format.d.ts.map +1 -1
- package/dist/src/tokens/format.js +3 -6
- package/dist/src/tokens/process/configs.js +3 -0
- package/dist/src/tokens/types.d.ts +6 -0
- package/dist/src/tokens/types.d.ts.map +1 -1
- package/dist/src/tokens/utils.d.ts +2 -1
- package/dist/src/tokens/utils.d.ts.map +1 -1
- package/dist/src/tokens/utils.js +6 -1
- package/package.json +5 -5
|
@@ -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":";AAiBA,eAAO,MAAM,WAAW,4iBASvB,CAAC"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { convertToHex } from "../src/colors/utils.js";
|
|
3
3
|
import "../src/colors/index.js";
|
|
4
|
-
import { cliOptions, createTokens } from "../src/tokens/create.js";
|
|
4
|
+
import { cliOptions, createTokens, tokenSetDimensions } from "../src/tokens/create.js";
|
|
5
5
|
import { dsfs } from "../src/utils/filesystem.js";
|
|
6
6
|
import { parseCreateConfig, readConfigFile } from "./config.js";
|
|
7
7
|
import migrations_default from "../src/migrations/index.js";
|
|
8
|
+
import { colorNamesByCategory } from "../src/tokens/utils.js";
|
|
8
9
|
import { buildTokens } from "../src/tokens/build.js";
|
|
9
|
-
import {
|
|
10
|
+
import { createSystemTokenFiles, tokenSetsToFiles } from "../src/tokens/create/files.js";
|
|
10
11
|
import { generateConfigFromTokens } from "../src/tokens/generate-config.js";
|
|
11
12
|
import pc from "picocolors";
|
|
12
13
|
import * as R from "ramda";
|
|
@@ -68,21 +69,25 @@ function makeTokenCommands() {
|
|
|
68
69
|
outdir: config.outDir
|
|
69
70
|
});
|
|
70
71
|
const outDir = dsfs.outDir;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
const theme = {
|
|
72
|
+
const files = [];
|
|
73
|
+
for (const [name, themeConfig] of Object.entries(config.themes)) {
|
|
74
|
+
const { tokenSets } = await createTokens({
|
|
75
75
|
name,
|
|
76
|
-
...
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
files = files.concat(await createTokenFiles({
|
|
80
|
-
outDir,
|
|
81
|
-
theme,
|
|
82
|
-
tokenSets,
|
|
83
|
-
themeNames
|
|
84
|
-
}));
|
|
76
|
+
...themeConfig
|
|
77
|
+
});
|
|
78
|
+
files.push(...tokenSetsToFiles(tokenSets));
|
|
85
79
|
}
|
|
80
|
+
const colors = config.themes?.[themeNames[0]]?.colors ?? {
|
|
81
|
+
main: {},
|
|
82
|
+
support: {}
|
|
83
|
+
};
|
|
84
|
+
files.push(...await createSystemTokenFiles({
|
|
85
|
+
tokenSetDimensions,
|
|
86
|
+
themeNames,
|
|
87
|
+
colors: colorNamesByCategory(colors)
|
|
88
|
+
}));
|
|
89
|
+
if (config.clean) await dsfs.cleanDir(outDir);
|
|
90
|
+
await dsfs.mkdir(outDir);
|
|
86
91
|
await dsfs.writeFiles(files, outDir);
|
|
87
92
|
console.log(`\n✅ Finished creating tokens in ${pc.green(outDir)} for themes: ${pc.blue(themeNames.join(", "))}`);
|
|
88
93
|
return Promise.resolve();
|
package/dist/package.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-preview-tokens.d.ts","sourceRoot":"","sources":["../../../src/scripts/update-preview-tokens.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"update-preview-tokens.d.ts","sourceRoot":"","sources":["../../../src/scripts/update-preview-tokens.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAmBhD,eAAO,MAAM,WAAW,GAAU,aAAa,KAAK,kBAsEnD,CAAC"}
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
import type { OutputFile,
|
|
1
|
+
import type { ColorNamesByCategory, OutputFile, TokenSetDimensions, TokenSets } from '../types.js';
|
|
2
2
|
export declare const stringify: (data: unknown) => string;
|
|
3
3
|
type CreateTokenFilesOptions = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
tokenSets: TokenSets;
|
|
4
|
+
tokenSetDimensions: TokenSetDimensions;
|
|
5
|
+
colors: ColorNamesByCategory;
|
|
7
6
|
themeNames: string[];
|
|
8
7
|
};
|
|
9
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Creates system token files (`$themes.json`, `$metadata.json`, `$designsystemet.jsonc`) based on the provided token set dimensions and theme names.
|
|
10
|
+
*
|
|
11
|
+
* `$themes.json` and `$metadata.json` are essential for Token Studio and Style Dictionary to correctly interpret and manage the design tokens.
|
|
12
|
+
*/
|
|
13
|
+
export declare const createSystemTokenFiles: (options: CreateTokenFilesOptions) => Promise<OutputFile[]>;
|
|
14
|
+
export declare const tokenSetsToFiles: (tokenSets: TokenSets) => OutputFile[];
|
|
10
15
|
export {};
|
|
11
16
|
//# sourceMappingURL=files.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../../../src/tokens/create/files.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"files.d.ts","sourceRoot":"","sources":["../../../../src/tokens/create/files.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,UAAU,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAKnG,eAAO,MAAM,SAAS,GAAI,MAAM,OAAO,WAAkC,CAAC;AAE1E,KAAK,uBAAuB,GAAG;IAC7B,kBAAkB,EAAE,kBAAkB,CAAC;IACvC,MAAM,EAAE,oBAAoB,CAAC;IAC7B,UAAU,EAAE,MAAM,EAAE,CAAC;CACtB,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GAAU,SAAS,uBAAuB,0BAiB5E,CAAC;AAEF,eAAO,MAAM,gBAAgB,GAAI,WAAW,SAAS,KAAG,UAAU,EAQjE,CAAC"}
|
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
import { dsfs } from "../../utils/filesystem.js";
|
|
2
1
|
import { generate$Designsystemet } from "./generators/$designsystemet.js";
|
|
3
2
|
import { generate$Metadata } from "./generators/$metadata.js";
|
|
4
3
|
import { generate$Themes } from "./generators/$themes.js";
|
|
5
4
|
//#region src/tokens/create/files.ts
|
|
6
5
|
const stringify = (data) => JSON.stringify(data, null, 2);
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Creates system token files (`$themes.json`, `$metadata.json`, `$designsystemet.jsonc`) based on the provided token set dimensions and theme names.
|
|
8
|
+
*
|
|
9
|
+
* `$themes.json` and `$metadata.json` are essential for Token Studio and Style Dictionary to correctly interpret and manage the design tokens.
|
|
10
|
+
*/
|
|
11
|
+
const createSystemTokenFiles = async (options) => {
|
|
12
|
+
const { colors, themeNames, tokenSetDimensions } = options;
|
|
13
|
+
const files = [];
|
|
9
14
|
const $themesPath = "$themes.json";
|
|
10
15
|
const $metadataPath = "$metadata.json";
|
|
11
16
|
const $designsystemetPath = "$designsystemet.jsonc";
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
"medium",
|
|
15
|
-
"large"
|
|
16
|
-
];
|
|
17
|
-
await dsfs.mkdir(outDir);
|
|
18
|
-
const $themes = await generate$Themes(["dark", "light"], themeNames, colors, sizeModes);
|
|
19
|
-
const $metadata = generate$Metadata(["dark", "light"], themeNames, colors, sizeModes);
|
|
17
|
+
const $themes = await generate$Themes(tokenSetDimensions, themeNames, colors);
|
|
18
|
+
const $metadata = generate$Metadata(tokenSetDimensions, themeNames, colors);
|
|
20
19
|
const $designsystemet = generate$Designsystemet();
|
|
21
|
-
const files = [];
|
|
22
20
|
files.push({
|
|
23
21
|
destination: $themesPath,
|
|
24
22
|
output: stringify($themes)
|
|
@@ -31,6 +29,10 @@ const createTokenFiles = async (options) => {
|
|
|
31
29
|
destination: $designsystemetPath,
|
|
32
30
|
output: stringify($designsystemet)
|
|
33
31
|
});
|
|
32
|
+
return files;
|
|
33
|
+
};
|
|
34
|
+
const tokenSetsToFiles = (tokenSets) => {
|
|
35
|
+
const files = [];
|
|
34
36
|
for (const [set, tokens] of tokenSets) {
|
|
35
37
|
const filePath = `${set}.json`;
|
|
36
38
|
files.push({
|
|
@@ -41,4 +43,4 @@ const createTokenFiles = async (options) => {
|
|
|
41
43
|
return files;
|
|
42
44
|
};
|
|
43
45
|
//#endregion
|
|
44
|
-
export {
|
|
46
|
+
export { createSystemTokenFiles, stringify, tokenSetsToFiles };
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Colors, SizeModes } from '../../types.js';
|
|
1
|
+
import type { ColorNamesByCategory, TokenSetDimensions } from '../../types.js';
|
|
3
2
|
type Metadata = {
|
|
4
3
|
tokenSetOrder: string[];
|
|
5
4
|
};
|
|
6
|
-
|
|
5
|
+
/**
|
|
6
|
+
* Generates metadata for the given token set dimensions, theme names, and colors.
|
|
7
|
+
*
|
|
8
|
+
* This is used to order tokens in Token Studio
|
|
9
|
+
*/
|
|
10
|
+
export declare function generate$Metadata(tokenSetDimensions: TokenSetDimensions, themeNames: string[], colors: ColorNamesByCategory): Metadata;
|
|
7
11
|
export {};
|
|
8
12
|
//# sourceMappingURL=$metadata.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"$metadata.d.ts","sourceRoot":"","sources":["../../../../../src/tokens/create/generators/$metadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"$metadata.d.ts","sourceRoot":"","sources":["../../../../../src/tokens/create/generators/$metadata.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAE/E,KAAK,QAAQ,GAAG;IACd,aAAa,EAAE,MAAM,EAAE,CAAC;CACzB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,iBAAiB,CAC/B,kBAAkB,EAAE,kBAAkB,EACtC,UAAU,EAAE,MAAM,EAAE,EACpB,MAAM,EAAE,oBAAoB,GAC3B,QAAQ,CAoBV"}
|
|
@@ -1,17 +1,23 @@
|
|
|
1
1
|
//#region src/tokens/create/generators/$metadata.ts
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* Generates metadata for the given token set dimensions, theme names, and colors.
|
|
4
|
+
*
|
|
5
|
+
* This is used to order tokens in Token Studio
|
|
6
|
+
*/
|
|
7
|
+
function generate$Metadata(tokenSetDimensions, themeNames, colors) {
|
|
8
|
+
const { colorSchemes, sizeModes } = tokenSetDimensions;
|
|
3
9
|
return { tokenSetOrder: [
|
|
4
10
|
"primitives/globals",
|
|
5
11
|
...sizeModes.map((size) => `primitives/modes/size/${size}`),
|
|
6
12
|
"primitives/modes/size/global",
|
|
7
13
|
...sizeModes.map((size) => `primitives/modes/typography/size/${size}`),
|
|
8
|
-
...
|
|
9
|
-
...
|
|
10
|
-
...
|
|
11
|
-
...
|
|
14
|
+
...themeNames.map((theme) => `primitives/modes/typography/primary/${theme}`),
|
|
15
|
+
...themeNames.map((theme) => `primitives/modes/typography/secondary/${theme}`),
|
|
16
|
+
...colorSchemes.flatMap((scheme) => [...themeNames.map((theme) => `primitives/modes/color-scheme/${scheme}/${theme}`)]),
|
|
17
|
+
...themeNames.map((theme) => `themes/${theme}`),
|
|
12
18
|
"semantic/color",
|
|
13
|
-
...
|
|
14
|
-
...
|
|
19
|
+
...colors.main.map((color) => `semantic/modes/main-color/${color}`),
|
|
20
|
+
...colors.support.map((color) => `semantic/modes/support-color/${color}`),
|
|
15
21
|
"semantic/style"
|
|
16
22
|
] };
|
|
17
23
|
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { type ThemeObject } from '@tokens-studio/types';
|
|
2
|
-
import type {
|
|
3
|
-
import type { Colors, SizeModes } from '../../types.js';
|
|
4
|
-
type ColorSchemes = Array<ColorScheme>;
|
|
2
|
+
import type { ColorNamesByCategory, TokenSetDimensions } from '../../types.js';
|
|
5
3
|
type ThemeObject_ = ThemeObject & {
|
|
6
4
|
$figmaCollectionId?: string;
|
|
7
5
|
$figmaModeId?: string;
|
|
@@ -22,6 +20,6 @@ type ThemeObject_ = ThemeObject & {
|
|
|
22
20
|
- New collections/modes may cause users hitting the cap on Figma variable modes which is at time of writing 4 (or unlimited for enterprise).
|
|
23
21
|
|
|
24
22
|
*/
|
|
25
|
-
export declare function generate$Themes(
|
|
23
|
+
export declare function generate$Themes(tokenSetDimensions: TokenSetDimensions, themeNames: string[], colors: ColorNamesByCategory): Promise<ThemeObject_[]>;
|
|
26
24
|
export {};
|
|
27
25
|
//# sourceMappingURL=$themes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"$themes.d.ts","sourceRoot":"","sources":["../../../../../src/tokens/create/generators/$themes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAkB,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"$themes.d.ts","sourceRoot":"","sources":["../../../../../src/tokens/create/generators/$themes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAkB,MAAM,sBAAsB,CAAC;AAGxE,OAAO,KAAK,EAAE,oBAAoB,EAAa,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAa1F,KAAK,YAAY,GAAG,WAAW,GAAG;IAChC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,wBAAwB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnD,CAAC;AAEF;;;;;;;;;;;;;;EAcE;AACF,wBAAsB,eAAe,CACnC,kBAAkB,EAAE,kBAAkB,EACtC,UAAU,EAAE,MAAM,EAAE,EACpB,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,YAAY,EAAE,CAAC,CAWzB"}
|
|
@@ -21,15 +21,16 @@ async function createHash(text, algo = "SHA-1") {
|
|
|
21
21
|
- New collections/modes may cause users hitting the cap on Figma variable modes which is at time of writing 4 (or unlimited for enterprise).
|
|
22
22
|
|
|
23
23
|
*/
|
|
24
|
-
async function generate$Themes(
|
|
24
|
+
async function generate$Themes(tokenSetDimensions, themeNames, colors) {
|
|
25
|
+
const { colorSchemes, sizeModes } = tokenSetDimensions;
|
|
25
26
|
return [
|
|
26
27
|
...generateSizeGroup(sizeModes),
|
|
27
|
-
...await generateThemesGroup(
|
|
28
|
-
...generateTypographyGroup(
|
|
29
|
-
...generateColorSchemesGroup(colorSchemes,
|
|
28
|
+
...await generateThemesGroup(themeNames),
|
|
29
|
+
...generateTypographyGroup(themeNames),
|
|
30
|
+
...generateColorSchemesGroup(colorSchemes, themeNames),
|
|
30
31
|
generateSemanticGroup(),
|
|
31
|
-
...await generateColorGroup("main", colors),
|
|
32
|
-
...await generateColorGroup("support", colors)
|
|
32
|
+
...await generateColorGroup("main", colors.main),
|
|
33
|
+
...await generateColorGroup("support", colors.support)
|
|
33
34
|
];
|
|
34
35
|
}
|
|
35
36
|
function generateSizeGroup(_sizes) {
|
|
@@ -130,7 +131,7 @@ function generateSemanticGroup() {
|
|
|
130
131
|
};
|
|
131
132
|
}
|
|
132
133
|
async function generateColorGroup(group, colors) {
|
|
133
|
-
return Promise.all(
|
|
134
|
+
return Promise.all(colors.map(async (color) => ({
|
|
134
135
|
id: await createHash(`${group}-${color}`),
|
|
135
136
|
name: color,
|
|
136
137
|
selectedTokenSets: { [`semantic/modes/${group}-color/${color}`]: TokenSetStatus.ENABLED },
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { Theme, TokenSets } from './types.js';
|
|
1
|
+
import type { Theme, TokenSetDimensions, TokenSets } from './types.js';
|
|
2
|
+
export declare const tokenSetDimensions: TokenSetDimensions;
|
|
2
3
|
export declare const cliOptions: {
|
|
3
4
|
readonly outDir: "out-dir";
|
|
4
5
|
readonly clean: "clean";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/tokens/create.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create.d.ts","sourceRoot":"","sources":["../../../src/tokens/create.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,KAAK,EAAY,kBAAkB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEjF,eAAO,MAAM,kBAAkB,EAAE,kBAGhC,CAAC;AAEF,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;CAeb,CAAC;AAEX,eAAO,MAAM,YAAY,GAAU,OAAO,KAAK;;EA2B9C,CAAC"}
|
|
@@ -7,6 +7,14 @@ import { generateColorModes } from "./create/generators/semantic/color-modes.js"
|
|
|
7
7
|
import { generateSemanticStyle } from "./create/generators/semantic/style.js";
|
|
8
8
|
import { generateTheme } from "./create/generators/themes/theme.js";
|
|
9
9
|
//#region src/tokens/create.ts
|
|
10
|
+
const tokenSetDimensions = {
|
|
11
|
+
colorSchemes: ["dark", "light"],
|
|
12
|
+
sizeModes: [
|
|
13
|
+
"small",
|
|
14
|
+
"medium",
|
|
15
|
+
"large"
|
|
16
|
+
]
|
|
17
|
+
};
|
|
10
18
|
const cliOptions = {
|
|
11
19
|
outDir: "out-dir",
|
|
12
20
|
clean: "clean",
|
|
@@ -23,12 +31,7 @@ const cliOptions = {
|
|
|
23
31
|
};
|
|
24
32
|
const createTokens = async (theme) => {
|
|
25
33
|
const { colors, typography, name, borderRadius, overrides } = theme;
|
|
26
|
-
const colorSchemes =
|
|
27
|
-
const sizeModes = [
|
|
28
|
-
"small",
|
|
29
|
-
"medium",
|
|
30
|
-
"large"
|
|
31
|
-
];
|
|
34
|
+
const { colorSchemes, sizeModes } = tokenSetDimensions;
|
|
32
35
|
return { tokenSets: new Map([
|
|
33
36
|
["primitives/globals", generateGlobals()],
|
|
34
37
|
...sizeModes.map((size) => [`primitives/modes/size/${size}`, generateSize(size)]),
|
|
@@ -44,4 +47,4 @@ const createTokens = async (theme) => {
|
|
|
44
47
|
]) };
|
|
45
48
|
};
|
|
46
49
|
//#endregion
|
|
47
|
-
export { cliOptions, createTokens };
|
|
50
|
+
export { cliOptions, createTokens, tokenSetDimensions };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../src/tokens/format.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,aAAa,EAAmB,MAAM,uBAAuB,CAAC;AAE5E,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../src/tokens/format.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,aAAa,EAAmB,MAAM,uBAAuB,CAAC;AAE5E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAGxC,eAAO,MAAM,YAAY,GAAU,SAAS,IAAI,CAAC,aAAa,EAAE,MAAM,GAAG,mBAAmB,CAAC,2DAQ5F,CAAC;AAEF,eAAO,MAAM,WAAW,GAAU,aAAa,KAAK,2DAgBnD,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,GAAU,aAAa,KAAK,oBAItD,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { createTokens } from "./create.js";
|
|
1
|
+
import { createTokens, tokenSetDimensions } from "./create.js";
|
|
2
|
+
import { colorNamesByCategory } from "./utils.js";
|
|
2
3
|
import { processThemeObject } from "./process/utils/getMultidimensionalThemes.js";
|
|
3
4
|
import { processPlatform } from "./process/platform.js";
|
|
4
5
|
import { createThemeCSSFiles } from "./process/output/theme.js";
|
|
@@ -16,11 +17,7 @@ const formatTheme = async (themeConfig) => {
|
|
|
16
17
|
const { tokenSets } = await createTokens(themeConfig);
|
|
17
18
|
return await formatTokens({
|
|
18
19
|
tokenSets,
|
|
19
|
-
processed$themes: (await generate$Themes(
|
|
20
|
-
"small",
|
|
21
|
-
"medium",
|
|
22
|
-
"large"
|
|
23
|
-
])).map(processThemeObject),
|
|
20
|
+
processed$themes: (await generate$Themes(tokenSetDimensions, [themeConfig.name], colorNamesByCategory(themeConfig.colors))).map(processThemeObject),
|
|
24
21
|
verbose: false
|
|
25
22
|
});
|
|
26
23
|
};
|
|
@@ -75,6 +75,9 @@ const getConfigsForThemeDimensions = (getConfig, processed$themes, dimensions, o
|
|
|
75
75
|
},
|
|
76
76
|
config: {
|
|
77
77
|
...config,
|
|
78
|
+
/** Use official W3C design token format
|
|
79
|
+
@see https://v4.styledictionary.com/info/dtcg/
|
|
80
|
+
@see https://design-tokens.github.io/community-group/format/ */
|
|
78
81
|
usesDtcg: true,
|
|
79
82
|
log: {
|
|
80
83
|
...config?.log,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Config as SDConfig } from 'style-dictionary/types';
|
|
2
2
|
import type { ConfigSchemaTheme } from '../config.js';
|
|
3
|
+
import type { ColorScheme } from '../index.js';
|
|
3
4
|
import type { GetStyleDictionaryConfig } from './process/configs/shared.js';
|
|
4
5
|
export type Token = {
|
|
5
6
|
$value: string | Record<string, string>[];
|
|
@@ -25,6 +26,7 @@ export declare const colorCategories: {
|
|
|
25
26
|
readonly support: "support";
|
|
26
27
|
};
|
|
27
28
|
export type ColorCategories = keyof typeof colorCategories;
|
|
29
|
+
export type ColorNamesByCategory = Record<ColorCategories, string[]>;
|
|
28
30
|
export type BuiltInColors = 'neutral' | 'success' | 'warning' | 'danger' | 'info';
|
|
29
31
|
export type SizeModes = 'small' | 'medium' | 'large';
|
|
30
32
|
/**
|
|
@@ -40,6 +42,10 @@ export type ThemePermutation = {
|
|
|
40
42
|
typography: string;
|
|
41
43
|
};
|
|
42
44
|
export type ThemeDimension = keyof ThemePermutation;
|
|
45
|
+
export type TokenSetDimensions = {
|
|
46
|
+
colorSchemes: ColorScheme[];
|
|
47
|
+
sizeModes: SizeModes[];
|
|
48
|
+
};
|
|
43
49
|
export type GetSDConfigOptions = {
|
|
44
50
|
tokensDir?: string;
|
|
45
51
|
dry?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/tokens/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAC;AAE5E,MAAM,MAAM,KAAK,GACb;IAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GAC5D;IAAE,KAAK,EAAE,WAAW,CAAC;IAAC,MAAM,EA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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Tokens } from 'style-dictionary';
|
|
2
2
|
import type { DesignToken, TransformedToken } from 'style-dictionary/types';
|
|
3
|
-
import { type ColorCategories, type TokenSet } from './types.js';
|
|
3
|
+
import { type ColorCategories, type ColorNamesByCategory, type Colors, type TokenSet } from './types.js';
|
|
4
4
|
/**
|
|
5
5
|
* Returns type based on design token format used. Read more:https://v4.styledictionary.com/info/dtcg/
|
|
6
6
|
* @param token Transformed token
|
|
@@ -60,4 +60,5 @@ export declare function inlineTokens(shouldInline: (t: TransformedToken) => bool
|
|
|
60
60
|
export declare function shortSizeName(size: string): string;
|
|
61
61
|
export declare const sizeComparator: (size: string) => number;
|
|
62
62
|
export declare function orderBySize(sizes: string[]): string[];
|
|
63
|
+
export declare function colorNamesByCategory(colors: Colors): ColorNamesByCategory;
|
|
63
64
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/tokens/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/tokens/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC5E,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,MAAM,EAEX,KAAK,QAAQ,EACd,MAAM,YAAY,CAAC;AAMpB;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAAI,OAAO,gBAAgB,WAAkD,CAAC;AAElG;;;;;;GAMG;AACH,eAA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O,EAAE,MAAM,EAAE,gBAAgB,EAAE,sBAetG;AAUD,wBAAgB,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAElD;AAED,eAAO,MAAM,cAAc,GAAI,MAAM,MAAM,KAAG,MAG7C,CAAC;AAEF,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAErD;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,oBAAoB,CAMzE"}
|
package/dist/src/tokens/utils.js
CHANGED
|
@@ -117,5 +117,10 @@ const sizeComparator = (size) => {
|
|
|
117
117
|
function orderBySize(sizes) {
|
|
118
118
|
return R.sortBy(sizeComparator, sizes);
|
|
119
119
|
}
|
|
120
|
+
function colorNamesByCategory(colors) {
|
|
121
|
+
const result = {};
|
|
122
|
+
for (const category of Object.values(colorCategories)) result[category] = Object.keys(colors[category] ?? {});
|
|
123
|
+
return result;
|
|
124
|
+
}
|
|
120
125
|
//#endregion
|
|
121
|
-
export { getType, getValue, inlineTokens, isColorCategoryToken, isDigit, isGlobalColorToken, isSemanticColorToken, isSemanticToken, orderBySize, pathStartsWithOneOf, shortSizeName, sizeComparator, traverseObj, typeEquals };
|
|
126
|
+
export { colorNamesByCategory, getType, getValue, inlineTokens, isColorCategoryToken, isDigit, isGlobalColorToken, isSemanticColorToken, isSemanticToken, orderBySize, pathStartsWithOneOf, shortSizeName, sizeComparator, traverseObj, typeEquals };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@digdir/designsystemet",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.0",
|
|
4
4
|
"description": "CLI for Designsystemet",
|
|
5
5
|
"author": "Designsystemet team",
|
|
6
6
|
"engines": {
|
|
@@ -45,12 +45,12 @@
|
|
|
45
45
|
"hsluv": "^1.0.1",
|
|
46
46
|
"object-hash": "^3.0.0",
|
|
47
47
|
"picocolors": "^1.1.1",
|
|
48
|
-
"postcss": "^8.5.
|
|
48
|
+
"postcss": "^8.5.13",
|
|
49
49
|
"ramda": "^0.32.0",
|
|
50
50
|
"style-dictionary": "^5.4.0",
|
|
51
|
-
"zod": "^4.
|
|
51
|
+
"zod": "^4.4.2",
|
|
52
52
|
"zod-validation-error": "^5.0.0",
|
|
53
|
-
"@digdir/designsystemet-types": "1.
|
|
53
|
+
"@digdir/designsystemet-types": "1.14.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@tokens-studio/types": "0.5.2",
|
|
@@ -58,7 +58,7 @@
|
|
|
58
58
|
"@types/node": "24.12.2",
|
|
59
59
|
"@types/object-hash": "3.0.6",
|
|
60
60
|
"@types/ramda": "0.31.1",
|
|
61
|
-
"tsdown": "0.21.
|
|
61
|
+
"tsdown": "0.21.10",
|
|
62
62
|
"tsx": "4.21.0",
|
|
63
63
|
"typescript": "5.9.3"
|
|
64
64
|
},
|