1 | const COMPILED_TOKENS = require('./dist/tokens/json/tokens.json');
|
2 |
|
3 | const cssCustomPropertyWithValue = (token) => {
|
4 | const path = [token.prefix !== false ? 'gl' : false, ...token.path].filter(Boolean);
|
5 | return `var(--${path.join('-')}, ${token.value})`;
|
6 | };
|
7 |
|
8 | const baseColors = ['blue', 'gray', 'green', 'orange', 'purple', 'red'].reduce((acc, color) => {
|
9 | Object.entries(COMPILED_TOKENS[color]).forEach(([, token]) => {
|
10 | acc[token.path.join('-')] = cssCustomPropertyWithValue(token);
|
11 | });
|
12 | return acc;
|
13 | }, {});
|
14 |
|
15 | const themeColors = Object.entries(COMPILED_TOKENS.theme).reduce((acc, [, scales]) => {
|
16 | Object.entries(scales).forEach(([, token]) => {
|
17 | acc[token.path.join('-')] = cssCustomPropertyWithValue(token);
|
18 | });
|
19 | return acc;
|
20 | }, {});
|
21 |
|
22 | const dataVizColors = Object.entries(COMPILED_TOKENS['data-viz']).reduce((acc, [, scales]) => {
|
23 | Object.entries(scales).forEach(([, token]) => {
|
24 | acc[token.path.join('-')] = cssCustomPropertyWithValue(token);
|
25 | });
|
26 | return acc;
|
27 | }, {});
|
28 |
|
29 | const textColors = Object.entries(COMPILED_TOKENS.text).reduce((acc, [scale, token]) => {
|
30 | acc[scale] = cssCustomPropertyWithValue(token);
|
31 | return acc;
|
32 | }, {});
|
33 |
|
34 | const colors = {
|
35 | transparent: 'transparent',
|
36 | white: cssCustomPropertyWithValue(COMPILED_TOKENS.white),
|
37 | black: cssCustomPropertyWithValue(COMPILED_TOKENS.black),
|
38 | ...baseColors,
|
39 | ...themeColors,
|
40 | ...dataVizColors,
|
41 | };
|
42 |
|
43 | const gridSize = 0.5;
|
44 | const spacing = {
|
45 | 0: '0',
|
46 | ...Object.fromEntries(
|
47 | Object.entries({
|
48 | 1: 0.25,
|
49 | 2: 0.5,
|
50 | 3: 1,
|
51 | 4: 1.5,
|
52 | 5: 2,
|
53 | 6: 3,
|
54 | 7: 4,
|
55 | 8: 5,
|
56 | 9: 6,
|
57 | 10: 7,
|
58 | 11: 8,
|
59 | '11-5': 9,
|
60 | 12: 10,
|
61 | 13: 12,
|
62 | 15: 15,
|
63 | 20: 20,
|
64 | 26: 26,
|
65 | 28: 28,
|
66 | 30: 30,
|
67 | 31: 31,
|
68 | 34: 34,
|
69 | 48: 48,
|
70 | 62: 62,
|
71 | 75: 75,
|
72 | 80: 80,
|
73 | 88: 88,
|
74 | }).map(([scale, factor]) => {
|
75 | return [scale, `${factor * gridSize}rem`];
|
76 | })
|
77 | ),
|
78 | };
|
79 |
|
80 |
|
81 | module.exports = {
|
82 | prefix: 'gl-',
|
83 | theme: {
|
84 | screens: {
|
85 | sm: '576px',
|
86 | md: '768px',
|
87 | lg: '992px',
|
88 | xl: '1200px',
|
89 | },
|
90 | colors,
|
91 | spacing,
|
92 | fontSize: {
|
93 | xs: '0.625rem',
|
94 | sm: '0.75rem',
|
95 | base: '0.875rem',
|
96 | lg: '1rem',
|
97 | },
|
98 | fontWeight: {
|
99 | 100: 100,
|
100 | 300: 300,
|
101 | normal: 400,
|
102 | semibold: 500,
|
103 | bold: 600,
|
104 | },
|
105 | textColor: {
|
106 | ...colors,
|
107 | ...textColors,
|
108 | },
|
109 | },
|
110 | };
|