@rte-ds/core 1.2.1 → 1.2.2

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.
Files changed (30) hide show
  1. package/components/badge/badge.utils.ts +1 -1
  2. package/components/badge/docs/Behaviors.scss +1 -1
  3. package/components/breadcrumbs/docs/Options.scss +1 -1
  4. package/components/breadcrumbs/docs/Usage.scss +1 -1
  5. package/components/grid/grid.stories.scss +1 -1
  6. package/components/select/docs/Options.scss +1 -1
  7. package/components/select/docs/OverviewOptions.scss +1 -1
  8. package/components/select/docs/Usage.scss +1 -1
  9. package/components/side-nav/nav-item/nav-item.utils.ts +1 -1
  10. package/components/tooltip/tooltip.utils.ts +1 -1
  11. package/css/rte-fonts.css +1 -1
  12. package/package.json +14 -1
  13. package/CHANGELOG.md +0 -320
  14. package/css-font-generator.ts +0 -51
  15. package/eslint.config.js +0 -1
  16. package/scripts/design-tokens/common.ts +0 -35
  17. package/scripts/design-tokens/generator.ts +0 -24
  18. package/scripts/design-tokens/primitives-generator.spec.ts +0 -84
  19. package/scripts/design-tokens/primitives-generator.ts +0 -66
  20. package/scripts/design-tokens/sourceFiles/primitives.json +0 -2075
  21. package/scripts/design-tokens/sourceFiles/tokens.json +0 -10561
  22. package/scripts/design-tokens/tokens-generator.spec.ts +0 -184
  23. package/scripts/design-tokens/tokens-generator.ts +0 -155
  24. package/scripts/design-tokens/tokens-generators/colors.ts +0 -142
  25. package/scripts/design-tokens/tokens-generators/layout.ts +0 -22
  26. package/scripts/design-tokens/tokens-generators/opacity.ts +0 -14
  27. package/scripts/design-tokens/tokens-generators/shadows.ts +0 -18
  28. package/scripts/design-tokens/tokens-generators/typography.ts +0 -58
  29. package/scripts/design-tokens/tokens-generators/zIndex.ts +0 -18
  30. package/tsconfig.json +0 -12
@@ -1,184 +0,0 @@
1
- import fs from "fs";
2
-
3
- import { describe, it, expect, vi, beforeEach } from "vitest";
4
-
5
- import { Collection, generateTokensScssFiles } from "./tokens-generator";
6
- import { ColorMode, generateThemeIndexScssFile } from "./tokens-generators/colors";
7
-
8
- vi.mock("fs");
9
-
10
- describe("tokens-generator", () => {
11
- beforeEach(() => {
12
- vi.clearAllMocks();
13
- });
14
-
15
- it("génère correctement un fichier SCSS de couleurs pour un mode", () => {
16
- const colorTokens = [
17
- {
18
- collection: Collection.COLORS,
19
- mode: ColorMode.BLEU_ICEBERG_LIGHT,
20
- variables: {
21
- background: {
22
- default: { $type: "color", $scopes: [], $value: "Semantic.bleu-iceberg-light.bleu-100" },
23
- hover: { $type: "color", $scopes: [], $value: "Semantic.bleu-iceberg-light.bleu-200" },
24
- },
25
- border: {
26
- primary: { $type: "color", $scopes: [], $value: "Semantic.bleu-iceberg-light.rouge-500" },
27
- },
28
- },
29
- },
30
- ];
31
- const writeSpy = vi.spyOn(fs, "writeFileSync");
32
- generateTokensScssFiles(colorTokens);
33
- expect(writeSpy).toHaveBeenCalledWith(
34
- expect.stringContaining("bleu-iceberg-light.scss"),
35
- expect.stringContaining('"background-default": $bleu-100,'),
36
- );
37
- expect(writeSpy).toHaveBeenCalledWith(
38
- expect.stringContaining("bleu-iceberg-light.scss"),
39
- expect.stringContaining('"background-hover": $bleu-200,'),
40
- );
41
- });
42
-
43
- it("génère correctement le fichier _main.scss pour les thèmes", () => {
44
- const writeSpy = vi.spyOn(fs, "writeFileSync");
45
- generateThemeIndexScssFile();
46
- expect(writeSpy).toHaveBeenCalledWith(
47
- expect.stringContaining("themes/_main.scss"),
48
- expect.stringContaining('@forward "bleu-iceberg-light";'),
49
- );
50
- expect(writeSpy).toHaveBeenCalledWith(
51
- expect.stringContaining("themes/_main.scss"),
52
- expect.stringContaining('@forward "vert-foret-dark";'),
53
- );
54
- });
55
-
56
- it("génère correctement un fichier SCSS de typo", () => {
57
- const typoTokens = [
58
- {
59
- collection: Collection.TYPOGRAPHY,
60
- mode: "desktop",
61
- variables: {
62
- heading: {
63
- xl: {
64
- bold: {
65
- main: { $type: "typography", $scopes: [], $value: "Type.desktop.heading.xl.bold.main" },
66
- },
67
- },
68
- },
69
- },
70
- },
71
- ];
72
- const writeSpy = vi.spyOn(fs, "writeFileSync");
73
- generateTokensScssFiles(typoTokens);
74
- expect(writeSpy).toHaveBeenCalledWith(
75
- expect.stringContaining("_typography.scss"),
76
- expect.stringContaining("$heading-xl-bold-main: $heading-xl-bold-main;"),
77
- );
78
- });
79
-
80
- it("génère correctement un fichier SCSS d'opacité", () => {
81
- const opacityTokens = [
82
- {
83
- collection: Collection.OPACITY,
84
- mode: "",
85
- variables: {
86
- "80%": { $type: "opacity", $scopes: [], $value: 0.8 },
87
- "50%": { $type: "opacity", $scopes: [], $value: 0.5 },
88
- },
89
- },
90
- ];
91
- const writeSpy = vi.spyOn(fs, "writeFileSync");
92
- generateTokensScssFiles(opacityTokens);
93
- expect(writeSpy).toHaveBeenCalledWith(
94
- expect.stringContaining("_opacity.scss"),
95
- expect.stringContaining("$opacity-80: 80%;"),
96
- );
97
- expect(writeSpy).toHaveBeenCalledWith(
98
- expect.stringContaining("_opacity.scss"),
99
- expect.stringContaining("$opacity-50: 50%;"),
100
- );
101
- });
102
-
103
- it("génère correctement un fichier SCSS de shadow", () => {
104
- const shadowTokens = [
105
- {
106
- collection: Collection.SHADOWS,
107
- mode: "",
108
- variables: {
109
- elevation: {
110
- shadow1: { $type: "shadow", $scopes: [], $value: "0 1px 2px #00000033" },
111
- shadow2: { $type: "shadow", $scopes: [], $value: "0 2px 4px #00000033" },
112
- },
113
- },
114
- },
115
- ];
116
- const writeSpy = vi.spyOn(fs, "writeFileSync");
117
- generateTokensScssFiles(shadowTokens);
118
- expect(writeSpy).toHaveBeenCalledWith(
119
- expect.stringContaining("_shadows.scss"),
120
- expect.stringContaining("$elevation-shadow1: 0 1px 2px #00000033;"),
121
- );
122
- expect(writeSpy).toHaveBeenCalledWith(
123
- expect.stringContaining("_shadows.scss"),
124
- expect.stringContaining("$elevation-shadow2: 0 2px 4px #00000033;"),
125
- );
126
- });
127
-
128
- it("génère correctement un fichier SCSS de layout", () => {
129
- const layoutTokens = [
130
- {
131
- collection: Collection.LAYOUT,
132
- mode: "",
133
- variables: {
134
- spacing: {
135
- sm: { $type: "layout", $scopes: [], $value: 8 },
136
- md: { $type: "layout", $scopes: [], $value: 16 },
137
- },
138
- "column-number": {
139
- default: { $type: "layout", $scopes: [], $value: 12 },
140
- },
141
- },
142
- },
143
- ];
144
- const writeSpy = vi.spyOn(fs, "writeFileSync");
145
- generateTokensScssFiles(layoutTokens);
146
- expect(writeSpy).toHaveBeenCalledWith(
147
- expect.stringContaining("_layout.scss"),
148
- expect.stringContaining("$spacing-sm: 8px;"),
149
- );
150
- expect(writeSpy).toHaveBeenCalledWith(
151
- expect.stringContaining("_layout.scss"),
152
- expect.stringContaining("$spacing-md: 16px;"),
153
- );
154
- expect(writeSpy).toHaveBeenCalledWith(
155
- expect.stringContaining("_layout.scss"),
156
- expect.stringContaining("$column-number-default: 12;"),
157
- );
158
- });
159
-
160
- it("génère correctement un fichier SCSS pour le cas par défaut (DefaultToken)", () => {
161
- const defaultTokens = [
162
- {
163
- collection: Collection.SPACING,
164
- mode: "",
165
- variables: {
166
- space: {
167
- sm: { $type: "spacing", $scopes: [], $value: 4 },
168
- md: { $type: "spacing", $scopes: [], $value: 8 },
169
- },
170
- },
171
- },
172
- ];
173
- const writeSpy = vi.spyOn(fs, "writeFileSync");
174
- generateTokensScssFiles(defaultTokens);
175
- expect(writeSpy).toHaveBeenCalledWith(
176
- expect.stringContaining("_spacing.scss"),
177
- expect.stringContaining("$space-sm: 4px;"),
178
- );
179
- expect(writeSpy).toHaveBeenCalledWith(
180
- expect.stringContaining("_spacing.scss"),
181
- expect.stringContaining("$space-md: 8px;"),
182
- );
183
- });
184
- });
@@ -1,155 +0,0 @@
1
- import fs from "fs";
2
- import path from "path";
3
-
4
- import {
5
- buildScssFileName,
6
- buildScssVariable,
7
- generateScssFile,
8
- PrivacyLevel,
9
- tokensOutputDir,
10
- TokenValue,
11
- UNIT,
12
- } from "./common";
13
- import {
14
- ColorMode,
15
- ColorToken,
16
- extractColors,
17
- generateThemeIndexScssFile,
18
- generateThemesFile,
19
- } from "./tokens-generators/colors";
20
- import { extractLayout, LayoutToken } from "./tokens-generators/layout";
21
- import { extractOpacity, OpacityToken } from "./tokens-generators/opacity";
22
- import { extractShadows, ShadowToken } from "./tokens-generators/shadows";
23
- import { extractTypography, TypographyToken } from "./tokens-generators/typography";
24
- import { generateZIndexTokensFile } from "./tokens-generators/zIndex";
25
-
26
- export enum Collection {
27
- COLORS = "Semantic : Colors",
28
- TYPOGRAPHY = "Semantic : Type",
29
- SPACING = "Spacing",
30
- BORDER = "Border",
31
- SHADOWS = "Shadows",
32
- LAYOUT = "Layout",
33
- OPACITY = "Opacity",
34
- SIZE = "Size",
35
- }
36
-
37
- export const TokenPrivacyLevel: Record<Collection, PrivacyLevel> = {
38
- [Collection.COLORS]: PrivacyLevel.PUBLIC,
39
- [Collection.TYPOGRAPHY]: PrivacyLevel.PUBLIC,
40
- [Collection.SPACING]: PrivacyLevel.PUBLIC,
41
- [Collection.BORDER]: PrivacyLevel.PUBLIC,
42
- [Collection.SHADOWS]: PrivacyLevel.PRIVATE,
43
- [Collection.LAYOUT]: PrivacyLevel.PUBLIC,
44
- [Collection.OPACITY]: PrivacyLevel.PUBLIC,
45
- [Collection.SIZE]: PrivacyLevel.PRIVATE,
46
- };
47
-
48
- export interface DefaultToken {
49
- [category: string]: {
50
- [subCategory: string]: TokenValue;
51
- };
52
- }
53
-
54
- export type TokenVariables = TypographyToken | ShadowToken | LayoutToken | DefaultToken | OpacityToken | ColorToken;
55
-
56
- export interface TokenItem {
57
- collection: Collection;
58
- mode: string | ColorMode;
59
- variables: TokenVariables;
60
- }
61
-
62
- if (!fs.existsSync(tokensOutputDir)) {
63
- fs.mkdirSync(tokensOutputDir);
64
- }
65
-
66
- export function generateTokensScssFiles(json: TokenItem[]): void {
67
- for (const tokenItem of json) {
68
- let scss = `// This file is auto-generated. Do not edit directly.\n\n`;
69
- let filename = "";
70
- switch (tokenItem.collection) {
71
- case Collection.COLORS:
72
- {
73
- const mode = tokenItem.mode as ColorMode;
74
- filename = buildScssFileName(mode);
75
- const filePath = path.join(tokensOutputDir, TokenPrivacyLevel[Collection.COLORS], "themes", "base", filename);
76
- scss += extractColors(tokenItem.variables as ColorToken, mode);
77
- generateScssFile(scss, filePath);
78
- }
79
- break;
80
-
81
- case Collection.TYPOGRAPHY:
82
- if (tokenItem.mode === "desktop") {
83
- console.log(" ☑️ Typography");
84
- filename = `_typography.scss`;
85
- const filePath = path.join(tokensOutputDir, TokenPrivacyLevel[Collection.TYPOGRAPHY], filename);
86
-
87
- scss += extractTypography(tokenItem.variables as TypographyToken);
88
- generateScssFile(scss, filePath);
89
- } else {
90
- console.log(" 🚫 Skipping typography for mode " + tokenItem.mode);
91
- }
92
- break;
93
-
94
- case Collection.OPACITY:
95
- {
96
- console.log(" ☑️ Opacity");
97
- filename = buildScssFileName(tokenItem.collection);
98
- const filePath = path.join(tokensOutputDir, TokenPrivacyLevel[Collection.OPACITY], filename);
99
-
100
- scss += extractOpacity(tokenItem.variables as OpacityToken, tokenItem.collection);
101
- generateScssFile(scss, filePath);
102
- }
103
- break;
104
-
105
- case Collection.SHADOWS:
106
- {
107
- console.log(" ☑️ Shadows");
108
- filename = buildScssFileName(tokenItem.collection);
109
- const filePath = path.join(tokensOutputDir, TokenPrivacyLevel[Collection.SHADOWS], filename);
110
-
111
- scss += extractShadows(tokenItem.variables as ShadowToken);
112
- generateScssFile(scss, filePath);
113
- }
114
- break;
115
-
116
- case Collection.LAYOUT:
117
- {
118
- console.log(" ☑️ Layout");
119
- filename = buildScssFileName(tokenItem.collection);
120
- const filePath = path.join(tokensOutputDir, TokenPrivacyLevel[Collection.LAYOUT], filename);
121
-
122
- scss += extractLayout(tokenItem.variables as LayoutToken);
123
- generateScssFile(scss, filePath);
124
- }
125
- break;
126
-
127
- default:
128
- {
129
- console.log(` ☑️ ${tokenItem.collection}`);
130
- filename = buildScssFileName(tokenItem.collection);
131
- const filePath = path.join(tokensOutputDir, TokenPrivacyLevel[tokenItem.collection], filename);
132
-
133
- scss += extractDefault(tokenItem.variables as DefaultToken);
134
- generateScssFile(scss, filePath);
135
- }
136
- break;
137
- }
138
- }
139
-
140
- generateZIndexTokensFile();
141
- generateThemesFile();
142
- generateThemeIndexScssFile();
143
- console.log(" ☑️ Themes");
144
- }
145
-
146
- function extractDefault(variables: DefaultToken): string {
147
- let scss = "";
148
- for (const category in variables) {
149
- for (const subCategory in variables[category]) {
150
- const token = variables[category][subCategory];
151
- scss += buildScssVariable([category, subCategory], `${token.$value}${UNIT}`);
152
- }
153
- }
154
- return scss;
155
- }
@@ -1,142 +0,0 @@
1
- import path from "path";
2
-
3
- import { generateScssFile, INDENT, PrivacyLevel, tokensOutputDir } from "../common";
4
-
5
- export enum ColorTheme {
6
- BLEU_ICEBERG = "bleu-iceberg",
7
- VIOLET = "violet",
8
- VERT_FORET = "vert-foret",
9
- }
10
-
11
- export enum ColorMode {
12
- BLEU_ICEBERG_LIGHT = "bleu-iceberg-light",
13
- BLEU_ICEBERG_DARK = "bleu-iceberg-dark",
14
- VIOLET_LIGHT = "violet-light",
15
- VIOLET_DARK = "violet-dark",
16
- VERT_FORET_LIGHT = "vert-foret-light",
17
- VERT_FORET_DARK = "vert-foret-dark",
18
- }
19
-
20
- export interface ColorTokenValue {
21
- $type: string;
22
- $scopes: string[];
23
- $value: string;
24
- }
25
-
26
- export interface ColorToken {
27
- [category: string]:
28
- | {
29
- [colorTokenName: string]: ColorTokenValue;
30
- }
31
- | ColorTokenValue;
32
- }
33
-
34
- const rawColorCategories = ["gradient", "elevation"];
35
-
36
- export function extractColors(variables: ColorToken, mode: ColorMode): string {
37
- let scss = `@use '../../../../primitives/colors' as *;\n`;
38
- scss += `@use '../../../../primitives/devColors' as *;\n\n`;
39
- scss += `$${mode}: (\n`;
40
- for (const category in variables) {
41
- const categoryTokens = variables[category];
42
- if ((categoryTokens as ColorTokenValue).$value) {
43
- const sanitizedCategory = category.replace(/ /g, "-");
44
- scss += extractTokenValue(categoryTokens as ColorTokenValue, mode, [sanitizedCategory]);
45
- } else {
46
- scss += processSubTokens(categoryTokens as Record<string, ColorTokenValue>, mode, category, [category]);
47
- }
48
- }
49
- scss += addDevColors(mode);
50
- scss += ");\n";
51
- return scss;
52
- }
53
-
54
- export function generateThemeIndexScssFile() {
55
- let scss = "";
56
- Object.values(ColorMode).forEach((mode) => {
57
- scss += `@forward "${mode}";\n`;
58
- });
59
- const pathFile = path.join(tokensOutputDir, PrivacyLevel.PUBLIC, "themes", "base", "_index.scss");
60
- generateScssFile(scss, pathFile);
61
- }
62
-
63
- export function generateThemesFile() {
64
- let scss = `// This file is auto-generated. Do not edit directly.\n\n`;
65
- scss += `@use 'base' as *;\n\n`;
66
- Object.values(ColorTheme).forEach((theme) => {
67
- scss += `$${theme}: (\n`;
68
- scss += `${INDENT.repeat(1)}"light": $${theme}-light,\n`;
69
- scss += `${INDENT.repeat(1)}"dark": $${theme}-dark,\n`;
70
- scss += `);\n`;
71
- });
72
-
73
- scss += `\n$themes: (\n`;
74
- Object.values(ColorTheme).forEach((theme) => {
75
- scss += `${INDENT.repeat(1)}"${theme.replace(/-/g, "_")}": $${theme},\n`;
76
- });
77
- scss += `);`;
78
-
79
- const filePath = path.join(tokensOutputDir, PrivacyLevel.PUBLIC, "themes", "_index.scss");
80
- generateScssFile(scss, filePath);
81
- }
82
-
83
- function extractTokenValue(token: ColorTokenValue, mode: ColorMode, path: string[]): string {
84
- const tokenValue = buildColorsScssVariableValue(token.$value, mode);
85
- if (rawColorCategories.includes(path[0])) {
86
- return buildColorScssVariable(path, `${tokenValue}`);
87
- } else {
88
- return buildColorScssVariable(path, `$${tokenValue}`);
89
- }
90
- }
91
-
92
- function processSubTokens(
93
- tokens: Record<string, ColorTokenValue>,
94
- mode: ColorMode,
95
- category: string,
96
- path: string[] = [],
97
- ): string {
98
- let scss = "";
99
- for (const subCategory in tokens) {
100
- const token = tokens[subCategory];
101
- if (token.$value) {
102
- scss += extractTokenValue(token, mode, [...path, subCategory]);
103
- } else {
104
- scss += processSubTokens(token as unknown as Record<string, ColorTokenValue>, mode, category, [
105
- ...path,
106
- subCategory,
107
- ]);
108
- }
109
- }
110
- return scss;
111
- }
112
-
113
- function buildColorScssVariable(variableName: string[], value: string): string {
114
- return `${INDENT.repeat(1)}"${variableName.join("-")}": ${value},\n`.toLowerCase();
115
- }
116
-
117
- function buildColorsScssVariableValue(rawValue: string, mode: ColorMode): string {
118
- const value = rawValue.split(`.${mode}.`)[1];
119
- return value ? value.replace(/\./g, "-") : rawValue;
120
- }
121
-
122
- function addDevColors(mode: ColorMode): string {
123
- const isLightMode = mode.includes("light");
124
- let scss = "";
125
- if (isLightMode) {
126
- scss += `${INDENT.repeat(1)}// TODO remove this color (not a real token)\n`;
127
- scss += `${INDENT.repeat(1)}"background-brand-hover-opacity-20": $${mode.replace("-light", "")}-700-opacity-20,\n`;
128
- scss += `${INDENT.repeat(1)}// TODO remove this color (not a real token)\n`;
129
- scss += `${INDENT.repeat(1)}"background-danger-hover-opacity-20": $rouge-indications-700-opacity-20,\n`;
130
- scss += `${INDENT.repeat(1)}// TODO remove this color (not a real token)\n`;
131
- scss += `${INDENT.repeat(1)}"background-hover-opacity-50": $greyscale-50-opacity-50,\n`;
132
- } else {
133
- scss += `${INDENT.repeat(1)}// TODO remove this color (not a real token)\n`;
134
- scss += `${INDENT.repeat(1)}"background-brand-hover-opacity-20": $${mode.replace("-dark", "")}-200-opacity-20,\n`;
135
- scss += `${INDENT.repeat(1)}// TODO remove this color (not a real token)\n`;
136
- scss += `${INDENT.repeat(1)}"background-danger-hover-opacity-20": $rouge-indications-500-opacity-20,\n`;
137
- scss += `${INDENT.repeat(1)}// TODO remove this color (not a real token)\n`;
138
- scss += `${INDENT.repeat(1)}"background-hover-opacity-50": $greyscale-800-opacity-50,\n`;
139
- }
140
-
141
- return scss;
142
- }
@@ -1,22 +0,0 @@
1
- import { buildScssVariable, TokenValue, UNIT } from "../common";
2
-
3
- export interface LayoutToken {
4
- [category: string]: {
5
- [size: string]: TokenValue;
6
- };
7
- }
8
-
9
- export function extractLayout(variables: LayoutToken): string {
10
- let scss = "";
11
- for (const category in variables) {
12
- for (const size in variables[category]) {
13
- const layoutToken = variables[category][size];
14
- if (category === "column-number") {
15
- scss += buildScssVariable([category, size], String(layoutToken.$value));
16
- } else {
17
- scss += buildScssVariable([category, size], `${layoutToken.$value}${UNIT}`);
18
- }
19
- }
20
- }
21
- return scss;
22
- }
@@ -1,14 +0,0 @@
1
- import { buildScssVariable, TokenValue } from "../common";
2
-
3
- export interface OpacityToken {
4
- [percentage: string]: TokenValue;
5
- }
6
-
7
- export function extractOpacity(variables: OpacityToken, collection: string): string {
8
- let scss = "";
9
- for (const percentage in variables) {
10
- const value = percentage.replace(/%$/, "");
11
- scss += buildScssVariable([collection, value], percentage);
12
- }
13
- return scss;
14
- }
@@ -1,18 +0,0 @@
1
- import { buildScssVariable, TokenValue, UNIT } from "../common";
2
-
3
- export interface ShadowToken {
4
- [category: string]: {
5
- [shadowTokenName: string]: TokenValue;
6
- };
7
- }
8
-
9
- export function extractShadows(variables: ShadowToken): string {
10
- let scss = "";
11
- for (const category in variables) {
12
- for (const shadowTokenName in variables[category]) {
13
- const shadowToken = variables[category][shadowTokenName];
14
- scss += buildScssVariable([category, shadowTokenName], `${String(shadowToken.$value)}${UNIT}`);
15
- }
16
- }
17
- return scss;
18
- }
@@ -1,58 +0,0 @@
1
- import { buildScssVariable, TokenValue } from "../common";
2
-
3
- export interface TypographyToken {
4
- [category: string]: {
5
- [size: string]: {
6
- [weight: string]: {
7
- [typographyTokenName: string]: TokenValue;
8
- };
9
- };
10
- };
11
- }
12
-
13
- export function extractTypography(variables: TypographyToken): string {
14
- let scss = "";
15
- scss += `@use '../../primitives/typography' as *;\n\n`;
16
- for (const category in variables) {
17
- scss += extractFromTypographyCategory(category, variables[category]);
18
- }
19
- return scss;
20
- }
21
-
22
- function extractFromTypographyCategory(category: string, categoryObj: TypographyToken[string]): string {
23
- let scss = "";
24
- for (const size in categoryObj) {
25
- scss += extractFromTypographySize(category, size, categoryObj[size]);
26
- }
27
- return scss;
28
- }
29
-
30
- function extractFromTypographySize(category: string, size: string, sizeObj: TypographyToken[string][string]): string {
31
- let scss = "";
32
- for (const weight in sizeObj) {
33
- scss += extractFromTypographyWeight(category, size, weight, sizeObj[weight]);
34
- }
35
- return scss;
36
- }
37
-
38
- function extractFromTypographyWeight(
39
- category: string,
40
- size: string,
41
- weight: string,
42
- weightObj: TypographyToken[string][string][string],
43
- ): string {
44
- let scss = "";
45
- for (const typographyTokenName in weightObj) {
46
- const typographyToken = weightObj[typographyTokenName];
47
- const rawTypographyTokenValue =
48
- typeof typographyToken.$value === "string"
49
- ? typographyToken.$value.split("Type.desktop.")[1]
50
- : typographyToken.$value;
51
- const typographyTokenValue =
52
- typeof rawTypographyTokenValue === "string"
53
- ? rawTypographyTokenValue.replace(/\./g, "-")
54
- : rawTypographyTokenValue;
55
- scss += buildScssVariable([category, size, weight, typographyTokenName], `$${typographyTokenValue}`);
56
- }
57
- return scss;
58
- }
@@ -1,18 +0,0 @@
1
- import path from "path";
2
-
3
- import { buildScssFileName, generateScssFile, PrivacyLevel, tokensOutputDir } from "../common";
4
-
5
- export function generateZIndexTokensFile() {
6
- let scss = `// This file is auto-generated. Do not edit directly.\n\n`;
7
-
8
- scss += `$level-0: 0;\n`;
9
- scss += `$level-1: 10;\n`;
10
- scss += `$level-2: 100;\n`;
11
-
12
- const filename = buildScssFileName("zIndex");
13
-
14
- const filePath = path.join(tokensOutputDir, PrivacyLevel.PRIVATE, filename);
15
-
16
- generateScssFile(scss, filePath);
17
- console.log(" ☑️ Z-Index");
18
- }
package/tsconfig.json DELETED
@@ -1,12 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "jsx": "react",
4
- "target": "es2019",
5
- "module": "commonjs",
6
- "esModuleInterop": true,
7
- "skipLibCheck": true,
8
- "forceConsistentCasingInFileNames": true,
9
- "strict": true
10
- },
11
- "exclude": ["node_modules"]
12
- }