@digdir/designsystemet 1.0.7 → 1.0.8
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/config.d.ts +12 -0
- package/dist/bin/config.d.ts.map +1 -0
- package/dist/bin/config.js +516 -0
- package/dist/bin/designsystemet.js +3392 -3327
- package/dist/config.schema.json +1 -0
- package/dist/src/config.d.ts +25 -14
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +49 -6
- package/dist/src/index.js +45 -18
- package/dist/src/migrations/beta-to-v1.js +9 -2
- package/dist/src/migrations/codemods/css/run.js +9 -2
- package/dist/src/migrations/color-rename-next49.js +9 -2
- package/dist/src/migrations/index.js +9 -2
- package/dist/src/scripts/createJsonSchema.js +10 -5
- package/dist/src/scripts/update-template.js +9 -2
- package/dist/src/tokens/build.d.ts +1 -1
- package/dist/src/tokens/build.d.ts.map +1 -1
- package/dist/src/tokens/build.js +54 -32
- package/dist/src/tokens/create/generators/$designsystemet.js +3 -3
- package/dist/src/tokens/create/write.js +12 -5
- package/dist/src/tokens/format.d.ts +1 -1
- package/dist/src/tokens/format.d.ts.map +1 -1
- package/dist/src/tokens/format.js +45 -18
- package/dist/src/tokens/index.js +45 -18
- package/dist/src/tokens/process/configs/color.js +12 -10
- package/dist/src/tokens/process/configs/semantic.js +11 -9
- package/dist/src/tokens/process/configs/storefront.js +11 -1
- package/dist/src/tokens/process/configs/typography.js +11 -9
- package/dist/src/tokens/process/configs.js +13 -26
- package/dist/src/tokens/process/formats/css/color.js +3 -1
- package/dist/src/tokens/process/formats/css.js +3 -1
- package/dist/src/tokens/process/formats/js-tokens.js +11 -1
- package/dist/src/tokens/process/platform.d.ts +3 -5
- package/dist/src/tokens/process/platform.d.ts.map +1 -1
- package/dist/src/tokens/process/platform.js +41 -14
- package/dist/src/tokens/process/theme.js +3 -3
- package/dist/src/tokens/process/utils/getMultidimensionalThemes.js +5 -4
- package/dist/src/tokens/types.d.ts +2 -2
- package/dist/src/tokens/types.d.ts.map +1 -1
- package/dist/src/tokens/utils.d.ts +2 -2
- package/dist/src/tokens/utils.d.ts.map +1 -1
- package/dist/src/tokens/utils.js +11 -1
- package/dist/src/utils.d.ts +1 -1
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +9 -2
- package/package.json +3 -3
|
@@ -28,18 +28,25 @@ var writeFile = async (path2, data, dry) => {
|
|
|
28
28
|
throw error;
|
|
29
29
|
});
|
|
30
30
|
};
|
|
31
|
-
var readFile = async (path2, dry) => {
|
|
31
|
+
var readFile = async (path2, dry, allowFileNotFound) => {
|
|
32
32
|
if (dry) {
|
|
33
33
|
console.log(`${chalk.blue("readFile")} ${path2}`);
|
|
34
34
|
return Promise.resolve("");
|
|
35
35
|
}
|
|
36
|
-
|
|
36
|
+
try {
|
|
37
|
+
return await fs.readFile(path2, "utf-8");
|
|
38
|
+
} catch (error) {
|
|
39
|
+
if (allowFileNotFound && error.code === "ENOENT") {
|
|
40
|
+
return "";
|
|
41
|
+
}
|
|
42
|
+
throw error;
|
|
43
|
+
}
|
|
37
44
|
};
|
|
38
45
|
|
|
39
46
|
// package.json
|
|
40
47
|
var package_default = {
|
|
41
48
|
name: "@digdir/designsystemet",
|
|
42
|
-
version: "1.0.
|
|
49
|
+
version: "1.0.8",
|
|
43
50
|
description: "CLI for Designsystemet",
|
|
44
51
|
author: "Designsystemet team",
|
|
45
52
|
engines: {
|
|
@@ -89,8 +96,8 @@ var package_default = {
|
|
|
89
96
|
test: "pnpm test:tokens-create-and-build-options && pnpm test:tokens-create-and-build-config",
|
|
90
97
|
"digdir:tokens-create": "pnpm run designsystemet tokens create --config ./configs/digdir.config.json",
|
|
91
98
|
"update:template": "tsx ./src/scripts/update-template.ts",
|
|
92
|
-
"update:
|
|
93
|
-
verify: "pnpm test && pnpm update:template && pnpm update:
|
|
99
|
+
"update:theme-digdir": "pnpm digdir:tokens-create && tsx ./src/scripts/update-design-tokens.ts",
|
|
100
|
+
verify: "pnpm test && pnpm update:template && pnpm update:theme-digdir && pnpm build:tokens"
|
|
94
101
|
},
|
|
95
102
|
dependencies: {
|
|
96
103
|
"@commander-js/extra-typings": "^13.1.0",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type FormatOptions } from './process/platform.js';
|
|
2
2
|
import type { Theme } from './types.js';
|
|
3
|
-
export declare const formatTokens: (options: Omit<FormatOptions, "
|
|
3
|
+
export declare const formatTokens: (options: Omit<FormatOptions, "type">) => Promise<import("./process/platform.js").ProcessReturn>;
|
|
4
4
|
export declare const formatTheme: (themeConfig: Theme) => Promise<import("./process/platform.js").ProcessReturn>;
|
|
5
5
|
/**
|
|
6
6
|
* Formats a theme configuration into CSS.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../src/tokens/format.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,aAAa,EAAmB,MAAM,uBAAuB,CAAC;AAE5E,OAAO,KAAK,EAAc,KAAK,EAAE,MAAM,YAAY,CAAC;AAEpD,eAAO,MAAM,YAAY,GAAU,SAAS,IAAI,CAAC,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../../../src/tokens/format.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,aAAa,EAAmB,MAAM,uBAAuB,CAAC;AAE5E,OAAO,KAAK,EAAc,KAAK,EAAE,MAAM,YAAY,CAAC;AAEpD,eAAO,MAAM,YAAY,GAAU,SAAS,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC,2DAOtE,CAAC;AAEF,eAAO,MAAM,WAAW,GAAU,aAAa,KAAK,2DAYnD,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,cAAc,GAAU,aAAa,KAAK,oBAItD,CAAC"}
|
|
@@ -2457,7 +2457,9 @@ function isGlobalColorToken(token) {
|
|
|
2457
2457
|
}
|
|
2458
2458
|
function isColorCategoryToken(token, category) {
|
|
2459
2459
|
if (!category) {
|
|
2460
|
-
return
|
|
2460
|
+
return Object.keys(colorCategories).some(
|
|
2461
|
+
(colorCategory2) => isColorCategoryToken(token, colorCategory2)
|
|
2462
|
+
);
|
|
2461
2463
|
}
|
|
2462
2464
|
return R7.startsWith(["color", category], token.path);
|
|
2463
2465
|
}
|
|
@@ -2794,7 +2796,7 @@ var colorCategoryVariables = (opts) => ({ "color-scheme": colorScheme2, theme, .
|
|
|
2794
2796
|
);
|
|
2795
2797
|
}
|
|
2796
2798
|
const layer = `ds.theme.color`;
|
|
2797
|
-
const isRootColor = color === buildOptions?.
|
|
2799
|
+
const isRootColor = color === buildOptions?.defaultColor;
|
|
2798
2800
|
const selector = isRootColor ? `:root, [data-color-scheme], [data-color="${color}"]` : `[data-color="${color}"], [data-color-scheme][data-color="${color}"]`;
|
|
2799
2801
|
const config = {
|
|
2800
2802
|
preprocessors: ["tokens-studio"],
|
|
@@ -3038,8 +3040,7 @@ function processThemeObject(theme) {
|
|
|
3038
3040
|
}
|
|
3039
3041
|
function groupThemes(themes) {
|
|
3040
3042
|
const groups = {};
|
|
3041
|
-
for (const
|
|
3042
|
-
const theme = processThemeObject(rawTheme);
|
|
3043
|
+
for (const theme of themes) {
|
|
3043
3044
|
if (theme.group) {
|
|
3044
3045
|
const groupKey = theme.group;
|
|
3045
3046
|
groups[groupKey] = [...groups[groupKey] ?? [], theme];
|
|
@@ -3190,9 +3191,12 @@ var initResult = {
|
|
|
3190
3191
|
};
|
|
3191
3192
|
var buildOptions;
|
|
3192
3193
|
var sd = new StyleDictionary2();
|
|
3193
|
-
var getCustomColors = (processed$themes) => processed$themes.filter(
|
|
3194
|
-
(x
|
|
3195
|
-
|
|
3194
|
+
var getCustomColors = (processed$themes, colorGroups) => processed$themes.filter((x) => {
|
|
3195
|
+
if (!x.group) {
|
|
3196
|
+
return false;
|
|
3197
|
+
}
|
|
3198
|
+
return colorGroups.includes(x.group);
|
|
3199
|
+
}).map((x) => x.name);
|
|
3196
3200
|
var buildConfigs = {
|
|
3197
3201
|
typography: { getConfig: configs.typographyVariables, dimensions: ["typography"] },
|
|
3198
3202
|
"color-scheme": { getConfig: configs.colorSchemeVariables, dimensions: ["color-scheme"] },
|
|
@@ -3233,17 +3237,40 @@ var buildConfigs = {
|
|
|
3233
3237
|
// },
|
|
3234
3238
|
};
|
|
3235
3239
|
async function processPlatform(options) {
|
|
3236
|
-
const {
|
|
3240
|
+
const { type, $themes } = options;
|
|
3237
3241
|
const platform = "css";
|
|
3238
|
-
const tokenSets =
|
|
3239
|
-
const tokensDir =
|
|
3242
|
+
const tokenSets = type === "format" ? options.tokenSets : void 0;
|
|
3243
|
+
const tokensDir = type === "build" ? options.tokensDir : void 0;
|
|
3244
|
+
const UNSAFE_DEFAULT_COLOR = process.env.UNSAFE_DEFAULT_COLOR ?? "";
|
|
3245
|
+
if (UNSAFE_DEFAULT_COLOR) {
|
|
3246
|
+
console.warn(
|
|
3247
|
+
chalk2.yellow(
|
|
3248
|
+
`
|
|
3249
|
+
\u26A0\uFE0F UNSAFE_DEFAULT_COLOR is set to ${chalk2.blue(UNSAFE_DEFAULT_COLOR)}. This will override the default color.`
|
|
3250
|
+
)
|
|
3251
|
+
);
|
|
3252
|
+
}
|
|
3253
|
+
const UNSAFE_COLOR_GROUPS = Array.from(process.env.UNSAFE_COLOR_GROUPS?.split(",") ?? []);
|
|
3254
|
+
if (UNSAFE_COLOR_GROUPS.length > 0) {
|
|
3255
|
+
console.warn(
|
|
3256
|
+
chalk2.yellow(
|
|
3257
|
+
`
|
|
3258
|
+
\u26A0\uFE0F UNSAFE_COLOR_GROUPS is set to ${chalk2.blue(`[${UNSAFE_COLOR_GROUPS.join(", ")}]`)}. This will override the default color groups.`
|
|
3259
|
+
)
|
|
3260
|
+
);
|
|
3261
|
+
}
|
|
3262
|
+
const colorGroups = UNSAFE_COLOR_GROUPS.length > 0 ? UNSAFE_COLOR_GROUPS : [colorCategories.main, colorCategories.support].map((c) => `${c}-color`);
|
|
3240
3263
|
buildOptions = options;
|
|
3264
|
+
buildOptions.defaultColor = UNSAFE_DEFAULT_COLOR;
|
|
3241
3265
|
const processed$themes = $themes.map(processThemeObject).filter((theme) => R18.not(theme.group === "size" && theme.name !== "medium"));
|
|
3242
|
-
const customColors = getCustomColors(processed$themes);
|
|
3243
|
-
if (!buildOptions.
|
|
3266
|
+
const customColors = getCustomColors(processed$themes, colorGroups);
|
|
3267
|
+
if (!buildOptions.defaultColor) {
|
|
3244
3268
|
const firstMainColor = R18.head(customColors);
|
|
3245
|
-
buildOptions.
|
|
3246
|
-
|
|
3269
|
+
buildOptions.defaultColor = firstMainColor;
|
|
3270
|
+
}
|
|
3271
|
+
if (buildOptions.defaultColor) {
|
|
3272
|
+
console.log(`
|
|
3273
|
+
\u{1F3A8} Using ${chalk2.blue(buildOptions.defaultColor)} as default color`);
|
|
3247
3274
|
}
|
|
3248
3275
|
const buildAndSdConfigs = R18.map((buildConfig) => {
|
|
3249
3276
|
const sdConfigs = getConfigsForThemeDimensions(buildConfig.getConfig, processed$themes, buildConfig.dimensions, {
|
|
@@ -3341,7 +3368,7 @@ import chalk3 from "chalk";
|
|
|
3341
3368
|
// package.json
|
|
3342
3369
|
var package_default = {
|
|
3343
3370
|
name: "@digdir/designsystemet",
|
|
3344
|
-
version: "1.0.
|
|
3371
|
+
version: "1.0.8",
|
|
3345
3372
|
description: "CLI for Designsystemet",
|
|
3346
3373
|
author: "Designsystemet team",
|
|
3347
3374
|
engines: {
|
|
@@ -3391,8 +3418,8 @@ var package_default = {
|
|
|
3391
3418
|
test: "pnpm test:tokens-create-and-build-options && pnpm test:tokens-create-and-build-config",
|
|
3392
3419
|
"digdir:tokens-create": "pnpm run designsystemet tokens create --config ./configs/digdir.config.json",
|
|
3393
3420
|
"update:template": "tsx ./src/scripts/update-template.ts",
|
|
3394
|
-
"update:
|
|
3395
|
-
verify: "pnpm test && pnpm update:template && pnpm update:
|
|
3421
|
+
"update:theme-digdir": "pnpm digdir:tokens-create && tsx ./src/scripts/update-design-tokens.ts",
|
|
3422
|
+
verify: "pnpm test && pnpm update:template && pnpm update:theme-digdir && pnpm build:tokens"
|
|
3396
3423
|
},
|
|
3397
3424
|
dependencies: {
|
|
3398
3425
|
"@commander-js/extra-typings": "^13.1.0",
|
|
@@ -3505,7 +3532,7 @@ ${fileHeader2}
|
|
|
3505
3532
|
// src/tokens/format.ts
|
|
3506
3533
|
var formatTokens = async (options) => {
|
|
3507
3534
|
const processedBuilds = await processPlatform({
|
|
3508
|
-
|
|
3535
|
+
type: "format",
|
|
3509
3536
|
...options
|
|
3510
3537
|
});
|
|
3511
3538
|
return processedBuilds;
|
package/dist/src/tokens/index.js
CHANGED
|
@@ -2472,7 +2472,9 @@ function isGlobalColorToken(token) {
|
|
|
2472
2472
|
}
|
|
2473
2473
|
function isColorCategoryToken(token, category) {
|
|
2474
2474
|
if (!category) {
|
|
2475
|
-
return
|
|
2475
|
+
return Object.keys(colorCategories).some(
|
|
2476
|
+
(colorCategory2) => isColorCategoryToken(token, colorCategory2)
|
|
2477
|
+
);
|
|
2476
2478
|
}
|
|
2477
2479
|
return R7.startsWith(["color", category], token.path);
|
|
2478
2480
|
}
|
|
@@ -2809,7 +2811,7 @@ var colorCategoryVariables = (opts) => ({ "color-scheme": colorScheme2, theme, .
|
|
|
2809
2811
|
);
|
|
2810
2812
|
}
|
|
2811
2813
|
const layer = `ds.theme.color`;
|
|
2812
|
-
const isRootColor = color === buildOptions?.
|
|
2814
|
+
const isRootColor = color === buildOptions?.defaultColor;
|
|
2813
2815
|
const selector = isRootColor ? `:root, [data-color-scheme], [data-color="${color}"]` : `[data-color="${color}"], [data-color-scheme][data-color="${color}"]`;
|
|
2814
2816
|
const config = {
|
|
2815
2817
|
preprocessors: ["tokens-studio"],
|
|
@@ -3053,8 +3055,7 @@ function processThemeObject(theme) {
|
|
|
3053
3055
|
}
|
|
3054
3056
|
function groupThemes(themes) {
|
|
3055
3057
|
const groups = {};
|
|
3056
|
-
for (const
|
|
3057
|
-
const theme = processThemeObject(rawTheme);
|
|
3058
|
+
for (const theme of themes) {
|
|
3058
3059
|
if (theme.group) {
|
|
3059
3060
|
const groupKey = theme.group;
|
|
3060
3061
|
groups[groupKey] = [...groups[groupKey] ?? [], theme];
|
|
@@ -3205,9 +3206,12 @@ var initResult = {
|
|
|
3205
3206
|
};
|
|
3206
3207
|
var buildOptions;
|
|
3207
3208
|
var sd = new StyleDictionary2();
|
|
3208
|
-
var getCustomColors = (processed$themes) => processed$themes.filter(
|
|
3209
|
-
(x
|
|
3210
|
-
|
|
3209
|
+
var getCustomColors = (processed$themes, colorGroups) => processed$themes.filter((x) => {
|
|
3210
|
+
if (!x.group) {
|
|
3211
|
+
return false;
|
|
3212
|
+
}
|
|
3213
|
+
return colorGroups.includes(x.group);
|
|
3214
|
+
}).map((x) => x.name);
|
|
3211
3215
|
var buildConfigs = {
|
|
3212
3216
|
typography: { getConfig: configs.typographyVariables, dimensions: ["typography"] },
|
|
3213
3217
|
"color-scheme": { getConfig: configs.colorSchemeVariables, dimensions: ["color-scheme"] },
|
|
@@ -3248,17 +3252,40 @@ var buildConfigs = {
|
|
|
3248
3252
|
// },
|
|
3249
3253
|
};
|
|
3250
3254
|
async function processPlatform(options) {
|
|
3251
|
-
const {
|
|
3255
|
+
const { type, $themes } = options;
|
|
3252
3256
|
const platform = "css";
|
|
3253
|
-
const tokenSets =
|
|
3254
|
-
const tokensDir =
|
|
3257
|
+
const tokenSets = type === "format" ? options.tokenSets : void 0;
|
|
3258
|
+
const tokensDir = type === "build" ? options.tokensDir : void 0;
|
|
3259
|
+
const UNSAFE_DEFAULT_COLOR = process.env.UNSAFE_DEFAULT_COLOR ?? "";
|
|
3260
|
+
if (UNSAFE_DEFAULT_COLOR) {
|
|
3261
|
+
console.warn(
|
|
3262
|
+
chalk2.yellow(
|
|
3263
|
+
`
|
|
3264
|
+
\u26A0\uFE0F UNSAFE_DEFAULT_COLOR is set to ${chalk2.blue(UNSAFE_DEFAULT_COLOR)}. This will override the default color.`
|
|
3265
|
+
)
|
|
3266
|
+
);
|
|
3267
|
+
}
|
|
3268
|
+
const UNSAFE_COLOR_GROUPS = Array.from(process.env.UNSAFE_COLOR_GROUPS?.split(",") ?? []);
|
|
3269
|
+
if (UNSAFE_COLOR_GROUPS.length > 0) {
|
|
3270
|
+
console.warn(
|
|
3271
|
+
chalk2.yellow(
|
|
3272
|
+
`
|
|
3273
|
+
\u26A0\uFE0F UNSAFE_COLOR_GROUPS is set to ${chalk2.blue(`[${UNSAFE_COLOR_GROUPS.join(", ")}]`)}. This will override the default color groups.`
|
|
3274
|
+
)
|
|
3275
|
+
);
|
|
3276
|
+
}
|
|
3277
|
+
const colorGroups = UNSAFE_COLOR_GROUPS.length > 0 ? UNSAFE_COLOR_GROUPS : [colorCategories.main, colorCategories.support].map((c) => `${c}-color`);
|
|
3255
3278
|
buildOptions = options;
|
|
3279
|
+
buildOptions.defaultColor = UNSAFE_DEFAULT_COLOR;
|
|
3256
3280
|
const processed$themes = $themes.map(processThemeObject).filter((theme) => R18.not(theme.group === "size" && theme.name !== "medium"));
|
|
3257
|
-
const customColors = getCustomColors(processed$themes);
|
|
3258
|
-
if (!buildOptions.
|
|
3281
|
+
const customColors = getCustomColors(processed$themes, colorGroups);
|
|
3282
|
+
if (!buildOptions.defaultColor) {
|
|
3259
3283
|
const firstMainColor = R18.head(customColors);
|
|
3260
|
-
buildOptions.
|
|
3261
|
-
|
|
3284
|
+
buildOptions.defaultColor = firstMainColor;
|
|
3285
|
+
}
|
|
3286
|
+
if (buildOptions.defaultColor) {
|
|
3287
|
+
console.log(`
|
|
3288
|
+
\u{1F3A8} Using ${chalk2.blue(buildOptions.defaultColor)} as default color`);
|
|
3262
3289
|
}
|
|
3263
3290
|
const buildAndSdConfigs = R18.map((buildConfig) => {
|
|
3264
3291
|
const sdConfigs = getConfigsForThemeDimensions(buildConfig.getConfig, processed$themes, buildConfig.dimensions, {
|
|
@@ -3356,7 +3383,7 @@ import chalk3 from "chalk";
|
|
|
3356
3383
|
// package.json
|
|
3357
3384
|
var package_default = {
|
|
3358
3385
|
name: "@digdir/designsystemet",
|
|
3359
|
-
version: "1.0.
|
|
3386
|
+
version: "1.0.8",
|
|
3360
3387
|
description: "CLI for Designsystemet",
|
|
3361
3388
|
author: "Designsystemet team",
|
|
3362
3389
|
engines: {
|
|
@@ -3406,8 +3433,8 @@ var package_default = {
|
|
|
3406
3433
|
test: "pnpm test:tokens-create-and-build-options && pnpm test:tokens-create-and-build-config",
|
|
3407
3434
|
"digdir:tokens-create": "pnpm run designsystemet tokens create --config ./configs/digdir.config.json",
|
|
3408
3435
|
"update:template": "tsx ./src/scripts/update-template.ts",
|
|
3409
|
-
"update:
|
|
3410
|
-
verify: "pnpm test && pnpm update:template && pnpm update:
|
|
3436
|
+
"update:theme-digdir": "pnpm digdir:tokens-create && tsx ./src/scripts/update-design-tokens.ts",
|
|
3437
|
+
verify: "pnpm test && pnpm update:template && pnpm update:theme-digdir && pnpm build:tokens"
|
|
3411
3438
|
},
|
|
3412
3439
|
dependencies: {
|
|
3413
3440
|
"@commander-js/extra-typings": "^13.1.0",
|
|
@@ -3520,7 +3547,7 @@ ${fileHeader2}
|
|
|
3520
3547
|
// src/tokens/format.ts
|
|
3521
3548
|
var formatTokens = async (options) => {
|
|
3522
3549
|
const processedBuilds = await processPlatform({
|
|
3523
|
-
|
|
3550
|
+
type: "format",
|
|
3524
3551
|
...options
|
|
3525
3552
|
});
|
|
3526
3553
|
return processedBuilds;
|
|
@@ -3,6 +3,14 @@ import * as R12 from "ramda";
|
|
|
3
3
|
|
|
4
4
|
// src/tokens/utils.ts
|
|
5
5
|
import * as R from "ramda";
|
|
6
|
+
|
|
7
|
+
// src/tokens/types.ts
|
|
8
|
+
var colorCategories = {
|
|
9
|
+
main: "main",
|
|
10
|
+
support: "support"
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
// src/tokens/utils.ts
|
|
6
14
|
var mapToLowerCase = R.map(R.toLower);
|
|
7
15
|
var hasAnyTruth = R.any(R.equals(true));
|
|
8
16
|
var getType = (token) => (token.$type ?? token.type) || "";
|
|
@@ -36,7 +44,9 @@ function isGlobalColorToken(token) {
|
|
|
36
44
|
}
|
|
37
45
|
function isColorCategoryToken(token, category) {
|
|
38
46
|
if (!category) {
|
|
39
|
-
return
|
|
47
|
+
return Object.keys(colorCategories).some(
|
|
48
|
+
(colorCategory2) => isColorCategoryToken(token, colorCategory2)
|
|
49
|
+
);
|
|
40
50
|
}
|
|
41
51
|
return R.startsWith(["color", category], token.path);
|
|
42
52
|
}
|
|
@@ -59,14 +69,6 @@ function inlineTokens(shouldInline, tokens) {
|
|
|
59
69
|
// src/tokens/process/formats/css/color.ts
|
|
60
70
|
import * as R2 from "ramda";
|
|
61
71
|
import { createPropertyFormatter } from "style-dictionary/utils";
|
|
62
|
-
|
|
63
|
-
// src/tokens/types.ts
|
|
64
|
-
var colorCategories = {
|
|
65
|
-
main: "main",
|
|
66
|
-
support: "support"
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
// src/tokens/process/formats/css/color.ts
|
|
70
72
|
var prefersColorScheme = (colorScheme2, content) => `
|
|
71
73
|
@media (prefers-color-scheme: ${colorScheme2}) {
|
|
72
74
|
[data-color-scheme="auto"] ${content}
|
|
@@ -791,7 +793,7 @@ var colorCategoryVariables = (opts) => ({ "color-scheme": colorScheme2, theme, .
|
|
|
791
793
|
);
|
|
792
794
|
}
|
|
793
795
|
const layer = `ds.theme.color`;
|
|
794
|
-
const isRootColor = color === buildOptions?.
|
|
796
|
+
const isRootColor = color === buildOptions?.defaultColor;
|
|
795
797
|
const selector = isRootColor ? `:root, [data-color-scheme], [data-color="${color}"]` : `[data-color="${color}"], [data-color-scheme][data-color="${color}"]`;
|
|
796
798
|
const config = {
|
|
797
799
|
preprocessors: ["tokens-studio"],
|
|
@@ -4,6 +4,14 @@ import { outputReferencesFilter } from "style-dictionary/utils";
|
|
|
4
4
|
|
|
5
5
|
// src/tokens/utils.ts
|
|
6
6
|
import * as R from "ramda";
|
|
7
|
+
|
|
8
|
+
// src/tokens/types.ts
|
|
9
|
+
var colorCategories = {
|
|
10
|
+
main: "main",
|
|
11
|
+
support: "support"
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// src/tokens/utils.ts
|
|
7
15
|
var mapToLowerCase = R.map(R.toLower);
|
|
8
16
|
var hasAnyTruth = R.any(R.equals(true));
|
|
9
17
|
var getType = (token) => (token.$type ?? token.type) || "";
|
|
@@ -34,7 +42,9 @@ function isGlobalColorToken(token) {
|
|
|
34
42
|
}
|
|
35
43
|
function isColorCategoryToken(token, category) {
|
|
36
44
|
if (!category) {
|
|
37
|
-
return
|
|
45
|
+
return Object.keys(colorCategories).some(
|
|
46
|
+
(colorCategory2) => isColorCategoryToken(token, colorCategory2)
|
|
47
|
+
);
|
|
38
48
|
}
|
|
39
49
|
return R.startsWith(["color", category], token.path);
|
|
40
50
|
}
|
|
@@ -57,14 +67,6 @@ function inlineTokens(shouldInline, tokens) {
|
|
|
57
67
|
// src/tokens/process/formats/css/color.ts
|
|
58
68
|
import * as R2 from "ramda";
|
|
59
69
|
import { createPropertyFormatter } from "style-dictionary/utils";
|
|
60
|
-
|
|
61
|
-
// src/tokens/types.ts
|
|
62
|
-
var colorCategories = {
|
|
63
|
-
main: "main",
|
|
64
|
-
support: "support"
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
// src/tokens/process/formats/css/color.ts
|
|
68
70
|
var prefersColorScheme = (colorScheme2, content) => `
|
|
69
71
|
@media (prefers-color-scheme: ${colorScheme2}) {
|
|
70
72
|
[data-color-scheme="auto"] ${content}
|
|
@@ -4,6 +4,14 @@ import { outputReferencesFilter } from "style-dictionary/utils";
|
|
|
4
4
|
|
|
5
5
|
// src/tokens/utils.ts
|
|
6
6
|
import * as R from "ramda";
|
|
7
|
+
|
|
8
|
+
// src/tokens/types.ts
|
|
9
|
+
var colorCategories = {
|
|
10
|
+
main: "main",
|
|
11
|
+
support: "support"
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// src/tokens/utils.ts
|
|
7
15
|
var mapToLowerCase = R.map(R.toLower);
|
|
8
16
|
var hasAnyTruth = R.any(R.equals(true));
|
|
9
17
|
var getType = (token) => (token.$type ?? token.type) || "";
|
|
@@ -28,7 +36,9 @@ var pathStartsWithOneOf = R.curry(
|
|
|
28
36
|
);
|
|
29
37
|
function isColorCategoryToken(token, category) {
|
|
30
38
|
if (!category) {
|
|
31
|
-
return
|
|
39
|
+
return Object.keys(colorCategories).some(
|
|
40
|
+
(colorCategory) => isColorCategoryToken(token, colorCategory)
|
|
41
|
+
);
|
|
32
42
|
}
|
|
33
43
|
return R.startsWith(["color", category], token.path);
|
|
34
44
|
}
|
|
@@ -3,6 +3,14 @@ import { expandTypesMap } from "@tokens-studio/sd-transforms";
|
|
|
3
3
|
|
|
4
4
|
// src/tokens/utils.ts
|
|
5
5
|
import * as R from "ramda";
|
|
6
|
+
|
|
7
|
+
// src/tokens/types.ts
|
|
8
|
+
var colorCategories = {
|
|
9
|
+
main: "main",
|
|
10
|
+
support: "support"
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
// src/tokens/utils.ts
|
|
6
14
|
var mapToLowerCase = R.map(R.toLower);
|
|
7
15
|
var hasAnyTruth = R.any(R.equals(true));
|
|
8
16
|
var getType = (token) => (token.$type ?? token.type) || "";
|
|
@@ -33,7 +41,9 @@ function isGlobalColorToken(token) {
|
|
|
33
41
|
}
|
|
34
42
|
function isColorCategoryToken(token, category) {
|
|
35
43
|
if (!category) {
|
|
36
|
-
return
|
|
44
|
+
return Object.keys(colorCategories).some(
|
|
45
|
+
(colorCategory2) => isColorCategoryToken(token, colorCategory2)
|
|
46
|
+
);
|
|
37
47
|
}
|
|
38
48
|
return R.startsWith(["color", category], token.path);
|
|
39
49
|
}
|
|
@@ -56,14 +66,6 @@ function inlineTokens(shouldInline, tokens) {
|
|
|
56
66
|
// src/tokens/process/formats/css/color.ts
|
|
57
67
|
import * as R2 from "ramda";
|
|
58
68
|
import { createPropertyFormatter } from "style-dictionary/utils";
|
|
59
|
-
|
|
60
|
-
// src/tokens/types.ts
|
|
61
|
-
var colorCategories = {
|
|
62
|
-
main: "main",
|
|
63
|
-
support: "support"
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
// src/tokens/process/formats/css/color.ts
|
|
67
69
|
var prefersColorScheme = (colorScheme2, content) => `
|
|
68
70
|
@media (prefers-color-scheme: ${colorScheme2}) {
|
|
69
71
|
[data-color-scheme="auto"] ${content}
|
|
@@ -5,6 +5,14 @@ import StyleDictionary2 from "style-dictionary";
|
|
|
5
5
|
|
|
6
6
|
// src/tokens/utils.ts
|
|
7
7
|
import * as R from "ramda";
|
|
8
|
+
|
|
9
|
+
// src/tokens/types.ts
|
|
10
|
+
var colorCategories = {
|
|
11
|
+
main: "main",
|
|
12
|
+
support: "support"
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
// src/tokens/utils.ts
|
|
8
16
|
var mapToLowerCase = R.map(R.toLower);
|
|
9
17
|
var hasAnyTruth = R.any(R.equals(true));
|
|
10
18
|
var getType = (token) => (token.$type ?? token.type) || "";
|
|
@@ -38,7 +46,9 @@ function isGlobalColorToken(token) {
|
|
|
38
46
|
}
|
|
39
47
|
function isColorCategoryToken(token, category) {
|
|
40
48
|
if (!category) {
|
|
41
|
-
return
|
|
49
|
+
return Object.keys(colorCategories).some(
|
|
50
|
+
(colorCategory2) => isColorCategoryToken(token, colorCategory2)
|
|
51
|
+
);
|
|
42
52
|
}
|
|
43
53
|
return R.startsWith(["color", category], token.path);
|
|
44
54
|
}
|
|
@@ -76,14 +86,6 @@ import * as R8 from "ramda";
|
|
|
76
86
|
// src/tokens/process/formats/css/color.ts
|
|
77
87
|
import * as R2 from "ramda";
|
|
78
88
|
import { createPropertyFormatter } from "style-dictionary/utils";
|
|
79
|
-
|
|
80
|
-
// src/tokens/types.ts
|
|
81
|
-
var colorCategories = {
|
|
82
|
-
main: "main",
|
|
83
|
-
support: "support"
|
|
84
|
-
};
|
|
85
|
-
|
|
86
|
-
// src/tokens/process/formats/css/color.ts
|
|
87
89
|
var prefersColorScheme = (colorScheme2, content) => `
|
|
88
90
|
@media (prefers-color-scheme: ${colorScheme2}) {
|
|
89
91
|
[data-color-scheme="auto"] ${content}
|
|
@@ -460,24 +462,9 @@ var getMultidimensionalThemes = (processed$themes, dimensions) => {
|
|
|
460
462
|
});
|
|
461
463
|
};
|
|
462
464
|
var processed = Symbol("Type brand for ProcessedThemeObject");
|
|
463
|
-
function isProcessed(theme) {
|
|
464
|
-
return Boolean(theme[processed]);
|
|
465
|
-
}
|
|
466
|
-
function processThemeObject(theme) {
|
|
467
|
-
if (isProcessed(theme)) {
|
|
468
|
-
return theme;
|
|
469
|
-
}
|
|
470
|
-
const result = { ...theme, [processed]: true };
|
|
471
|
-
if (result.group) {
|
|
472
|
-
result.group = kebabCase(result.group);
|
|
473
|
-
}
|
|
474
|
-
result.name = kebabCase(result.name);
|
|
475
|
-
return result;
|
|
476
|
-
}
|
|
477
465
|
function groupThemes(themes) {
|
|
478
466
|
const groups = {};
|
|
479
|
-
for (const
|
|
480
|
-
const theme = processThemeObject(rawTheme);
|
|
467
|
+
for (const theme of themes) {
|
|
481
468
|
if (theme.group) {
|
|
482
469
|
const groupKey = theme.group;
|
|
483
470
|
groups[groupKey] = [...groups[groupKey] ?? [], theme];
|
|
@@ -702,7 +689,7 @@ var colorCategoryVariables = (opts) => ({ "color-scheme": colorScheme2, theme, .
|
|
|
702
689
|
);
|
|
703
690
|
}
|
|
704
691
|
const layer = `ds.theme.color`;
|
|
705
|
-
const isRootColor = color === buildOptions?.
|
|
692
|
+
const isRootColor = color === buildOptions?.defaultColor;
|
|
706
693
|
const selector = isRootColor ? `:root, [data-color-scheme], [data-color="${color}"]` : `[data-color="${color}"], [data-color-scheme][data-color="${color}"]`;
|
|
707
694
|
const config = {
|
|
708
695
|
preprocessors: ["tokens-studio"],
|
|
@@ -39,7 +39,9 @@ function isGlobalColorToken(token) {
|
|
|
39
39
|
}
|
|
40
40
|
function isColorCategoryToken(token, category) {
|
|
41
41
|
if (!category) {
|
|
42
|
-
return
|
|
42
|
+
return Object.keys(colorCategories).some(
|
|
43
|
+
(colorCategory2) => isColorCategoryToken(token, colorCategory2)
|
|
44
|
+
);
|
|
43
45
|
}
|
|
44
46
|
return R.startsWith(["color", category], token.path);
|
|
45
47
|
}
|
|
@@ -40,7 +40,9 @@ function isGlobalColorToken(token) {
|
|
|
40
40
|
}
|
|
41
41
|
function isColorCategoryToken(token, category) {
|
|
42
42
|
if (!category) {
|
|
43
|
-
return
|
|
43
|
+
return Object.keys(colorCategories).some(
|
|
44
|
+
(colorCategory2) => isColorCategoryToken(token, colorCategory2)
|
|
45
|
+
);
|
|
44
46
|
}
|
|
45
47
|
return R.startsWith(["color", category], token.path);
|
|
46
48
|
}
|
|
@@ -4,6 +4,14 @@ import { createPropertyFormatter as createPropertyFormatter2, fileHeader } from
|
|
|
4
4
|
|
|
5
5
|
// src/tokens/utils.ts
|
|
6
6
|
import * as R from "ramda";
|
|
7
|
+
|
|
8
|
+
// src/tokens/types.ts
|
|
9
|
+
var colorCategories = {
|
|
10
|
+
main: "main",
|
|
11
|
+
support: "support"
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// src/tokens/utils.ts
|
|
7
15
|
var mapToLowerCase = R.map(R.toLower);
|
|
8
16
|
var hasAnyTruth = R.any(R.equals(true));
|
|
9
17
|
var getType = (token) => (token.$type ?? token.type) || "";
|
|
@@ -28,7 +36,9 @@ var pathStartsWithOneOf = R.curry(
|
|
|
28
36
|
);
|
|
29
37
|
function isColorCategoryToken(token, category) {
|
|
30
38
|
if (!category) {
|
|
31
|
-
return
|
|
39
|
+
return Object.keys(colorCategories).some(
|
|
40
|
+
(colorCategory) => isColorCategoryToken(token, colorCategory)
|
|
41
|
+
);
|
|
32
42
|
}
|
|
33
43
|
return R.startsWith(["color", category], token.path);
|
|
34
44
|
}
|
|
@@ -5,25 +5,23 @@ type SharedOptions = {
|
|
|
5
5
|
/** Enable verbose output */
|
|
6
6
|
verbose: boolean;
|
|
7
7
|
/** Set the default color for ":root" */
|
|
8
|
-
|
|
8
|
+
defaultColor?: string;
|
|
9
9
|
/** Dry run, no files will be written */
|
|
10
10
|
dry?: boolean;
|
|
11
|
-
/** Clean the output path before building tokens */
|
|
12
|
-
clean?: boolean;
|
|
13
11
|
/** Generate preview tokens */
|
|
14
12
|
preview: boolean;
|
|
15
13
|
/** Token Studio `$themes.json` content */
|
|
16
14
|
$themes: ThemeObject[];
|
|
17
15
|
};
|
|
18
16
|
export type BuildOptions = {
|
|
19
|
-
|
|
17
|
+
type: 'build';
|
|
20
18
|
/** Design tokens path */
|
|
21
19
|
tokensDir: string;
|
|
22
20
|
/** Output directory for built tokens */
|
|
23
21
|
outDir: string;
|
|
24
22
|
} & SharedOptions;
|
|
25
23
|
export type FormatOptions = {
|
|
26
|
-
|
|
24
|
+
type: 'format';
|
|
27
25
|
/** Tokensets */
|
|
28
26
|
tokenSets: Map<string, TokenSet>;
|
|
29
27
|
} & SharedOptions;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../../../../src/tokens/process/platform.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAIxD,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAoB,KAAK,gBAAgB,EAAmB,MAAM,aAAa,CAAC;AAIvF,KAAK,aAAa,GAAG;IACnB,4BAA4B;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,wCAAwC;IACxC,
|
|
1
|
+
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../../../../src/tokens/process/platform.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAIxD,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,EAAoB,KAAK,gBAAgB,EAAmB,MAAM,aAAa,CAAC;AAIvF,KAAK,aAAa,GAAG;IACnB,4BAA4B;IAC5B,OAAO,EAAE,OAAO,CAAC;IACjB,wCAAwC;IACxC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,wCAAwC;IACxC,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,8BAA8B;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,0CAA0C;IAC1C,OAAO,EAAE,WAAW,EAAE,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,IAAI,EAAE,OAAO,CAAC;IACd,yBAAyB;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,wCAAwC;IACxC,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,aAAa,CAAC;AAElB,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,QAAQ,CAAC;IACf,gBAAgB;IAChB,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;CAClC,GAAG,aAAa,CAAC;AAElB,KAAK,cAAc,GAAG,YAAY,GAAG,aAAa,CAAC;AAEnD,KAAK,qBAAqB,CAAC,CAAC,IAAI,MAAM,CAAC,MAAM,OAAO,YAAY,GAAG,OAAO,EAAE,CAAC,CAAC,CAAC;AAE/E,MAAM,MAAM,aAAa,GAAG,qBAAqB,CAAC,WAAW,EAAE,CAAC,CAAC;AAEjE,KAAK,WAAW,GAAG;IACjB,WAAW,EAAE,gBAAgB,CAAC;IAC9B,SAAS,EAAE,UAAU,EAAE,CAAC;CACzB,CAAC;AAeF,eAAO,IAAI,YAAY,EAAE,cAAc,GAAG,SAAS,CAAC;AAkBpD,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsCqB,CAAC;AAExC,wBAAsB,eAAe,CAAC,CAAC,EAAE,OAAO,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC,CA0IxF"}
|