Skip to content

Commit f477ef9

Browse files
author
Ján Hamara
committed
feat(design-token): start restructuring the design tokens
1 parent c3fe580 commit f477ef9

File tree

4 files changed

+148
-70
lines changed

4 files changed

+148
-70
lines changed

docs/index.storybook.mdx

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ import FigmaLogo from './assets/figma-logo-with-text.svg';
1414
import GithubLogo from './assets/github-logo.svg';
1515
import WarningIcon from './assets/warning-icon.svg';
1616

17+
import { Colors as ClassicGlobalColors } from '../src/essentials/Colors/Colors';
18+
import { generateGlobalTierCssVariables } from '../src/utils/generateCssVariables';
19+
1720
import { ArrowRightIcon, AlertIcon, PenIcon } from '../src/icons/';
1821
import { Box } from '../src/components/Box/Box';
1922
import { Button } from '../src/components/Button/Button';

src/essentials/Colors/Colors.ts

+122-52
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,62 @@
11
import { ColorSchema } from './types';
22

33
export const Colors = {
4-
WHITE: 'hsl(0, 0%, 100%)',
5-
BLACK: 'hsl(0, 0%, 0%)',
6-
AUTHENTIC_BLUE_1100: 'hsl(211, 100%, 6%)',
7-
AUTHENTIC_BLUE_900: 'hsl(211, 100%, 12%)',
8-
AUTHENTIC_BLUE_550: 'hsl(210, 16%, 46%)',
9-
AUTHENTIC_BLUE_350: 'hsl(213, 14%, 66%)',
10-
AUTHENTIC_BLUE_200: 'hsl(210, 14%, 80%)',
11-
AUTHENTIC_BLUE_50: 'hsl(220, 12%, 95%)',
12-
FREEDOM_RED_1000: 'hsl(352, 92%, 39%)',
13-
FREEDOM_RED_900: 'hsl(352, 100%, 52%)',
14-
ACTION_BLUE_1000: 'hsl(212, 92%, 34%)',
15-
ACTION_BLUE_900: 'hsl(212, 92%, 45%)',
16-
ACTION_BLUE_350: 'hsl(212, 75%, 78%)',
17-
ACTION_BLUE_150: 'hsl(213, 74%, 91%)',
18-
ACTION_BLUE_100: 'hsl(211, 74%, 94%)',
19-
ACTION_BLUE_50: 'hsl(210, 75%, 97%)',
20-
BUMPY_MAGENTA_1000: 'hsl(302, 100%, 37%)',
21-
BUMPY_MAGENTA_900: 'hsl(302, 100%, 50%)',
22-
BUMPY_MAGENTA_350: 'hsl(302, 100%, 81%)',
23-
BUMPY_MAGENTA_50: 'hsl(300, 100%, 97%)',
24-
POSITIVE_GREEN_1000: 'hsl(149, 92%, 24%)',
25-
POSITIVE_GREEN_900: 'hsl(149, 93%, 32%)',
26-
POSITIVE_GREEN_350: 'hsl(149, 44%, 74%)',
27-
POSITIVE_GREEN_50: 'hsl(147, 47%, 96%)',
28-
ATTENTION_YELLOW_900: 'hsl(48, 100%, 50%)',
29-
ATTENTION_YELLOW_350: 'hsl(48, 100%, 81%)',
30-
ATTENTION_YELLOW_50: 'hsl(47, 100%, 97%)',
31-
NEGATIVE_ORANGE_1000: 'hsl(21, 96%, 38%)',
32-
NEGATIVE_ORANGE_900: 'hsl(21, 100%, 51%)',
33-
NEGATIVE_ORANGE_350: 'hsl(21, 100%, 81%)',
34-
NEGATIVE_ORANGE_50: 'hsl(21, 100%, 97%)'
4+
white: 'hsl(0, 0%, 100%)',
5+
black: 'hsl(0, 0%, 0%)',
6+
blue: {
7+
primary: {
8+
1100: 'hsl(211, 100%, 6%)',
9+
900: 'hsl(211, 100%, 12%)',
10+
550: 'hsl(210, 16%, 46%)',
11+
350: 'hsl(213, 14%, 66%)',
12+
200: 'hsl(210, 14%, 80%)',
13+
50: 'hsl(220, 12%, 95%)',
14+
},
15+
secondary: {
16+
1000: 'hsl(212, 92%, 34%)',
17+
900: 'hsl(212, 92%, 45%)',
18+
350: 'hsl(212, 75%, 78%)',
19+
150: 'hsl(213, 74%, 91%)',
20+
100: 'hsl(211, 74%, 94%)',
21+
50: 'hsl(210, 75%, 97%)',
22+
}
23+
},
24+
red: {
25+
1000: 'hsl(352, 92%, 39%)',
26+
900: 'hsl(352, 100%, 52%)',
27+
},
28+
magenta: {
29+
1000: 'hsl(302, 100%, 37%)',
30+
900: 'hsl(302, 100%, 50%)',
31+
350: 'hsl(302, 100%, 81%)',
32+
50: 'hsl(300, 100%, 97%)',
33+
},
34+
green: {
35+
1000: 'hsl(149, 92%, 24%)',
36+
900: 'hsl(149, 93%, 32%)',
37+
350: 'hsl(149, 44%, 74%)',
38+
50: 'hsl(147, 47%, 96%)',
39+
},
40+
yellow: {
41+
900: 'hsl(48, 100%, 50%)',
42+
350: 'hsl(48, 100%, 81%)',
43+
50: 'hsl(47, 100%, 97%)',
44+
},
45+
orange: {
46+
1000: 'hsl(21, 96%, 38%)',
47+
900: 'hsl(21, 100%, 51%)',
48+
350: 'hsl(21, 100%, 81%)',
49+
50: 'hsl(21, 100%, 97%)'
50+
}
3551
} as const;
3652

53+
// AUTHENTIC = primary now
54+
// ACTION = secondary now
55+
3756
export const SemanticColors = {
3857
text: {
39-
primary: Colors.AUTHENTIC_BLUE_900,
40-
primaryInverted: Colors.WHITE,
58+
primary: Colors.blue.primary[900],
59+
primaryInverted: Colors.white,
4160
secondary: Colors.AUTHENTIC_BLUE_550,
4261
secondaryInverted: Colors.AUTHENTIC_BLUE_200,
4362
tertiary: Colors.AUTHENTIC_BLUE_350,
@@ -91,65 +110,116 @@ export const SemanticColors = {
91110
dangerEmphasized: Colors.NEGATIVE_ORANGE_900,
92111
successEmphasized: Colors.POSITIVE_GREEN_900,
93112
warningEmphasized: Colors.ATTENTION_YELLOW_900
113+
},
114+
// } satisfies ColorSchema;
115+
}
116+
117+
export const ComponentColors = {
118+
text: {
119+
button: {
120+
primary: {
121+
// --wave-c-color-text-button-primary-default
122+
default: '',
123+
// --wave-c-color-text-button-primary-hover
124+
hover: '',
125+
// --wave-c-color-text-button-primary-disabled
126+
disabled: '',
127+
// --wave-c-color-text-button-primary-inverted
128+
inverted: '',
129+
// --wave-c-color-text-button-primary-hoverInverted // This needs rething, as inverted is state, same as hover - Should be in Dark Mode Schema
130+
hoverInverted: '',
131+
// --wave-c-color-text-button-primary-disabledInverted // This needs rething, as inverted is state, same as hover - Should be in Dark Mode Schema
132+
disabledInverted: '',
133+
},
134+
secondary: {
135+
// --wave-c-color-text-button-secondary-default
136+
default: '',
137+
// --wave-c-color-text-button-secondary-hover
138+
hover: '',
139+
// --wave-c-color-text-button-secondary-disabled
140+
disabled: '',
141+
// --wave-c-color-text-button-secondary-inverted
142+
inverted: '',
143+
// --wave-c-color-text-button-secondary-hoverInverted // This needs rething, as inverted is state, same as hover - Should be in Dark Mode Schema
144+
hoverInverted: '',
145+
// --wave-c-color-text-button-secondary-disabledInverted // This needs rething, as inverted is state, same as hover - Should be in Dark Mode Schema
146+
disabledInverted: '',
147+
},
148+
danger: {
149+
// --wave-c-color-text-button-danger-default
150+
default: '',
151+
// --wave-c-color-text-button-danger-hover
152+
hover: '',
153+
// --wave-c-color-text-button-danger-disabled
154+
disabled: '',
155+
// --wave-c-color-text-button-danger-inverted
156+
inverted: '',
157+
// --wave-c-color-text-button-danger-hoverInverted // This needs rething, as inverted is state, same as hover - Should be in Dark Mode Schema
158+
hoverInverted: '',
159+
// --wave-c-color-text-button-danger-disabledInverted // This needs rething, as inverted is state, same as hover - Should be in Dark Mode Schema
160+
disabledInverted: '',
161+
}
162+
}
94163
}
95-
// button: {
96164
// primary: {
97165
// text: Colors.WHITE,
98166
// icon: Colors.WHITE,
99167
// background: Colors.AUTHENTIC_BLUE_900,
100168
// border: Colors.AUTHENTIC_BLUE_900,
101-
//
169+
102170
// textHover: Colors.WHITE,
103171
// iconHover: Colors.WHITE,
104172
// backgroundHover: Colors.AUTHENTIC_BLUE_1100,
105173
// borderHover: Colors.AUTHENTIC_BLUE_1100,
106-
//
174+
107175
// textDisabled: Colors.WHITE,
108176
// iconDisabled: Colors.WHITE,
109177
// backgroundDisabled: Colors.AUTHENTIC_BLUE_200,
110178
// borderDisabled: Colors.AUTHENTIC_BLUE_200,
111-
//
179+
112180
// textInverted: Colors.ACTION_BLUE_900,
113181
// iconInverted: Colors.ACTION_BLUE_900,
114182
// backgroundInverted: Colors.WHITE,
115183
// borderInverted: Colors.WHITE,
116-
//
184+
117185
// textHoverInverted: Colors.WHITE,
118186
// iconHoverInverted: Colors.WHITE,
119187
// backgroundHoverInverted: Colors.ACTION_BLUE_900,
120188
// borderHoverInverted: Colors.ACTION_BLUE_900,
121-
//
189+
122190
// textDisabledInverted: Colors.AUTHENTIC_BLUE_350,
123191
// iconDisabledInverted: Colors.AUTHENTIC_BLUE_350,
124192
// backgroundDisabledInverted: Colors.AUTHENTIC_BLUE_550,
125193
// borderDisabledInverted: Colors.AUTHENTIC_BLUE_550
126194
// },
195+
// // --wave-c-color-border-button-primary-hover
196+
// // --wave-c-color-border-button-primary-hover-inverted
127197
// secondary: {
128198
// text: Colors.AUTHENTIC_BLUE_900,
129199
// icon: Colors.AUTHENTIC_BLUE_900,
130200
// background: Colors.WHITE,
131201
// border: Colors.AUTHENTIC_BLUE_200,
132-
//
202+
133203
// textHover: Colors.AUTHENTIC_BLUE_900,
134204
// iconHover: Colors.AUTHENTIC_BLUE_900,
135205
// backgroundHover: Colors.AUTHENTIC_BLUE_50,
136206
// borderHover: Colors.AUTHENTIC_BLUE_200,
137-
//
207+
138208
// textDisabled: Colors.AUTHENTIC_BLUE_200,
139209
// iconDisabled: Colors.AUTHENTIC_BLUE_200,
140210
// backgroundDisabled: Colors.WHITE,
141211
// borderDisabled: Colors.AUTHENTIC_BLUE_200,
142-
//
212+
143213
// textInverted: Colors.WHITE,
144214
// iconInverted: Colors.WHITE,
145215
// backgroundInverted: 'transparent',
146216
// borderInverted: Colors.WHITE,
147-
//
217+
148218
// textHoverInverted: Colors.AUTHENTIC_BLUE_900,
149219
// iconHoverInverted: Colors.AUTHENTIC_BLUE_900,
150220
// backgroundHoverInverted: Colors.WHITE,
151221
// borderHoverInverted: Colors.WHITE,
152-
//
222+
153223
// textDisabledInverted: Colors.AUTHENTIC_BLUE_550,
154224
// iconDisabledInverted: Colors.AUTHENTIC_BLUE_550,
155225
// backgroundDisabledInverted: 'transparent',
@@ -160,27 +230,27 @@ export const SemanticColors = {
160230
// icon: Colors.WHITE,
161231
// background: Colors.NEGATIVE_ORANGE_900,
162232
// border: Colors.NEGATIVE_ORANGE_900,
163-
//
233+
164234
// textHover: Colors.WHITE,
165235
// iconHover: Colors.WHITE,
166236
// backgroundHover: Colors.NEGATIVE_ORANGE_1000,
167237
// borderHover: Colors.NEGATIVE_ORANGE_1000,
168-
//
238+
169239
// textDisabled: Colors.WHITE,
170240
// iconDisabled: Colors.WHITE,
171241
// backgroundDisabled: Colors.AUTHENTIC_BLUE_200,
172242
// borderDisabled: Colors.AUTHENTIC_BLUE_200,
173-
//
243+
174244
// textInverted: Colors.WHITE,
175245
// iconInverted: Colors.WHITE,
176246
// backgroundInverted: Colors.NEGATIVE_ORANGE_900,
177247
// borderInverted: Colors.NEGATIVE_ORANGE_900,
178-
//
248+
179249
// textHoverInverted: Colors.WHITE,
180250
// iconHoverInverted: Colors.WHITE,
181251
// backgroundHoverInverted: Colors.NEGATIVE_ORANGE_1000,
182252
// borderHoverInverted: Colors.NEGATIVE_ORANGE_1000,
183-
//
253+
184254
// textDisabledInverted: Colors.WHITE,
185255
// iconDisabledInverted: Colors.WHITE,
186256
// backgroundDisabledInverted: Colors.AUTHENTIC_BLUE_200,
@@ -195,7 +265,7 @@ export const SemanticColors = {
195265
// iconHover: Colors.ACTION_BLUE_1000,
196266
// textDisabled: Colors.AUTHENTIC_BLUE_200,
197267
// iconDisabled: Colors.AUTHENTIC_BLUE_200,
198-
//
268+
199269
// textInverted: Colors.WHITE,
200270
// iconInverted: Colors.WHITE,
201271
// textHoverInverted: Colors.AUTHENTIC_BLUE_350,
@@ -210,7 +280,7 @@ export const SemanticColors = {
210280
// iconHover: Colors.NEGATIVE_ORANGE_1000,
211281
// textDisabled: Colors.AUTHENTIC_BLUE_200,
212282
// iconDisabled: Colors.AUTHENTIC_BLUE_200,
213-
//
283+
214284
// textInverted: Colors.NEGATIVE_ORANGE_900,
215285
// iconInverted: Colors.NEGATIVE_ORANGE_900,
216286
// textHoverInverted: Colors.NEGATIVE_ORANGE_1000,
@@ -278,4 +348,4 @@ export const SemanticColors = {
278348
// dialog: {
279349
// dimming: 'rgba(0, 15, 31, 0.6)'
280350
// }
281-
} satisfies ColorSchema;
351+
}

src/essentials/Colors/globalStyles.ts

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import { createGlobalStyle } from 'styled-components';
2-
import { SemanticColors as ClassicSemanticColors } from './Colors';
3-
import { SemanticColors as RedesignedSemanticColors } from './RedesignedColors';
4-
import { generateCssVariables } from '../../utils/generateCssVariables';
1+
// import { createGlobalStyle } from 'styled-components';
2+
// import { SemanticColors as ClassicSemanticColors } from './Colors';
3+
// import { SemanticColors as RedesignedSemanticColors } from './RedesignedColors';
4+
// import { generateCssVariables } from '../../utils/generateCssVariables';
55

6-
export const ClassicColors = createGlobalStyle`
7-
:root {
8-
${generateCssVariables(ClassicSemanticColors)}
9-
}
10-
`;
6+
// export const ClassicColors = createGlobalStyle`
7+
// :root {
8+
// /* ${generateCssVariables(ClassicSemanticColors)} */
9+
// }
10+
// `;
1111

12-
export const RedesignedColors = createGlobalStyle`
13-
:root {
14-
${generateCssVariables(RedesignedSemanticColors)}
15-
}
16-
`;
12+
// export const RedesignedColors = createGlobalStyle`
13+
// :root {
14+
// /* ${generateCssVariables(RedesignedSemanticColors)} */
15+
// }
16+
// `;

src/utils/generateCssVariables.ts

+9-4
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@ type TokenObject = {
22
[key: string]: string | number | null | undefined | TokenObject;
33
};
44

5-
const parseLevel = (tokenObject: TokenObject, path: string[] = []): ReadonlyArray<string> =>
5+
const parseLevel = (tokenObject: TokenObject, path: string[] = [], tier?: string): ReadonlyArray<string> =>
66
Object.entries(tokenObject).flatMap(([key, value]) => {
77
if (typeof value === 'object') {
8-
return parseLevel(value, [...path, key]);
8+
return parseLevel(value, [...path, key], tier);
99
}
10-
return `--${[...path, key].join('-')}: ${value};`;
10+
// eslint-disable-next-line no-console
11+
console.log(`--wave-${tier}-${[...path, key].join('-')}: ${value};`)
12+
return `--wave-${tier}-${[...path, key].join('-')}: ${value};`;
1113
});
1214

13-
export const generateCssVariables = (tokens: TokenObject) => parseLevel(tokens);
15+
// export const generateCssVariables = (tokens: TokenObject) => parseLevel(tokens, [], 'global');
16+
export const generateGlobalTierCssVariables = (tokens: TokenObject) => parseLevel(tokens, ['color'], 'g');
17+
export const generateSemanticTierCssVariables = (tokens: TokenObject) => parseLevel(tokens, ['color'], 's');
18+
export const generateComponentTierCssVariables = (tokens: TokenObject) => parseLevel(tokens, ['color'], 'c');

0 commit comments

Comments
 (0)