@digdir/designsystemet 1.1.3 → 1.1.5
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.js +130 -186
- package/dist/src/index.js +88 -145
- package/dist/src/scripts/update-preview-tokens.d.ts +3 -0
- package/dist/src/scripts/update-preview-tokens.d.ts.map +1 -0
- package/dist/src/scripts/update-preview-tokens.js +3446 -0
- 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 +98 -154
- package/dist/src/tokens/create/generators/$designsystemet.js +6 -6
- package/dist/src/tokens/create/write.js +6 -6
- 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 +88 -145
- package/dist/src/tokens/index.js +88 -145
- package/dist/src/tokens/process/configs/color.js +234 -293
- package/dist/src/tokens/process/configs/semantic.js +509 -113
- package/dist/src/tokens/process/configs/typography.d.ts.map +1 -1
- package/dist/src/tokens/process/configs/typography.js +504 -110
- package/dist/src/tokens/process/configs.d.ts +0 -1
- package/dist/src/tokens/process/configs.d.ts.map +1 -1
- package/dist/src/tokens/process/configs.js +231 -290
- package/dist/src/tokens/process/formats/css/color.d.ts.map +1 -1
- package/dist/src/tokens/process/formats/css/color.js +644 -12
- package/dist/src/tokens/process/formats/css/semantic.d.ts.map +1 -1
- package/dist/src/tokens/process/formats/css/semantic.js +679 -23
- package/dist/src/tokens/process/formats/css/typography.d.ts.map +1 -1
- package/dist/src/tokens/process/formats/css/typography.js +741 -8
- package/dist/src/tokens/process/formats/css.js +549 -38
- package/dist/src/tokens/process/output/declarations.js +60 -121
- package/dist/src/tokens/process/output/theme.js +6 -6
- package/dist/src/tokens/process/platform.d.ts +9 -4
- package/dist/src/tokens/process/platform.d.ts.map +1 -1
- package/dist/src/tokens/process/platform.js +76 -133
- package/dist/src/tokens/process/utils/getMultidimensionalThemes.js +62 -123
- package/package.json +6 -6
- package/dist/src/tokens/process/configs/storefront.d.ts +0 -3
- package/dist/src/tokens/process/configs/storefront.d.ts.map +0 -1
- package/dist/src/tokens/process/configs/storefront.js +0 -234
- package/dist/src/tokens/process/formats/js-tokens.d.ts +0 -6
- package/dist/src/tokens/process/formats/js-tokens.d.ts.map +0 -1
- package/dist/src/tokens/process/formats/js-tokens.js +0 -123
|
@@ -12,7 +12,6 @@ export declare const configs: {
|
|
|
12
12
|
infoColorVariables: GetStyleDictionaryConfig;
|
|
13
13
|
typographyVariables: GetStyleDictionaryConfig;
|
|
14
14
|
semanticVariables: GetStyleDictionaryConfig;
|
|
15
|
-
typescriptTokens: GetStyleDictionaryConfig;
|
|
16
15
|
};
|
|
17
16
|
export declare const getConfigsForThemeDimensions: (getConfig: GetStyleDictionaryConfig, processed$themes: ProcessedThemeObject[], dimensions: ThemeDimension[], options: GetSDConfigOptions) => SDConfigForThemePermutation[];
|
|
18
17
|
//# sourceMappingURL=configs.d.ts.map
|
|
@@ -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;
|
|
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;AAKpE,OAAO,EAA6B,KAAK,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAa5G,eAAO,MAAM,OAAO;;;;;;;;;;;CAWnB,CAAC;AAEF,eAAO,MAAM,4BAA4B,GACvC,WAAW,wBAAwB,EACnC,kBAAkB,oBAAoB,EAAE,EACxC,YAAY,cAAc,EAAE,EAC5B,SAAS,kBAAkB,KAC1B,2BAA2B,EAoD7B,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/tokens/process/configs.ts
|
|
2
2
|
import { register } from "@tokens-studio/sd-transforms";
|
|
3
|
-
import * as
|
|
3
|
+
import * as R10 from "ramda";
|
|
4
4
|
import StyleDictionary2 from "style-dictionary";
|
|
5
5
|
|
|
6
6
|
// src/tokens/utils.ts
|
|
@@ -84,198 +84,12 @@ function inlineTokens(shouldInline, tokens) {
|
|
|
84
84
|
import * as R8 from "ramda";
|
|
85
85
|
|
|
86
86
|
// src/tokens/process/formats/css/color.ts
|
|
87
|
-
import * as R2 from "ramda";
|
|
88
|
-
import { createPropertyFormatter } from "style-dictionary/utils";
|
|
89
|
-
var prefersColorScheme = (colorScheme2, content) => `
|
|
90
|
-
@media (prefers-color-scheme: ${colorScheme2}) {
|
|
91
|
-
[data-color-scheme="auto"] ${content}
|
|
92
|
-
}
|
|
93
|
-
`;
|
|
94
|
-
var colorScheme = {
|
|
95
|
-
name: "ds/css-colorscheme",
|
|
96
|
-
format: async ({ dictionary, options, platform }) => {
|
|
97
|
-
const { allTokens } = dictionary;
|
|
98
|
-
const { outputReferences, usesDtcg } = options;
|
|
99
|
-
const { selector, colorScheme: colorScheme2, layer } = platform;
|
|
100
|
-
const colorScheme_ = colorScheme2;
|
|
101
|
-
const format = createPropertyFormatter({
|
|
102
|
-
outputReferences,
|
|
103
|
-
dictionary,
|
|
104
|
-
format: "css",
|
|
105
|
-
usesDtcg
|
|
106
|
-
});
|
|
107
|
-
const colorSchemeProperty = colorScheme_ === "dark" || colorScheme_ === "light" ? `
|
|
108
|
-
color-scheme: ${colorScheme_};
|
|
109
|
-
` : "";
|
|
110
|
-
const filteredAllTokens = allTokens.filter(
|
|
111
|
-
R2.allPass([
|
|
112
|
-
R2.anyPass([
|
|
113
|
-
// Include semantic tokens in the output
|
|
114
|
-
isSemanticToken,
|
|
115
|
-
// Include global color tokens
|
|
116
|
-
isGlobalColorToken
|
|
117
|
-
]),
|
|
118
|
-
// Don't include color category tokens -- they are exported separately
|
|
119
|
-
(t) => !isColorCategoryToken(t)
|
|
120
|
-
])
|
|
121
|
-
);
|
|
122
|
-
const formattedTokens = filteredAllTokens.map(format).join("\n");
|
|
123
|
-
const content = `{
|
|
124
|
-
${formattedTokens}
|
|
125
|
-
${colorSchemeProperty}}
|
|
126
|
-
`;
|
|
127
|
-
const autoSelectorContent = ["light", "dark"].includes(colorScheme_) ? prefersColorScheme(colorScheme_, content) : "";
|
|
128
|
-
const body = R2.isNotNil(layer) ? `@layer ${layer} {
|
|
129
|
-
${selector} ${content} ${autoSelectorContent}
|
|
130
|
-
}
|
|
131
|
-
` : `${selector} ${content} ${autoSelectorContent}
|
|
132
|
-
`;
|
|
133
|
-
return body;
|
|
134
|
-
}
|
|
135
|
-
};
|
|
136
|
-
var colorCategory = {
|
|
137
|
-
name: "ds/css-colorcategory",
|
|
138
|
-
format: async ({ dictionary, options, platform }) => {
|
|
139
|
-
const { outputReferences, usesDtcg } = options;
|
|
140
|
-
const { selector, layer } = platform;
|
|
141
|
-
const format = R2.compose(
|
|
142
|
-
createPropertyFormatter({
|
|
143
|
-
outputReferences,
|
|
144
|
-
dictionary,
|
|
145
|
-
format: "css",
|
|
146
|
-
usesDtcg
|
|
147
|
-
}),
|
|
148
|
-
(token) => ({
|
|
149
|
-
...token,
|
|
150
|
-
name: token.name.replace(/color-\w+-/, "color-"),
|
|
151
|
-
original: {
|
|
152
|
-
...token.original,
|
|
153
|
-
$value: new RegExp(`color-(${colorCategories.main}|${colorCategories.support})-`).test(token.name) ? token.original.$value : `{${token.path.join(".")}}`
|
|
154
|
-
}
|
|
155
|
-
})
|
|
156
|
-
);
|
|
157
|
-
const formattedTokens = dictionary.allTokens.map(format).join("\n");
|
|
158
|
-
const content = `{
|
|
159
|
-
${formattedTokens}
|
|
160
|
-
}
|
|
161
|
-
`;
|
|
162
|
-
const body = R2.isNotNil(layer) ? `@layer ${layer} {
|
|
163
|
-
${selector} ${content}
|
|
164
|
-
}
|
|
165
|
-
` : `${selector} ${content}
|
|
166
|
-
`;
|
|
167
|
-
return body;
|
|
168
|
-
}
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
// src/tokens/process/formats/css/semantic.ts
|
|
172
|
-
import * as R3 from "ramda";
|
|
173
|
-
import { createPropertyFormatter as createPropertyFormatter2 } from "style-dictionary/utils";
|
|
174
|
-
var isNumericBorderRadiusToken = (t) => t.path[0] === "border-radius" && isDigit(t.path[1]);
|
|
175
|
-
var isNumericSizeToken = (t) => pathStartsWithOneOf(["size"], t) && isDigit(t.path[1]);
|
|
176
|
-
var isSizeToken = (t) => pathStartsWithOneOf(["size"], t);
|
|
177
|
-
var isInlineTokens = R3.anyPass([isNumericBorderRadiusToken, isNumericSizeToken, isSizeToken]);
|
|
178
|
-
var overrideSizingFormula = (format, token) => {
|
|
179
|
-
const [name, value] = format(token).split(":");
|
|
180
|
-
const calc = value.replace(`var(--ds-size-mode-font-size)`, "1em").replace(/floor\((.*)\);/, "calc($1)");
|
|
181
|
-
const round = `round(down, ${calc}, 1px)`;
|
|
182
|
-
return {
|
|
183
|
-
name,
|
|
184
|
-
round,
|
|
185
|
-
calc
|
|
186
|
-
};
|
|
187
|
-
};
|
|
188
|
-
var formatSizingTokens = (format, tokens) => {
|
|
189
|
-
const { round, calc } = R3.reduce(
|
|
190
|
-
(acc, token) => {
|
|
191
|
-
const { round: round2, calc: calc2, name } = overrideSizingFormula(format, token);
|
|
192
|
-
return {
|
|
193
|
-
round: [...acc.round, `${name}: ${round2};`],
|
|
194
|
-
calc: [...acc.calc, `${name}: ${calc2};`]
|
|
195
|
-
};
|
|
196
|
-
},
|
|
197
|
-
{ round: [], calc: [] },
|
|
198
|
-
tokens
|
|
199
|
-
);
|
|
200
|
-
return `
|
|
201
|
-
${calc.join("\n")}
|
|
202
|
-
|
|
203
|
-
@supports (width: round(down, .1em, 1px)) {
|
|
204
|
-
${round.join("\n")}
|
|
205
|
-
}`;
|
|
206
|
-
};
|
|
207
|
-
var semantic = {
|
|
208
|
-
name: "ds/css-semantic",
|
|
209
|
-
format: async ({ dictionary, options, platform }) => {
|
|
210
|
-
const { outputReferences, usesDtcg } = options;
|
|
211
|
-
const { selector, layer } = platform;
|
|
212
|
-
const format = createPropertyFormatter2({
|
|
213
|
-
outputReferences,
|
|
214
|
-
dictionary,
|
|
215
|
-
format: "css",
|
|
216
|
-
usesDtcg
|
|
217
|
-
});
|
|
218
|
-
const tokens = inlineTokens(isInlineTokens, dictionary.allTokens);
|
|
219
|
-
const filteredTokens = R3.reject((token) => token.name.includes("ds-size-mode-font-size"), tokens);
|
|
220
|
-
const [sizingTokens, restTokens] = R3.partition(
|
|
221
|
-
(t) => pathStartsWithOneOf(["_size"], t) && isDigit(t.path[1]),
|
|
222
|
-
filteredTokens
|
|
223
|
-
);
|
|
224
|
-
const formattedTokens = [R3.map(format, restTokens).join("\n"), formatSizingTokens(format, sizingTokens)];
|
|
225
|
-
const content = `{
|
|
226
|
-
${formattedTokens.join("\n")}
|
|
227
|
-
}
|
|
228
|
-
`;
|
|
229
|
-
const body = R3.isNotNil(layer) ? `@layer ${layer} {
|
|
230
|
-
${selector} ${content}
|
|
231
|
-
}
|
|
232
|
-
` : `${selector} ${content}
|
|
233
|
-
`;
|
|
234
|
-
return body;
|
|
235
|
-
}
|
|
236
|
-
};
|
|
237
|
-
|
|
238
|
-
// src/tokens/process/formats/css/typography.ts
|
|
239
87
|
import * as R4 from "ramda";
|
|
240
|
-
import { createPropertyFormatter
|
|
241
|
-
var typographyFontFamilyPredicate = R4.allPass([
|
|
242
|
-
R4.pathSatisfies(R4.includes("typography"), ["path"]),
|
|
243
|
-
R4.pathSatisfies(R4.includes("fontFamily"), ["path"])
|
|
244
|
-
]);
|
|
245
|
-
var typography = {
|
|
246
|
-
name: "ds/css-typography",
|
|
247
|
-
format: async ({ dictionary, options, platform }) => {
|
|
248
|
-
const { outputReferences, usesDtcg } = options;
|
|
249
|
-
const { selector, layer } = platform;
|
|
250
|
-
const format = createPropertyFormatter3({
|
|
251
|
-
outputReferences,
|
|
252
|
-
dictionary,
|
|
253
|
-
format: "css",
|
|
254
|
-
usesDtcg
|
|
255
|
-
});
|
|
256
|
-
const filteredTokens = R4.reject(typographyFontFamilyPredicate, dictionary.allTokens);
|
|
257
|
-
const formattedTokens = R4.pipe(R4.map(format), R4.join("\n"))(filteredTokens);
|
|
258
|
-
const content = selector ? `${selector} {
|
|
259
|
-
${formattedTokens}
|
|
260
|
-
}` : formattedTokens;
|
|
261
|
-
const body = R4.isNotNil(layer) ? `@layer ${layer} {
|
|
262
|
-
${content}
|
|
263
|
-
}` : content;
|
|
264
|
-
return body;
|
|
265
|
-
}
|
|
266
|
-
};
|
|
267
|
-
|
|
268
|
-
// src/tokens/process/formats/css.ts
|
|
269
|
-
var formats = {
|
|
270
|
-
colorScheme,
|
|
271
|
-
colorCategory,
|
|
272
|
-
semantic,
|
|
273
|
-
typography
|
|
274
|
-
};
|
|
88
|
+
import { createPropertyFormatter } from "style-dictionary/utils";
|
|
275
89
|
|
|
276
90
|
// src/tokens/process/platform.ts
|
|
277
91
|
import chalk2 from "chalk";
|
|
278
|
-
import * as
|
|
92
|
+
import * as R3 from "ramda";
|
|
279
93
|
import StyleDictionary from "style-dictionary";
|
|
280
94
|
|
|
281
95
|
// ../../node_modules/.pnpm/@tokens-studio+types@0.5.2/node_modules/@tokens-studio/types/dist/constants/BoxShadowTypes.js
|
|
@@ -444,13 +258,13 @@ var TypographyValues;
|
|
|
444
258
|
// src/tokens/process/utils/getMultidimensionalThemes.ts
|
|
445
259
|
import chalk from "chalk";
|
|
446
260
|
import { kebabCase } from "change-case";
|
|
447
|
-
import * as
|
|
261
|
+
import * as R2 from "ramda";
|
|
448
262
|
var getMultidimensionalThemes = (processed$themes, dimensions) => {
|
|
449
263
|
const verboseLogging = buildOptions?.verbose;
|
|
450
264
|
const grouped$themes = groupThemes(processed$themes);
|
|
451
265
|
const permutations = permutateThemes(grouped$themes);
|
|
452
266
|
const ALL_DEPENDENT_ON = ["theme"];
|
|
453
|
-
const keys2 =
|
|
267
|
+
const keys2 = R2.keys(grouped$themes);
|
|
454
268
|
const nonDependentKeys = keys2.filter((x) => ![...ALL_DEPENDENT_ON, ...dimensions].includes(x));
|
|
455
269
|
if (verboseLogging) {
|
|
456
270
|
console.log(chalk.cyan(`\u{1F50E} Finding theme permutations for ${dimensions}`));
|
|
@@ -476,7 +290,7 @@ function groupThemes(themes) {
|
|
|
476
290
|
}
|
|
477
291
|
return groups;
|
|
478
292
|
}
|
|
479
|
-
var hasUnknownProps =
|
|
293
|
+
var hasUnknownProps = R2.pipe(R2.values, R2.none(R2.equals("unknown")), R2.not);
|
|
480
294
|
function permutateThemes(groups) {
|
|
481
295
|
const separator = "_";
|
|
482
296
|
const permutations = cartesian(Object.values(groups));
|
|
@@ -486,8 +300,8 @@ function permutateThemes(groups) {
|
|
|
486
300
|
const { group, name, selectedTokenSets } = theme;
|
|
487
301
|
let updatedPermutation = acc.permutation;
|
|
488
302
|
if (group) {
|
|
489
|
-
const groupProp =
|
|
490
|
-
updatedPermutation =
|
|
303
|
+
const groupProp = R2.lensProp(group);
|
|
304
|
+
updatedPermutation = R2.set(groupProp, name, updatedPermutation);
|
|
491
305
|
}
|
|
492
306
|
const updatedName = `${String(acc.name)}${acc ? separator : ""}${name}`;
|
|
493
307
|
const sets = [...acc.selectedTokenSets, ...filterTokenSets(selectedTokenSets)];
|
|
@@ -535,7 +349,11 @@ function cartesian(a) {
|
|
|
535
349
|
}
|
|
536
350
|
|
|
537
351
|
// src/tokens/process/platform.ts
|
|
538
|
-
var buildOptions
|
|
352
|
+
var buildOptions = {
|
|
353
|
+
verbose: false,
|
|
354
|
+
processed$themes: [],
|
|
355
|
+
buildTokenFormats: {}
|
|
356
|
+
};
|
|
539
357
|
var sd = new StyleDictionary();
|
|
540
358
|
var buildConfigs = {
|
|
541
359
|
typography: { getConfig: configs.typographyVariables, dimensions: ["typography"] },
|
|
@@ -568,13 +386,221 @@ var buildConfigs = {
|
|
|
568
386
|
log: ({ permutation: { theme } }) => `${theme} - info`
|
|
569
387
|
},
|
|
570
388
|
semantic: { getConfig: configs.semanticVariables, dimensions: ["semantic"] }
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
389
|
+
};
|
|
390
|
+
|
|
391
|
+
// src/tokens/process/formats/css/color.ts
|
|
392
|
+
var prefersColorScheme = (colorScheme2, content) => `
|
|
393
|
+
@media (prefers-color-scheme: ${colorScheme2}) {
|
|
394
|
+
[data-color-scheme="auto"] ${content}
|
|
395
|
+
}
|
|
396
|
+
`;
|
|
397
|
+
var colorScheme = {
|
|
398
|
+
name: "ds/css-colorscheme",
|
|
399
|
+
format: async ({ dictionary, options, platform }) => {
|
|
400
|
+
const { allTokens } = dictionary;
|
|
401
|
+
const { outputReferences, usesDtcg } = options;
|
|
402
|
+
const { selector, colorScheme: colorScheme2, layer } = platform;
|
|
403
|
+
const colorScheme_ = colorScheme2;
|
|
404
|
+
const format = createPropertyFormatter({
|
|
405
|
+
outputReferences,
|
|
406
|
+
dictionary,
|
|
407
|
+
format: "css",
|
|
408
|
+
usesDtcg
|
|
409
|
+
});
|
|
410
|
+
const colorSchemeProperty = colorScheme_ === "dark" || colorScheme_ === "light" ? `
|
|
411
|
+
color-scheme: ${colorScheme_};
|
|
412
|
+
` : "";
|
|
413
|
+
const filteredAllTokens = allTokens.filter(
|
|
414
|
+
R4.allPass([
|
|
415
|
+
R4.anyPass([
|
|
416
|
+
// Include semantic tokens in the output
|
|
417
|
+
isSemanticToken,
|
|
418
|
+
// Include global color tokens
|
|
419
|
+
isGlobalColorToken
|
|
420
|
+
]),
|
|
421
|
+
// Don't include color category tokens -- they are exported separately
|
|
422
|
+
(t) => !isColorCategoryToken(t)
|
|
423
|
+
])
|
|
424
|
+
);
|
|
425
|
+
const formattedMap = filteredAllTokens.map((token) => ({
|
|
426
|
+
token,
|
|
427
|
+
formatted: format(token)
|
|
428
|
+
}));
|
|
429
|
+
const formattedTokens = formattedMap.map(R4.view(R4.lensProp("formatted"))).join("\n");
|
|
430
|
+
const content = `{
|
|
431
|
+
${formattedTokens}
|
|
432
|
+
${colorSchemeProperty}}
|
|
433
|
+
`;
|
|
434
|
+
const autoSelectorContent = ["light", "dark"].includes(colorScheme_) ? prefersColorScheme(colorScheme_, content) : "";
|
|
435
|
+
const body = R4.isNotNil(layer) ? `@layer ${layer} {
|
|
436
|
+
${selector} ${content} ${autoSelectorContent}
|
|
437
|
+
}
|
|
438
|
+
` : `${selector} ${content} ${autoSelectorContent}
|
|
439
|
+
`;
|
|
440
|
+
return body;
|
|
441
|
+
}
|
|
442
|
+
};
|
|
443
|
+
var colorCategory = {
|
|
444
|
+
name: "ds/css-colorcategory",
|
|
445
|
+
format: async ({ dictionary, options, platform }) => {
|
|
446
|
+
const { outputReferences, usesDtcg } = options;
|
|
447
|
+
const { selector, layer, files } = platform;
|
|
448
|
+
const destination = files?.[0]?.destination;
|
|
449
|
+
const format = R4.compose(
|
|
450
|
+
createPropertyFormatter({
|
|
451
|
+
outputReferences,
|
|
452
|
+
dictionary,
|
|
453
|
+
format: "css",
|
|
454
|
+
usesDtcg
|
|
455
|
+
}),
|
|
456
|
+
(token) => ({
|
|
457
|
+
...token,
|
|
458
|
+
name: token.name.replace(/color-\w+-/, "color-"),
|
|
459
|
+
original: {
|
|
460
|
+
...token.original,
|
|
461
|
+
$value: new RegExp(`color-(${colorCategories.main}|${colorCategories.support})-`).test(token.name) ? token.original.$value : `{${token.path.join(".")}}`
|
|
462
|
+
}
|
|
463
|
+
})
|
|
464
|
+
);
|
|
465
|
+
const formattedMap = dictionary.allTokens.map((token) => ({
|
|
466
|
+
token,
|
|
467
|
+
formatted: format(token)
|
|
468
|
+
}));
|
|
469
|
+
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
470
|
+
const formattedTokens = formattedMap.map(R4.view(R4.lensProp("formatted"))).join("\n");
|
|
471
|
+
const content = `{
|
|
472
|
+
${formattedTokens}
|
|
473
|
+
}
|
|
474
|
+
`;
|
|
475
|
+
const body = R4.isNotNil(layer) ? `@layer ${layer} {
|
|
476
|
+
${selector} ${content}
|
|
477
|
+
}
|
|
478
|
+
` : `${selector} ${content}
|
|
479
|
+
`;
|
|
480
|
+
return body;
|
|
481
|
+
}
|
|
482
|
+
};
|
|
483
|
+
|
|
484
|
+
// src/tokens/process/formats/css/semantic.ts
|
|
485
|
+
import * as R5 from "ramda";
|
|
486
|
+
import { createPropertyFormatter as createPropertyFormatter2 } from "style-dictionary/utils";
|
|
487
|
+
var isNumericBorderRadiusToken = (t) => t.path[0] === "border-radius" && isDigit(t.path[1]);
|
|
488
|
+
var isNumericSizeToken = (t) => pathStartsWithOneOf(["size"], t) && isDigit(t.path[1]);
|
|
489
|
+
var isSizeToken = (t) => pathStartsWithOneOf(["size"], t);
|
|
490
|
+
var isInlineTokens = R5.anyPass([isNumericBorderRadiusToken, isNumericSizeToken, isSizeToken]);
|
|
491
|
+
var overrideSizingFormula = (format, token) => {
|
|
492
|
+
const [name, value] = format(token).split(":");
|
|
493
|
+
const calc = value.replace(`var(--ds-size-mode-font-size)`, "1em").replace(/floor\((.*)\);/, "calc($1)");
|
|
494
|
+
const round = `round(down, ${calc}, 1px)`;
|
|
495
|
+
return {
|
|
496
|
+
name,
|
|
497
|
+
round,
|
|
498
|
+
calc
|
|
499
|
+
};
|
|
500
|
+
};
|
|
501
|
+
var formatSizingTokens = (format, tokens) => R5.reduce(
|
|
502
|
+
(acc, token) => {
|
|
503
|
+
const { round, calc, name } = overrideSizingFormula(format, token);
|
|
504
|
+
return {
|
|
505
|
+
tokens: [...acc.tokens, token],
|
|
506
|
+
round: [...acc.round, `${name}: ${round};`],
|
|
507
|
+
calc: [...acc.calc, `${name}: ${calc};`]
|
|
508
|
+
};
|
|
509
|
+
},
|
|
510
|
+
{ tokens: [], round: [], calc: [] },
|
|
511
|
+
tokens
|
|
512
|
+
);
|
|
513
|
+
var sizingTemplate = ({ round, calc }) => `
|
|
514
|
+
${calc.join("\n")}
|
|
515
|
+
|
|
516
|
+
@supports (width: round(down, .1em, 1px)) {
|
|
517
|
+
${round.join("\n")}
|
|
518
|
+
}`;
|
|
519
|
+
var semantic = {
|
|
520
|
+
name: "ds/css-semantic",
|
|
521
|
+
format: async ({ dictionary, options, platform }) => {
|
|
522
|
+
const { outputReferences, usesDtcg } = options;
|
|
523
|
+
const { selector, layer, files } = platform;
|
|
524
|
+
const destination = files?.[0]?.destination;
|
|
525
|
+
const format = createPropertyFormatter2({
|
|
526
|
+
outputReferences,
|
|
527
|
+
dictionary,
|
|
528
|
+
format: "css",
|
|
529
|
+
usesDtcg
|
|
530
|
+
});
|
|
531
|
+
const tokens = inlineTokens(isInlineTokens, dictionary.allTokens);
|
|
532
|
+
const filteredTokens = R5.reject((token) => token.name.includes("ds-size-mode-font-size"), tokens);
|
|
533
|
+
const [sizingTokens, restTokens] = R5.partition(
|
|
534
|
+
(t) => pathStartsWithOneOf(["_size"], t) && isDigit(t.path[1]),
|
|
535
|
+
filteredTokens
|
|
536
|
+
);
|
|
537
|
+
const formattedSizingTokens = formatSizingTokens(format, sizingTokens);
|
|
538
|
+
const formattedMap = restTokens.map((token) => ({
|
|
539
|
+
token,
|
|
540
|
+
formatted: format(token)
|
|
541
|
+
}));
|
|
542
|
+
const formattedSizingMap = formattedSizingTokens.round.map((t, i) => ({
|
|
543
|
+
token: formattedSizingTokens.tokens[i],
|
|
544
|
+
formatted: t
|
|
545
|
+
}));
|
|
546
|
+
buildOptions.buildTokenFormats[destination] = [...formattedMap, ...formattedSizingMap];
|
|
547
|
+
const sizingSnippet = sizingTemplate(formattedSizingTokens);
|
|
548
|
+
const formattedTokens = formattedMap.map(R5.view(R5.lensProp("formatted"))).concat(sizingSnippet);
|
|
549
|
+
const content = `{
|
|
550
|
+
${formattedTokens.join("\n")}
|
|
551
|
+
}
|
|
552
|
+
`;
|
|
553
|
+
const body = R5.isNotNil(layer) ? `@layer ${layer} {
|
|
554
|
+
${selector} ${content}
|
|
555
|
+
}
|
|
556
|
+
` : `${selector} ${content}
|
|
557
|
+
`;
|
|
558
|
+
return body;
|
|
559
|
+
}
|
|
560
|
+
};
|
|
561
|
+
|
|
562
|
+
// src/tokens/process/formats/css/typography.ts
|
|
563
|
+
import * as R6 from "ramda";
|
|
564
|
+
import { createPropertyFormatter as createPropertyFormatter3 } from "style-dictionary/utils";
|
|
565
|
+
var typographyFontFamilyPredicate = R6.allPass([
|
|
566
|
+
R6.pathSatisfies(R6.includes("typography"), ["path"]),
|
|
567
|
+
R6.pathSatisfies(R6.includes("fontFamily"), ["path"])
|
|
568
|
+
]);
|
|
569
|
+
var typography = {
|
|
570
|
+
name: "ds/css-typography",
|
|
571
|
+
format: async ({ dictionary, options, platform }) => {
|
|
572
|
+
const { outputReferences, usesDtcg } = options;
|
|
573
|
+
const { selector, layer, files } = platform;
|
|
574
|
+
const destination = files?.[0]?.destination;
|
|
575
|
+
const format = createPropertyFormatter3({
|
|
576
|
+
outputReferences,
|
|
577
|
+
dictionary,
|
|
578
|
+
format: "css",
|
|
579
|
+
usesDtcg
|
|
580
|
+
});
|
|
581
|
+
const filteredTokens = R6.reject(typographyFontFamilyPredicate, dictionary.allTokens);
|
|
582
|
+
const formattedMap = filteredTokens.map((token) => ({
|
|
583
|
+
token,
|
|
584
|
+
formatted: format(token)
|
|
585
|
+
}));
|
|
586
|
+
buildOptions.buildTokenFormats[destination] = formattedMap;
|
|
587
|
+
const formattedTokens = formattedMap.map(R6.view(R6.lensProp("formatted"))).join("\n");
|
|
588
|
+
const content = selector ? `${selector} {
|
|
589
|
+
${formattedTokens}
|
|
590
|
+
}` : formattedTokens;
|
|
591
|
+
const body = R6.isNotNil(layer) ? `@layer ${layer} {
|
|
592
|
+
${content}
|
|
593
|
+
}` : content;
|
|
594
|
+
return body;
|
|
595
|
+
}
|
|
596
|
+
};
|
|
597
|
+
|
|
598
|
+
// src/tokens/process/formats/css.ts
|
|
599
|
+
var formats = {
|
|
600
|
+
colorScheme,
|
|
601
|
+
colorCategory,
|
|
602
|
+
semantic,
|
|
603
|
+
typography
|
|
578
604
|
};
|
|
579
605
|
|
|
580
606
|
// src/tokens/process/transformers.ts
|
|
@@ -765,90 +791,6 @@ var semanticVariables = ({ theme }) => {
|
|
|
765
791
|
};
|
|
766
792
|
};
|
|
767
793
|
|
|
768
|
-
// src/tokens/process/configs/storefront.ts
|
|
769
|
-
import * as R11 from "ramda";
|
|
770
|
-
import { outputReferencesFilter as outputReferencesFilter2 } from "style-dictionary/utils";
|
|
771
|
-
|
|
772
|
-
// src/tokens/process/formats/js-tokens.ts
|
|
773
|
-
import * as R10 from "ramda";
|
|
774
|
-
import { createPropertyFormatter as createPropertyFormatter4, fileHeader } from "style-dictionary/utils";
|
|
775
|
-
var groupByType = R10.groupBy((token) => getType(token));
|
|
776
|
-
var removeUnwatedTokens = R10.pipe(
|
|
777
|
-
R10.reject((token) => isColorCategoryToken(token)),
|
|
778
|
-
R10.reject((token) => R10.any((path) => path.startsWith("_"))(token.path))
|
|
779
|
-
);
|
|
780
|
-
var dissocExtensions = R10.pipe(R10.dissoc("$extensions"), R10.dissocPath(["original", "$extensions"]));
|
|
781
|
-
var removeUnwatedProps = R10.map((token) => dissocExtensions(token));
|
|
782
|
-
var toCssVarName = R10.pipe(R10.split(":"), R10.head, R10.trim);
|
|
783
|
-
var jsTokens = {
|
|
784
|
-
name: "ds/js-tokens",
|
|
785
|
-
format: async ({ dictionary, file, options }) => {
|
|
786
|
-
const { usesDtcg, outputReferences } = options;
|
|
787
|
-
const format = createPropertyFormatter4({
|
|
788
|
-
outputReferences,
|
|
789
|
-
dictionary,
|
|
790
|
-
format: "css",
|
|
791
|
-
usesDtcg
|
|
792
|
-
});
|
|
793
|
-
const formatTokens = R10.map((token) => {
|
|
794
|
-
if (pathStartsWithOneOf(["size", "_size"], token)) {
|
|
795
|
-
const { calc, name } = overrideSizingFormula(format, token);
|
|
796
|
-
return {
|
|
797
|
-
...token,
|
|
798
|
-
name: name.trim(),
|
|
799
|
-
$value: calc.trim()
|
|
800
|
-
};
|
|
801
|
-
}
|
|
802
|
-
return {
|
|
803
|
-
...token,
|
|
804
|
-
name: toCssVarName(format(token))
|
|
805
|
-
};
|
|
806
|
-
});
|
|
807
|
-
const processTokens = R10.pipe(removeUnwatedTokens, removeUnwatedProps, formatTokens, groupByType);
|
|
808
|
-
const tokens = processTokens(inlineTokens(isInlineTokens, dictionary.allTokens));
|
|
809
|
-
const content = Object.entries(tokens).map(
|
|
810
|
-
([name, token]) => `export const ${name} = ${JSON.stringify(token, null, 2).replace(/"([^"]+)":/g, "$1:")}
|
|
811
|
-
`
|
|
812
|
-
).join("\n");
|
|
813
|
-
return fileHeader({ file }).then((fileHeaderText) => fileHeaderText + content);
|
|
814
|
-
}
|
|
815
|
-
};
|
|
816
|
-
|
|
817
|
-
// src/tokens/process/configs/storefront.ts
|
|
818
|
-
var typescriptTokens = ({ "color-scheme": colorScheme2, theme }) => {
|
|
819
|
-
return {
|
|
820
|
-
preprocessors: ["tokens-studio"],
|
|
821
|
-
platforms: {
|
|
822
|
-
ts: {
|
|
823
|
-
prefix,
|
|
824
|
-
basePxFontSize,
|
|
825
|
-
transforms: dsTransformers,
|
|
826
|
-
buildPath: `${theme}/`,
|
|
827
|
-
files: [
|
|
828
|
-
{
|
|
829
|
-
destination: `${colorScheme2}.ts`,
|
|
830
|
-
format: jsTokens.name,
|
|
831
|
-
filter: (token) => {
|
|
832
|
-
if (pathStartsWithOneOf(["border-width", "letter-spacing", "border-radius"], token) && !R11.includes("semantic", token.filePath))
|
|
833
|
-
return false;
|
|
834
|
-
const isSemanticColor = R11.includes("semantic", token.filePath) && typeEquals(["color"], token);
|
|
835
|
-
const wantedTypes = typeEquals(["shadow", "dimension", "typography", "opacity"], token);
|
|
836
|
-
return isSemanticColor || wantedTypes;
|
|
837
|
-
}
|
|
838
|
-
}
|
|
839
|
-
],
|
|
840
|
-
options: {
|
|
841
|
-
outputReferences: (token, options) => {
|
|
842
|
-
const include = pathStartsWithOneOf(["border-radius"], token);
|
|
843
|
-
const isWantedSize = pathStartsWithOneOf(["size", "_size"], token) && isDigit(token.path[1]);
|
|
844
|
-
return (include || isWantedSize) && outputReferencesFilter2(token, options);
|
|
845
|
-
}
|
|
846
|
-
}
|
|
847
|
-
}
|
|
848
|
-
}
|
|
849
|
-
};
|
|
850
|
-
};
|
|
851
|
-
|
|
852
794
|
// src/tokens/process/configs/typography.ts
|
|
853
795
|
import { expandTypesMap } from "@tokens-studio/sd-transforms";
|
|
854
796
|
var typographyVariables = ({ theme, typography: typography2 }) => {
|
|
@@ -875,6 +817,7 @@ var typographyVariables = ({ theme, typography: typography2 }) => {
|
|
|
875
817
|
sizeRem.name,
|
|
876
818
|
"ts/size/lineheight",
|
|
877
819
|
"ts/typography/fontWeight",
|
|
820
|
+
"ts/size/css/letterspacing",
|
|
878
821
|
typographyName.name
|
|
879
822
|
],
|
|
880
823
|
files: [
|
|
@@ -902,7 +845,6 @@ StyleDictionary2.registerTransform(sizeRem);
|
|
|
902
845
|
StyleDictionary2.registerTransform(typographyName);
|
|
903
846
|
StyleDictionary2.registerTransform(resolveMath);
|
|
904
847
|
StyleDictionary2.registerTransform(unitless);
|
|
905
|
-
StyleDictionary2.registerFormat(jsTokens);
|
|
906
848
|
for (const format of Object.values(formats)) {
|
|
907
849
|
StyleDictionary2.registerFormat(format);
|
|
908
850
|
}
|
|
@@ -916,8 +858,7 @@ var configs = {
|
|
|
916
858
|
warningColorVariables: colorCategoryVariables({ category: "builtin", color: "warning" }),
|
|
917
859
|
infoColorVariables: colorCategoryVariables({ category: "builtin", color: "info" }),
|
|
918
860
|
typographyVariables,
|
|
919
|
-
semanticVariables
|
|
920
|
-
typescriptTokens
|
|
861
|
+
semanticVariables
|
|
921
862
|
};
|
|
922
863
|
var getConfigsForThemeDimensions = (getConfig, processed$themes, dimensions, options) => {
|
|
923
864
|
const { tokensDir, tokenSets } = options;
|
|
@@ -933,7 +874,7 @@ var getConfigsForThemeDimensions = (getConfig, processed$themes, dimensions, opt
|
|
|
933
874
|
obj.filePath = tokenSet;
|
|
934
875
|
}
|
|
935
876
|
});
|
|
936
|
-
tokenSource.tokens =
|
|
877
|
+
tokenSource.tokens = R10.mergeDeepRight(tokenSource.tokens, tokensWithFilePath);
|
|
937
878
|
}
|
|
938
879
|
}
|
|
939
880
|
} else {
|
|
@@ -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;AAarD,eAAO,MAAM,WAAW,EAAE,MAgDzB,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,MAwC3B,CAAC"}
|