@digdir/designsystemet 1.16.1 → 1.18.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/README.md +2 -15
- package/dist/bin/config.d.ts +2 -4
- package/dist/bin/config.d.ts.map +1 -1
- package/dist/bin/config.js +6 -8
- package/dist/bin/designsystemet.d.ts +1 -1
- package/dist/bin/designsystemet.d.ts.map +1 -1
- package/dist/bin/designsystemet.js +12 -13
- package/dist/config.schema.json +5 -33
- package/dist/package.js +1 -1
- package/dist/src/automigrate.d.ts +2 -0
- package/dist/src/automigrate.d.ts.map +1 -0
- package/dist/src/automigrate.js +33 -0
- package/dist/src/colors/types.d.ts +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +4 -3
- package/dist/src/migrations/flatten-color-categories.d.ts +10 -0
- package/dist/src/migrations/flatten-color-categories.d.ts.map +1 -0
- package/dist/src/migrations/flatten-color-categories.js +51 -0
- package/dist/src/migrations/index.d.ts +9 -0
- package/dist/src/migrations/index.d.ts.map +1 -1
- package/dist/src/migrations/index.js +3 -1
- package/dist/src/schemas/helpers.d.ts +29 -0
- package/dist/src/schemas/helpers.d.ts.map +1 -0
- package/dist/src/schemas/helpers.js +71 -0
- package/dist/src/{config.d.ts → schemas/v1/schema.d.ts} +1 -12
- package/dist/src/schemas/v1/schema.d.ts.map +1 -0
- package/dist/src/{config.js → schemas/v1/schema.js} +6 -61
- package/dist/src/schemas/v1.1/schema.d.ts +162 -0
- package/dist/src/schemas/v1.1/schema.d.ts.map +1 -0
- package/dist/src/schemas/v1.1/schema.js +54 -0
- package/dist/src/tokens/build.js +1 -1
- package/dist/src/tokens/create/files.d.ts +2 -2
- package/dist/src/tokens/create/files.d.ts.map +1 -1
- package/dist/src/tokens/create/files.js +3 -3
- package/dist/src/tokens/create/generators/$metadata.d.ts +2 -2
- package/dist/src/tokens/create/generators/$metadata.d.ts.map +1 -1
- package/dist/src/tokens/create/generators/$metadata.js +2 -4
- package/dist/src/tokens/create/generators/$themes.d.ts +2 -2
- package/dist/src/tokens/create/generators/$themes.d.ts.map +1 -1
- package/dist/src/tokens/create/generators/$themes.js +7 -10
- package/dist/src/tokens/create/generators/primitives/color-scheme.d.ts +4 -4
- package/dist/src/tokens/create/generators/primitives/color-scheme.d.ts.map +1 -1
- package/dist/src/tokens/create/generators/primitives/color-scheme.js +9 -11
- package/dist/src/tokens/create/generators/semantic/color.d.ts +2 -4
- package/dist/src/tokens/create/generators/semantic/color.d.ts.map +1 -1
- package/dist/src/tokens/create/generators/semantic/color.js +9 -38
- package/dist/src/tokens/create/generators/semantic/style.d.ts +1 -1
- package/dist/src/tokens/create/generators/semantic/style.d.ts.map +1 -1
- package/dist/src/tokens/create/generators/semantic/style.js +78 -41
- package/dist/src/tokens/create/generators/themes/theme.d.ts +2 -2
- package/dist/src/tokens/create/generators/themes/theme.d.ts.map +1 -1
- package/dist/src/tokens/create/generators/themes/theme.js +2 -11
- package/dist/src/tokens/create.d.ts +0 -16
- package/dist/src/tokens/create.d.ts.map +1 -1
- package/dist/src/tokens/create.js +10 -22
- package/dist/src/tokens/format.js +6 -4
- package/dist/src/tokens/generate-config.d.ts +3 -2
- package/dist/src/tokens/generate-config.d.ts.map +1 -1
- package/dist/src/tokens/generate-config.js +10 -36
- package/dist/src/tokens/index.d.ts +2 -1
- package/dist/src/tokens/index.d.ts.map +1 -1
- package/dist/src/tokens/index.js +3 -2
- package/dist/src/tokens/process/configs/color.d.ts +1 -9
- package/dist/src/tokens/process/configs/color.d.ts.map +1 -1
- package/dist/src/tokens/process/configs/color.js +6 -9
- package/dist/src/tokens/process/configs.d.ts +1 -7
- package/dist/src/tokens/process/configs.d.ts.map +1 -1
- package/dist/src/tokens/process/configs.js +3 -24
- package/dist/src/tokens/process/formats/css/color.d.ts.map +1 -1
- package/dist/src/tokens/process/formats/css/color.js +4 -5
- package/dist/src/tokens/process/formats/css/size-mode.d.ts +0 -1
- package/dist/src/tokens/process/formats/css/size-mode.d.ts.map +1 -1
- package/dist/src/tokens/process/formats/css/size-mode.js +1 -1
- package/dist/src/tokens/process/formats/css/size.d.ts +0 -12
- package/dist/src/tokens/process/formats/css/size.d.ts.map +1 -1
- package/dist/src/tokens/process/formats/css/size.js +1 -1
- package/dist/src/tokens/process/output/declarations.d.ts.map +1 -1
- package/dist/src/tokens/process/output/declarations.js +6 -8
- package/dist/src/tokens/process/platform.d.ts +4 -36
- package/dist/src/tokens/process/platform.d.ts.map +1 -1
- package/dist/src/tokens/process/platform.js +8 -50
- package/dist/src/tokens/process/utils/getMultidimensionalThemes.d.ts +2 -3
- package/dist/src/tokens/process/utils/getMultidimensionalThemes.d.ts.map +1 -1
- package/dist/src/tokens/process/utils/getMultidimensionalThemes.js +4 -8
- package/dist/src/tokens/types.d.ts +3 -11
- package/dist/src/tokens/types.d.ts.map +1 -1
- package/dist/src/tokens/types.js +1 -7
- package/dist/src/tokens/utils.d.ts +5 -11
- package/dist/src/tokens/utils.d.ts.map +1 -1
- package/dist/src/tokens/utils.js +8 -13
- package/package.json +7 -3
- package/dist/src/config.d.ts.map +0 -1
- package/dist/src/tokens/create/generators/semantic/color-modes.d.ts +0 -8
- package/dist/src/tokens/create/generators/semantic/color-modes.d.ts.map +0 -1
- package/dist/src/tokens/create/generators/semantic/color-modes.js +0 -26
|
@@ -1,6 +1,49 @@
|
|
|
1
|
+
import { semanticColorMap } from "../../../../colors/types.js";
|
|
2
|
+
import * as R from "ramda";
|
|
1
3
|
//#region src/tokens/create/generators/semantic/style.ts
|
|
2
|
-
function generateSemanticStyle() {
|
|
4
|
+
function generateSemanticStyle(colorNames) {
|
|
3
5
|
return {
|
|
6
|
+
...generateColors(colorNames),
|
|
7
|
+
"border-width": {
|
|
8
|
+
default: {
|
|
9
|
+
$type: "borderWidth",
|
|
10
|
+
$value: "{border-width.1}"
|
|
11
|
+
},
|
|
12
|
+
focus: {
|
|
13
|
+
$type: "borderWidth",
|
|
14
|
+
$value: "{border-width.3}"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"border-radius": {
|
|
18
|
+
sm: {
|
|
19
|
+
$type: "dimension",
|
|
20
|
+
$value: "{border-radius.1}"
|
|
21
|
+
},
|
|
22
|
+
md: {
|
|
23
|
+
$type: "dimension",
|
|
24
|
+
$value: "{border-radius.2}"
|
|
25
|
+
},
|
|
26
|
+
lg: {
|
|
27
|
+
$type: "dimension",
|
|
28
|
+
$value: "{border-radius.3}"
|
|
29
|
+
},
|
|
30
|
+
xl: {
|
|
31
|
+
$type: "dimension",
|
|
32
|
+
$value: "{border-radius.4}"
|
|
33
|
+
},
|
|
34
|
+
default: {
|
|
35
|
+
$type: "dimension",
|
|
36
|
+
$value: "{border-radius.5}"
|
|
37
|
+
},
|
|
38
|
+
full: {
|
|
39
|
+
$type: "dimension",
|
|
40
|
+
$value: "{border-radius.6}"
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
opacity: { disabled: {
|
|
44
|
+
$type: "opacity",
|
|
45
|
+
$value: "{opacity.30}"
|
|
46
|
+
} },
|
|
4
47
|
typography: {
|
|
5
48
|
heading: {
|
|
6
49
|
"2xl": {
|
|
@@ -231,20 +274,6 @@ function generateSemanticStyle() {
|
|
|
231
274
|
}
|
|
232
275
|
}
|
|
233
276
|
},
|
|
234
|
-
opacity: { disabled: {
|
|
235
|
-
$type: "opacity",
|
|
236
|
-
$value: "{opacity.30}"
|
|
237
|
-
} },
|
|
238
|
-
"border-width": {
|
|
239
|
-
default: {
|
|
240
|
-
$type: "borderWidth",
|
|
241
|
-
$value: "{border-width.1}"
|
|
242
|
-
},
|
|
243
|
-
focus: {
|
|
244
|
-
$type: "borderWidth",
|
|
245
|
-
$value: "{border-width.3}"
|
|
246
|
-
}
|
|
247
|
-
},
|
|
248
277
|
shadow: {
|
|
249
278
|
xs: {
|
|
250
279
|
$type: "boxShadow",
|
|
@@ -267,32 +296,6 @@ function generateSemanticStyle() {
|
|
|
267
296
|
$value: "{shadow.500}"
|
|
268
297
|
}
|
|
269
298
|
},
|
|
270
|
-
"border-radius": {
|
|
271
|
-
sm: {
|
|
272
|
-
$type: "dimension",
|
|
273
|
-
$value: "{border-radius.1}"
|
|
274
|
-
},
|
|
275
|
-
md: {
|
|
276
|
-
$type: "dimension",
|
|
277
|
-
$value: "{border-radius.2}"
|
|
278
|
-
},
|
|
279
|
-
lg: {
|
|
280
|
-
$type: "dimension",
|
|
281
|
-
$value: "{border-radius.3}"
|
|
282
|
-
},
|
|
283
|
-
xl: {
|
|
284
|
-
$type: "dimension",
|
|
285
|
-
$value: "{border-radius.4}"
|
|
286
|
-
},
|
|
287
|
-
default: {
|
|
288
|
-
$type: "dimension",
|
|
289
|
-
$value: "{border-radius.5}"
|
|
290
|
-
},
|
|
291
|
-
full: {
|
|
292
|
-
$type: "dimension",
|
|
293
|
-
$value: "{border-radius.6}"
|
|
294
|
-
}
|
|
295
|
-
},
|
|
296
299
|
size: {
|
|
297
300
|
"0": {
|
|
298
301
|
$type: "dimension",
|
|
@@ -377,5 +380,39 @@ function generateSemanticStyle() {
|
|
|
377
380
|
}
|
|
378
381
|
};
|
|
379
382
|
}
|
|
383
|
+
const generateColors = (colorNames) => {
|
|
384
|
+
const semanticColorTokens = colorNames.map((colorName) => [colorName, generateColorScaleTokens(colorName)]);
|
|
385
|
+
return {
|
|
386
|
+
...baseColorTemplate,
|
|
387
|
+
color: {
|
|
388
|
+
...Object.fromEntries(semanticColorTokens),
|
|
389
|
+
...baseColorTemplate.color
|
|
390
|
+
}
|
|
391
|
+
};
|
|
392
|
+
};
|
|
393
|
+
const baseColorTemplate = {
|
|
394
|
+
color: { focus: {
|
|
395
|
+
inner: {
|
|
396
|
+
$type: "color",
|
|
397
|
+
$value: "{color.focus.inner-color}"
|
|
398
|
+
},
|
|
399
|
+
outer: {
|
|
400
|
+
$type: "color",
|
|
401
|
+
$value: "{color.focus.outer-color}"
|
|
402
|
+
}
|
|
403
|
+
} },
|
|
404
|
+
link: { color: { visited: {
|
|
405
|
+
$type: "color",
|
|
406
|
+
$value: "{color.link.visited}"
|
|
407
|
+
} } }
|
|
408
|
+
};
|
|
409
|
+
const generateColorScaleTokens = (colorName) => {
|
|
410
|
+
const colorScale = {};
|
|
411
|
+
for (const [colorSemantic, colorNumber] of R.toPairs(semanticColorMap)) colorScale[colorSemantic] = {
|
|
412
|
+
$type: "color",
|
|
413
|
+
$value: `{color.${colorName}.${colorNumber}}`
|
|
414
|
+
};
|
|
415
|
+
return colorScale;
|
|
416
|
+
};
|
|
380
417
|
//#endregion
|
|
381
418
|
export { generateSemanticStyle };
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare const generateTheme: (
|
|
1
|
+
import type { TokenSet } from '../../../types.js';
|
|
2
|
+
export declare const generateTheme: (colorNames: string[], themeName: string, borderRadius: number) => TokenSet;
|
|
3
3
|
//# sourceMappingURL=theme.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../../../../src/tokens/create/generators/themes/theme.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../../../../src/tokens/create/generators/themes/theme.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAS,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAEzD,eAAO,MAAM,aAAa,GAAI,YAAY,MAAM,EAAE,EAAE,WAAW,MAAM,EAAE,cAAc,MAAM,aA+C1F,CAAC"}
|
|
@@ -1,17 +1,8 @@
|
|
|
1
|
-
import { baseColorNames } from "../../../../colors/colorMetadata.js";
|
|
2
1
|
import { semanticColorMap } from "../../../../colors/types.js";
|
|
3
2
|
import * as R from "ramda";
|
|
4
3
|
//#region src/tokens/create/generators/themes/theme.ts
|
|
5
|
-
const generateTheme = (
|
|
6
|
-
const
|
|
7
|
-
const supportColorNames = Object.keys(colors.support);
|
|
8
|
-
const customColors = [
|
|
9
|
-
...mainColorNames,
|
|
10
|
-
"neutral",
|
|
11
|
-
...supportColorNames,
|
|
12
|
-
...baseColorNames
|
|
13
|
-
];
|
|
14
|
-
const themeColorTokens = Object.fromEntries(customColors.map((colorName) => [colorName, generateColorScaleTokens(colorName, themeName)]));
|
|
4
|
+
const generateTheme = (colorNames, themeName, borderRadius) => {
|
|
5
|
+
const themeColorTokens = Object.fromEntries(colorNames.map((colorName) => [colorName, generateColorScaleTokens(colorName, themeName)]));
|
|
15
6
|
const { color: themeBaseFileColor, ...remainingThemeFile } = generateBase(themeName);
|
|
16
7
|
const themeFile = {
|
|
17
8
|
color: {
|
|
@@ -1,21 +1,5 @@
|
|
|
1
1
|
import type { Theme, TokenSetDimensions, TokenSets } from './types.js';
|
|
2
2
|
export declare const tokenSetDimensions: TokenSetDimensions;
|
|
3
|
-
export declare const cliOptions: {
|
|
4
|
-
readonly outDir: "out-dir";
|
|
5
|
-
readonly clean: "clean";
|
|
6
|
-
readonly tailwind: "tailwind";
|
|
7
|
-
readonly theme: {
|
|
8
|
-
readonly colors: {
|
|
9
|
-
readonly main: "main-colors";
|
|
10
|
-
readonly support: "support-colors";
|
|
11
|
-
readonly neutral: "neutral-color";
|
|
12
|
-
};
|
|
13
|
-
readonly typography: {
|
|
14
|
-
readonly fontFamily: "font-family";
|
|
15
|
-
};
|
|
16
|
-
readonly borderRadius: "border-radius";
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
3
|
export declare const createTokens: (theme: Theme) => Promise<{
|
|
20
4
|
tokenSets: TokenSets;
|
|
21
5
|
}>;
|
|
@@ -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":"AAOA,OAAO,KAAK,EAAE,KAAK,EAAY,kBAAkB,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGjF,eAAO,MAAM,kBAAkB,EAAE,kBAGhC,CAAC;AAEF,eAAO,MAAM,YAAY,GAAU,OAAO,KAAK;;EA8B9C,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { addSeverityColors, toColorNames } from "./utils.js";
|
|
1
2
|
import { generateColorScheme } from "./create/generators/primitives/color-scheme.js";
|
|
2
3
|
import { generateGlobals } from "./create/generators/primitives/globals.js";
|
|
3
4
|
import { generateSize, generateSizeGlobal } from "./create/generators/primitives/size.js";
|
|
4
5
|
import { generateFontSizes, generateTypography } from "./create/generators/primitives/typography.js";
|
|
5
|
-
import {
|
|
6
|
-
import { generateColorModes } from "./create/generators/semantic/color-modes.js";
|
|
6
|
+
import { generateColorTokens } from "./create/generators/semantic/color.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
|
|
@@ -15,23 +15,12 @@ const tokenSetDimensions = {
|
|
|
15
15
|
"large"
|
|
16
16
|
]
|
|
17
17
|
};
|
|
18
|
-
const cliOptions = {
|
|
19
|
-
outDir: "out-dir",
|
|
20
|
-
clean: "clean",
|
|
21
|
-
tailwind: "tailwind",
|
|
22
|
-
theme: {
|
|
23
|
-
colors: {
|
|
24
|
-
main: "main-colors",
|
|
25
|
-
support: "support-colors",
|
|
26
|
-
neutral: "neutral-color"
|
|
27
|
-
},
|
|
28
|
-
typography: { fontFamily: "font-family" },
|
|
29
|
-
borderRadius: "border-radius"
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
18
|
const createTokens = async (theme) => {
|
|
33
|
-
const {
|
|
19
|
+
const { typography, name, borderRadius, overrides } = theme;
|
|
34
20
|
const { colorSchemes, sizeModes } = tokenSetDimensions;
|
|
21
|
+
const colors = addSeverityColors(theme.colors);
|
|
22
|
+
const colorNames = toColorNames(colors);
|
|
23
|
+
const colorTokens = Object.entries(generateColorTokens(colorNames, name));
|
|
35
24
|
return { tokenSets: new Map([
|
|
36
25
|
["primitives/globals", generateGlobals()],
|
|
37
26
|
...sizeModes.map((size) => [`primitives/modes/size/${size}`, generateSize(size)]),
|
|
@@ -40,11 +29,10 @@ const createTokens = async (theme) => {
|
|
|
40
29
|
[`primitives/modes/typography/primary/${name}`, generateTypography(name, typography)],
|
|
41
30
|
[`primitives/modes/typography/secondary/${name}`, generateTypography(name, typography)],
|
|
42
31
|
...colorSchemes.flatMap((scheme) => [[`primitives/modes/color-scheme/${scheme}/${name}`, generateColorScheme(name, scheme, colors, overrides)]]),
|
|
43
|
-
[`themes/${name}`, generateTheme(
|
|
44
|
-
[
|
|
45
|
-
|
|
46
|
-
[`semantic/style`, generateSemanticStyle()]
|
|
32
|
+
[`themes/${name}`, generateTheme(colorNames, name, borderRadius)],
|
|
33
|
+
...colorTokens.map(([colorName, colorSetTokens]) => [`semantic/color/${colorName}`, colorSetTokens]),
|
|
34
|
+
[`semantic/style`, generateSemanticStyle(colorNames)]
|
|
47
35
|
]) };
|
|
48
36
|
};
|
|
49
37
|
//#endregion
|
|
50
|
-
export {
|
|
38
|
+
export { createTokens, tokenSetDimensions };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { colorNamesByCategory } from "./utils.js";
|
|
3
|
-
import { processThemeObject } from "./process/utils/getMultidimensionalThemes.js";
|
|
1
|
+
import { toColorNames } from "./utils.js";
|
|
4
2
|
import { processPlatform } from "./process/platform.js";
|
|
3
|
+
import { processThemeObject } from "./process/utils/getMultidimensionalThemes.js";
|
|
5
4
|
import { createThemeCSSFiles } from "./process/output/theme.js";
|
|
6
5
|
import { generate$Themes } from "./create/generators/$themes.js";
|
|
6
|
+
import { createTokens, tokenSetDimensions } from "./create.js";
|
|
7
7
|
import * as R from "ramda";
|
|
8
8
|
//#region src/tokens/format.ts
|
|
9
9
|
const formatTokens = async (options) => {
|
|
@@ -14,10 +14,12 @@ const formatTokens = async (options) => {
|
|
|
14
14
|
});
|
|
15
15
|
};
|
|
16
16
|
const formatTheme = async (themeConfig) => {
|
|
17
|
+
const themeNames = [themeConfig.name];
|
|
18
|
+
const colorNames = toColorNames(themeConfig.colors);
|
|
17
19
|
const { tokenSets } = await createTokens(themeConfig);
|
|
18
20
|
return await formatTokens({
|
|
19
21
|
tokenSets,
|
|
20
|
-
processed$themes: (await generate$Themes(tokenSetDimensions,
|
|
22
|
+
processed$themes: (await generate$Themes(tokenSetDimensions, themeNames, colorNames)).map(processThemeObject),
|
|
21
23
|
verbose: false
|
|
22
24
|
});
|
|
23
25
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { CreateConfigSchema } from '../
|
|
2
|
-
|
|
1
|
+
import type { CreateConfigSchema } from '../schemas/v1.1/schema.js';
|
|
2
|
+
type GenerateConfigOptions = {
|
|
3
3
|
tokensDir: string;
|
|
4
4
|
outFile?: string;
|
|
5
5
|
};
|
|
@@ -7,4 +7,5 @@ export type GenerateConfigOptions = {
|
|
|
7
7
|
* Generates a config file from existing design tokens
|
|
8
8
|
*/
|
|
9
9
|
export declare function generateConfigFromTokens(options: GenerateConfigOptions): Promise<CreateConfigSchema>;
|
|
10
|
+
export {};
|
|
10
11
|
//# sourceMappingURL=generate-config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generate-config.d.ts","sourceRoot":"","sources":["../../../src/tokens/generate-config.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"generate-config.d.ts","sourceRoot":"","sources":["../../../src/tokens/generate-config.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AA0LpE,KAAK,qBAAqB,GAAG;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;GAEG;AACH,wBAAsB,wBAAwB,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CA8D1G"}
|
|
@@ -96,40 +96,21 @@ function extractFontFamilyFromPrimitives(typographyConfig, themeName) {
|
|
|
96
96
|
if (typeof fontFamily === "object" && "$value" in fontFamily) return fontFamily.$value;
|
|
97
97
|
}
|
|
98
98
|
/**
|
|
99
|
-
*
|
|
99
|
+
* Extracts colors from the theme tokens, excluding reserved colors and extracting base colors from color scales.
|
|
100
100
|
*/
|
|
101
|
-
function
|
|
102
|
-
const
|
|
103
|
-
const support = {};
|
|
104
|
-
let neutral = null;
|
|
105
|
-
const builtInColors = [
|
|
106
|
-
"neutral",
|
|
107
|
-
"info",
|
|
108
|
-
"success",
|
|
109
|
-
"warning",
|
|
110
|
-
"danger"
|
|
111
|
-
];
|
|
101
|
+
function extractColors(themeTokens, themeName) {
|
|
102
|
+
const colors = {};
|
|
112
103
|
const specialKeys = ["link"];
|
|
113
104
|
const themeColors = themeTokens[themeName];
|
|
114
|
-
if (!themeColors) return
|
|
115
|
-
main,
|
|
116
|
-
support,
|
|
117
|
-
neutral
|
|
118
|
-
};
|
|
105
|
+
if (!themeColors) return colors;
|
|
119
106
|
for (const [colorName, colorValue] of Object.entries(themeColors)) {
|
|
120
107
|
if (specialKeys.includes(colorName)) continue;
|
|
121
108
|
if (typeof colorValue === "object" && !("$value" in colorValue)) {
|
|
122
109
|
const baseColor = extractBaseColor(colorValue);
|
|
123
|
-
if (baseColor)
|
|
124
|
-
else if (builtInColors.includes(colorName)) {} else if (colorName === "accent") main[colorName] = baseColor;
|
|
125
|
-
else support[colorName] = baseColor;
|
|
110
|
+
if (baseColor) colors[colorName] = baseColor;
|
|
126
111
|
}
|
|
127
112
|
}
|
|
128
|
-
return
|
|
129
|
-
main,
|
|
130
|
-
support,
|
|
131
|
-
neutral
|
|
132
|
-
};
|
|
113
|
+
return colors;
|
|
133
114
|
}
|
|
134
115
|
/**
|
|
135
116
|
* Generates a config file from existing design tokens
|
|
@@ -149,26 +130,19 @@ async function generateConfigFromTokens(options) {
|
|
|
149
130
|
const themeTokens = await readThemeTokens(tokensDir, themeName);
|
|
150
131
|
const themeConfig = await readThemeConfig(tokensDir, themeName);
|
|
151
132
|
const typographyConfig = await readTypographyConfig(tokensDir, themeName);
|
|
152
|
-
const
|
|
153
|
-
if (
|
|
154
|
-
if (!neutral) {
|
|
133
|
+
const colors = extractColors(themeTokens, themeName);
|
|
134
|
+
if (!colors.neutral) {
|
|
155
135
|
console.warn(pc.yellow(`\nWarning: No neutral color found for theme ${themeName}`));
|
|
156
136
|
continue;
|
|
157
137
|
}
|
|
158
138
|
const borderRadius = extractBorderRadius(themeConfig);
|
|
159
139
|
const fontFamily = extractFontFamily(themeConfig) ?? extractFontFamilyFromPrimitives(typographyConfig, themeName);
|
|
160
140
|
config.themes[themeName] = {
|
|
161
|
-
colors
|
|
162
|
-
main,
|
|
163
|
-
support,
|
|
164
|
-
neutral
|
|
165
|
-
},
|
|
141
|
+
colors,
|
|
166
142
|
borderRadius,
|
|
167
143
|
typography: fontFamily ? { fontFamily } : void 0
|
|
168
144
|
};
|
|
169
|
-
console.log(`\n✅
|
|
170
|
-
console.log(`\n✅ Support colors: ${Object.keys(support).map((c) => pc.cyan(c)).join(", ") || pc.dim("none")}`);
|
|
171
|
-
console.log(`\n✅ Neutral: ${pc.cyan(neutral)}`);
|
|
145
|
+
console.log(`\n✅ Colors: ${Object.keys(colors).map((c) => pc.cyan(c)).join(", ") || pc.dim("none")}`);
|
|
172
146
|
if (borderRadius !== void 0) console.log(`\n✅ Border radius: ${pc.cyan(String(borderRadius))}`);
|
|
173
147
|
if (fontFamily) console.log(`\n✅ Font family: ${pc.cyan(fontFamily)}`);
|
|
174
148
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { cliOptions
|
|
1
|
+
export { deprecatedCLIOptions as cliOptions } from '../schemas/helpers.js';
|
|
2
|
+
export { createTokens } from './create.js';
|
|
2
3
|
export { formatThemeCSS, formatTokens } from './format.js';
|
|
3
4
|
export type { Theme as CreateTokensOptions } from './types.js';
|
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tokens/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tokens/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,IAAI,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAC3E,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3D,YAAY,EAAE,KAAK,IAAI,mBAAmB,EAAE,MAAM,YAAY,CAAC"}
|
package/dist/src/tokens/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { deprecatedCLIOptions } from "../schemas/helpers.js";
|
|
2
|
+
import { createTokens } from "./create.js";
|
|
2
3
|
import { formatThemeCSS, formatTokens } from "./format.js";
|
|
3
|
-
export { cliOptions, createTokens, formatThemeCSS, formatTokens };
|
|
4
|
+
export { deprecatedCLIOptions as cliOptions, createTokens, formatThemeCSS, formatTokens };
|
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
import type { BuiltInColors, ColorCategories } from '../../types.js';
|
|
2
1
|
import { type GetStyleDictionaryConfig } from './shared.js';
|
|
3
2
|
export declare const colorSchemeVariables: GetStyleDictionaryConfig;
|
|
4
|
-
|
|
5
|
-
category: ColorCategories;
|
|
6
|
-
} | {
|
|
7
|
-
category: 'builtin';
|
|
8
|
-
color: BuiltInColors;
|
|
9
|
-
};
|
|
10
|
-
export declare const colorCategoryVariables: (opts: ColorCategoryOpts) => GetStyleDictionaryConfig;
|
|
11
|
-
export {};
|
|
3
|
+
export declare const colorVariables: GetStyleDictionaryConfig;
|
|
12
4
|
//# sourceMappingURL=color.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../../../../src/tokens/process/configs/color.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../../../../src/tokens/process/configs/color.ts"],"names":[],"mappings":"AAKA,OAAO,EAAkB,KAAK,wBAAwB,EAAU,MAAM,aAAa,CAAC;AAEpF,eAAO,MAAM,oBAAoB,EAAE,wBA8BlC,CAAC;AAEF,eAAO,MAAM,cAAc,EAAE,wBAqC5B,CAAC"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isSemanticColorToken, pathStartsWithOneOf } from "../../utils.js";
|
|
2
2
|
import { dsTransformers } from "./shared.js";
|
|
3
3
|
import { formats } from "../formats/css.js";
|
|
4
4
|
import { buildOptions } from "../platform.js";
|
|
5
|
-
import * as R from "ramda";
|
|
6
5
|
//#region src/tokens/process/configs/color.ts
|
|
7
6
|
const colorSchemeVariables = ({ "color-scheme": colorScheme = "light", theme }) => {
|
|
8
7
|
return {
|
|
@@ -18,16 +17,14 @@ const colorSchemeVariables = ({ "color-scheme": colorScheme = "light", theme })
|
|
|
18
17
|
files: [{
|
|
19
18
|
destination: `color-scheme/${colorScheme}.css`,
|
|
20
19
|
format: formats.colorScheme.name,
|
|
21
|
-
filter: (token) =>
|
|
20
|
+
filter: (token) => pathStartsWithOneOf(["color"], token) || token.path[1] === "color"
|
|
22
21
|
}],
|
|
23
22
|
options: { outputReferences: false }
|
|
24
23
|
} }
|
|
25
24
|
};
|
|
26
25
|
};
|
|
27
|
-
const
|
|
28
|
-
const
|
|
29
|
-
const color = category === "builtin" ? opts.color : permutation[`${category}-color`];
|
|
30
|
-
if (!color) throw new Error(category === "builtin" ? `Missing color for built-in color ${opts.color}` : `Missing color for category ${category}`);
|
|
26
|
+
const colorVariables = ({ "color-scheme": colorScheme, theme, ...permutation }) => {
|
|
27
|
+
const color = permutation.color;
|
|
31
28
|
return {
|
|
32
29
|
preprocessors: ["tokens-studio"],
|
|
33
30
|
platforms: { css: {
|
|
@@ -41,11 +38,11 @@ const colorCategoryVariables = (opts) => ({ "color-scheme": colorScheme, theme,
|
|
|
41
38
|
files: [{
|
|
42
39
|
destination: `color/${color}.css`,
|
|
43
40
|
format: formats.colorCategory.name,
|
|
44
|
-
filter: (token) =>
|
|
41
|
+
filter: (token) => isSemanticColorToken(token, color)
|
|
45
42
|
}],
|
|
46
43
|
options: { outputReferences: true }
|
|
47
44
|
} }
|
|
48
45
|
};
|
|
49
46
|
};
|
|
50
47
|
//#endregion
|
|
51
|
-
export {
|
|
48
|
+
export { colorSchemeVariables, colorVariables };
|
|
@@ -3,13 +3,7 @@ import type { GetStyleDictionaryConfig } from './configs/shared.js';
|
|
|
3
3
|
import { type ProcessedThemeObject } from './utils/getMultidimensionalThemes.js';
|
|
4
4
|
export declare const configs: {
|
|
5
5
|
colorSchemeVariables: GetStyleDictionaryConfig;
|
|
6
|
-
|
|
7
|
-
supportColorVariables: GetStyleDictionaryConfig;
|
|
8
|
-
neutralColorVariables: GetStyleDictionaryConfig;
|
|
9
|
-
successColorVariables: GetStyleDictionaryConfig;
|
|
10
|
-
dangerColorVariables: GetStyleDictionaryConfig;
|
|
11
|
-
warningColorVariables: GetStyleDictionaryConfig;
|
|
12
|
-
infoColorVariables: GetStyleDictionaryConfig;
|
|
6
|
+
colorVariables: GetStyleDictionaryConfig;
|
|
13
7
|
sizeModeVariables: GetStyleDictionaryConfig;
|
|
14
8
|
sizeVariables: GetStyleDictionaryConfig;
|
|
15
9
|
typographyVariables: GetStyleDictionaryConfig;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configs.d.ts","sourceRoot":"","sources":["../../../../src/tokens/process/configs.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAInG,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAQpE,OAAO,EAA6B,KAAK,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAa5G,eAAO,MAAM,OAAO
|
|
1
|
+
{"version":3,"file":"configs.d.ts","sourceRoot":"","sources":["../../../../src/tokens/process/configs.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,kBAAkB,EAAE,2BAA2B,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAInG,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAQpE,OAAO,EAA6B,KAAK,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAa5G,eAAO,MAAM,OAAO;;;;;;;;CAQnB,CAAC;AAEF,eAAO,MAAM,4BAA4B,GACvC,WAAW,wBAAwB,EACnC,kBAAkB,oBAAoB,EAAE,EACxC,YAAY,cAAc,EAAE,EAC5B,SAAS,kBAAkB,KAC1B,2BAA2B,EAoD7B,CAAC"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { traverseObj } from "../utils.js";
|
|
2
2
|
import { resolveMath, sizeRem, typographyName, unitless } from "./transformers.js";
|
|
3
3
|
import { formats } from "./formats/css.js";
|
|
4
|
-
import {
|
|
4
|
+
import { colorSchemeVariables, colorVariables } from "./configs/color.js";
|
|
5
5
|
import { semanticVariables } from "./configs/semantic.js";
|
|
6
6
|
import { sizeVariables } from "./configs/size.js";
|
|
7
7
|
import { sizeModeVariables } from "./configs/size-mode.js";
|
|
8
8
|
import { typeScaleVariables } from "./configs/type-scale.js";
|
|
9
9
|
import { typographyVariables } from "./configs/typography.js";
|
|
10
|
-
import { getMultidimensionalThemes } from "./utils/getMultidimensionalThemes.js";
|
|
11
10
|
import { buildOptions } from "./platform.js";
|
|
11
|
+
import { getMultidimensionalThemes } from "./utils/getMultidimensionalThemes.js";
|
|
12
12
|
import * as R from "ramda";
|
|
13
13
|
import StyleDictionary from "style-dictionary";
|
|
14
14
|
import { register } from "@tokens-studio/sd-transforms";
|
|
@@ -21,28 +21,7 @@ StyleDictionary.registerTransform(unitless);
|
|
|
21
21
|
for (const format of Object.values(formats)) StyleDictionary.registerFormat(format);
|
|
22
22
|
const configs = {
|
|
23
23
|
colorSchemeVariables,
|
|
24
|
-
|
|
25
|
-
supportColorVariables: colorCategoryVariables({ category: "support" }),
|
|
26
|
-
neutralColorVariables: colorCategoryVariables({
|
|
27
|
-
category: "builtin",
|
|
28
|
-
color: "neutral"
|
|
29
|
-
}),
|
|
30
|
-
successColorVariables: colorCategoryVariables({
|
|
31
|
-
category: "builtin",
|
|
32
|
-
color: "success"
|
|
33
|
-
}),
|
|
34
|
-
dangerColorVariables: colorCategoryVariables({
|
|
35
|
-
category: "builtin",
|
|
36
|
-
color: "danger"
|
|
37
|
-
}),
|
|
38
|
-
warningColorVariables: colorCategoryVariables({
|
|
39
|
-
category: "builtin",
|
|
40
|
-
color: "warning"
|
|
41
|
-
}),
|
|
42
|
-
infoColorVariables: colorCategoryVariables({
|
|
43
|
-
category: "builtin",
|
|
44
|
-
color: "info"
|
|
45
|
-
}),
|
|
24
|
+
colorVariables,
|
|
46
25
|
sizeModeVariables,
|
|
47
26
|
sizeVariables,
|
|
48
27
|
typographyVariables,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../../../../../src/tokens/process/formats/css/color.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../../../../../src/tokens/process/formats/css/color.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAYrD,eAAO,MAAM,WAAW,EAAE,MA2CzB,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,MAwC3B,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { isColorCategoryToken, isGlobalColorToken, isSemanticToken } from "../../../utils.js";
|
|
1
|
+
import { isSemanticToken } from "../../../utils.js";
|
|
3
2
|
import { buildOptions } from "../../platform.js";
|
|
4
3
|
import * as R from "ramda";
|
|
5
4
|
import { createPropertyFormatter } from "style-dictionary/utils";
|
|
@@ -23,7 +22,7 @@ const colorScheme = {
|
|
|
23
22
|
usesDtcg
|
|
24
23
|
});
|
|
25
24
|
const colorSchemeProperty = colorScheme_ === "dark" || colorScheme_ === "light" ? `\n color-scheme: ${colorScheme_};\n` : "";
|
|
26
|
-
const content = `{\n${allTokens.filter(R.allPass([R.anyPass([isSemanticToken
|
|
25
|
+
const content = `{\n${allTokens.filter(R.allPass([R.anyPass([isSemanticToken])])).map((token) => ({
|
|
27
26
|
token,
|
|
28
27
|
formatted: format(token)
|
|
29
28
|
})).map(R.view(R.lensProp("formatted"))).join("\n")}\n${colorSchemeProperty}}\n`;
|
|
@@ -44,10 +43,10 @@ const colorCategory = {
|
|
|
44
43
|
usesDtcg
|
|
45
44
|
}), (token) => ({
|
|
46
45
|
...token,
|
|
47
|
-
name: token.name.replace(
|
|
46
|
+
name: token.name.replace(`color-${token.path[1]}-`, "color-"),
|
|
48
47
|
original: {
|
|
49
48
|
...token.original,
|
|
50
|
-
$value:
|
|
49
|
+
$value: `{${token.path.join(".")}}`
|
|
51
50
|
}
|
|
52
51
|
}));
|
|
53
52
|
const formattedMap = dictionary.allTokens.map((token) => ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"size-mode.d.ts","sourceRoot":"","sources":["../../../../../../src/tokens/process/formats/css/size-mode.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAerD,eAAO,MAAM,QAAQ,EAAE,MAsDtB,CAAC
|
|
1
|
+
{"version":3,"file":"size-mode.d.ts","sourceRoot":"","sources":["../../../../../../src/tokens/process/formats/css/size-mode.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAerD,eAAO,MAAM,QAAQ,EAAE,MAsDtB,CAAC"}
|
|
@@ -1,18 +1,6 @@
|
|
|
1
1
|
import type { TransformedToken } from 'style-dictionary';
|
|
2
2
|
import type { Format } from 'style-dictionary/types';
|
|
3
3
|
export declare const isInlineTokens: (t: TransformedToken) => boolean;
|
|
4
|
-
/**
|
|
5
|
-
* Overrides the default sizing formula with a custom one that supports [round()](https://developer.mozilla.org/en-US/docs/Web/CSS/round) if supported.
|
|
6
|
-
*
|
|
7
|
-
* @param format - Function to format a token into a CSS property string.
|
|
8
|
-
* @param tokens - Array of transformed tokens to format.
|
|
9
|
-
* @returns Object with formatted CSS strings for calc and round.
|
|
10
|
-
*/
|
|
11
|
-
export declare const overrideSizingFormula: (format: (t: TransformedToken) => string, token: TransformedToken) => {
|
|
12
|
-
name: string;
|
|
13
|
-
round: string;
|
|
14
|
-
calc: string;
|
|
15
|
-
};
|
|
16
4
|
export declare const sizingTemplate: ({ round, calc }: {
|
|
17
5
|
round: string[];
|
|
18
6
|
calc: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"size.d.ts","sourceRoot":"","sources":["../../../../../../src/tokens/process/formats/css/size.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AASrD,eAAO,MAAM,cAAc,MAJY,gBAAgB,YAI+C,CAAC;
|
|
1
|
+
{"version":3,"file":"size.d.ts","sourceRoot":"","sources":["../../../../../../src/tokens/process/formats/css/size.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACzD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AASrD,eAAO,MAAM,cAAc,MAJY,gBAAgB,YAI+C,CAAC;AAoDvG,eAAO,MAAM,cAAc,GAAI,iBAAiB;IAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,CAAA;CAAE,WAOlF,CAAC;AAEF,eAAO,MAAM,IAAI,EAAE,MAyClB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"declarations.d.ts","sourceRoot":"","sources":["../../../../../src/tokens/process/output/declarations.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"declarations.d.ts","sourceRoot":"","sources":["../../../../../src/tokens/process/output/declarations.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAkB,KAAK,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAElG,eAAO,MAAM,iBAAiB,QAA2B,CAAC;AAE1D,eAAO,MAAM,0BAA0B,GAAI,kBAAkB,oBAAoB,EAAE,KAAG,UAAU,EAa/F,CAAC"}
|