@atlaskit/primitives 0.1.0 → 0.2.0
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/CHANGELOG.md +13 -0
- package/dist/cjs/components/box.js +80 -6
- package/dist/cjs/components/inline.partial.js +22 -46
- package/dist/cjs/components/internal/base-box.partial.js +822 -0
- package/dist/cjs/components/stack.partial.js +22 -46
- package/dist/cjs/index.js +2 -2
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/components/box.js +75 -1
- package/dist/es2019/components/inline.partial.js +20 -20
- package/dist/es2019/components/internal/base-box.partial.js +839 -0
- package/dist/es2019/components/stack.partial.js +20 -20
- package/dist/es2019/index.js +2 -2
- package/dist/es2019/version.json +1 -1
- package/dist/esm/components/box.js +77 -1
- package/dist/esm/components/inline.partial.js +21 -46
- package/dist/esm/components/internal/base-box.partial.js +817 -0
- package/dist/esm/components/stack.partial.js +21 -46
- package/dist/esm/index.js +2 -2
- package/dist/esm/version.json +1 -1
- package/dist/types/components/box.d.ts +10 -1
- package/dist/types/components/inline.partial.d.ts +18 -16
- package/dist/types/components/internal/base-box.partial.d.ts +483 -0
- package/dist/types/components/stack.partial.d.ts +18 -16
- package/dist/types/components/types.d.ts +8 -1
- package/dist/types/index.d.ts +3 -3
- package/package.json +2 -3
- package/report.api.md +505 -46
- package/scripts/__tests__/__snapshots__/codegen.test.tsx.snap +204 -0
- package/scripts/codegen-styles.tsx +31 -16
- package/scripts/color-codegen-template.tsx +10 -7
- package/scripts/dimension-codegen-template.tsx +14 -2
- package/scripts/misc-codegen-template.tsx +1 -1
- package/scripts/spacing-codegen-template.tsx +37 -33
- package/tmp/api-report-tmp.d.ts +466 -46
- package/dist/cjs/components/internal/box.partial.js +0 -605
- package/dist/es2019/components/internal/box.partial.js +0 -597
- package/dist/esm/components/internal/box.partial.js +0 -600
- package/dist/types/components/internal/box.partial.d.ts +0 -348
|
@@ -2,6 +2,129 @@
|
|
|
2
2
|
|
|
3
3
|
exports[`@atlaskit/primitives bg styles are generated correctly 1`] = `
|
|
4
4
|
"const backgroundColorMap = {
|
|
5
|
+
'accent.red.subtlest': css({
|
|
6
|
+
backgroundColor: token('color.background.accent.red.subtlest', '#FF8F73'),
|
|
7
|
+
}),
|
|
8
|
+
'accent.red.subtler': css({
|
|
9
|
+
backgroundColor: token('color.background.accent.red.subtler', '#FF7452'),
|
|
10
|
+
}),
|
|
11
|
+
'accent.red.subtle': css({
|
|
12
|
+
backgroundColor: token('color.background.accent.red.subtle', '#DE350B'),
|
|
13
|
+
}),
|
|
14
|
+
'accent.red.bolder': css({
|
|
15
|
+
backgroundColor: token('color.background.accent.red.bolder', '#DE350B'),
|
|
16
|
+
}),
|
|
17
|
+
'accent.orange.subtlest': css({
|
|
18
|
+
backgroundColor: token(
|
|
19
|
+
'color.background.accent.orange.subtlest',
|
|
20
|
+
'#F18D13',
|
|
21
|
+
),
|
|
22
|
+
}),
|
|
23
|
+
'accent.orange.subtler': css({
|
|
24
|
+
backgroundColor: token('color.background.accent.orange.subtler', '#B65C02'),
|
|
25
|
+
}),
|
|
26
|
+
'accent.orange.subtle': css({
|
|
27
|
+
backgroundColor: token('color.background.accent.orange.subtle', '#5F3811'),
|
|
28
|
+
}),
|
|
29
|
+
'accent.orange.bolder': css({
|
|
30
|
+
backgroundColor: token('color.background.accent.orange.bolder', '#43290F'),
|
|
31
|
+
}),
|
|
32
|
+
'accent.yellow.subtlest': css({
|
|
33
|
+
backgroundColor: token(
|
|
34
|
+
'color.background.accent.yellow.subtlest',
|
|
35
|
+
'#FFE380',
|
|
36
|
+
),
|
|
37
|
+
}),
|
|
38
|
+
'accent.yellow.subtler': css({
|
|
39
|
+
backgroundColor: token('color.background.accent.yellow.subtler', '#FFC400'),
|
|
40
|
+
}),
|
|
41
|
+
'accent.yellow.subtle': css({
|
|
42
|
+
backgroundColor: token('color.background.accent.yellow.subtle', '#FF991F'),
|
|
43
|
+
}),
|
|
44
|
+
'accent.yellow.bolder': css({
|
|
45
|
+
backgroundColor: token('color.background.accent.yellow.bolder', '#FF991F'),
|
|
46
|
+
}),
|
|
47
|
+
'accent.green.subtlest': css({
|
|
48
|
+
backgroundColor: token('color.background.accent.green.subtlest', '#79F2C0'),
|
|
49
|
+
}),
|
|
50
|
+
'accent.green.subtler': css({
|
|
51
|
+
backgroundColor: token('color.background.accent.green.subtler', '#57D9A3'),
|
|
52
|
+
}),
|
|
53
|
+
'accent.green.subtle': css({
|
|
54
|
+
backgroundColor: token('color.background.accent.green.subtle', '#00875A'),
|
|
55
|
+
}),
|
|
56
|
+
'accent.green.bolder': css({
|
|
57
|
+
backgroundColor: token('color.background.accent.green.bolder', '#00875A'),
|
|
58
|
+
}),
|
|
59
|
+
'accent.teal.subtlest': css({
|
|
60
|
+
backgroundColor: token('color.background.accent.teal.subtlest', '#79E2F2'),
|
|
61
|
+
}),
|
|
62
|
+
'accent.teal.subtler': css({
|
|
63
|
+
backgroundColor: token('color.background.accent.teal.subtler', '#00C7E6'),
|
|
64
|
+
}),
|
|
65
|
+
'accent.teal.subtle': css({
|
|
66
|
+
backgroundColor: token('color.background.accent.teal.subtle', '#00A3BF'),
|
|
67
|
+
}),
|
|
68
|
+
'accent.teal.bolder': css({
|
|
69
|
+
backgroundColor: token('color.background.accent.teal.bolder', '#00A3BF'),
|
|
70
|
+
}),
|
|
71
|
+
'accent.blue.subtlest': css({
|
|
72
|
+
backgroundColor: token('color.background.accent.blue.subtlest', '#4C9AFF'),
|
|
73
|
+
}),
|
|
74
|
+
'accent.blue.subtler': css({
|
|
75
|
+
backgroundColor: token('color.background.accent.blue.subtler', '#2684FF'),
|
|
76
|
+
}),
|
|
77
|
+
'accent.blue.subtle': css({
|
|
78
|
+
backgroundColor: token('color.background.accent.blue.subtle', '#0052CC'),
|
|
79
|
+
}),
|
|
80
|
+
'accent.blue.bolder': css({
|
|
81
|
+
backgroundColor: token('color.background.accent.blue.bolder', '#0052CC'),
|
|
82
|
+
}),
|
|
83
|
+
'accent.purple.subtlest': css({
|
|
84
|
+
backgroundColor: token(
|
|
85
|
+
'color.background.accent.purple.subtlest',
|
|
86
|
+
'#998DD9',
|
|
87
|
+
),
|
|
88
|
+
}),
|
|
89
|
+
'accent.purple.subtler': css({
|
|
90
|
+
backgroundColor: token('color.background.accent.purple.subtler', '#8777D9'),
|
|
91
|
+
}),
|
|
92
|
+
'accent.purple.subtle': css({
|
|
93
|
+
backgroundColor: token('color.background.accent.purple.subtle', '#5243AA'),
|
|
94
|
+
}),
|
|
95
|
+
'accent.purple.bolder': css({
|
|
96
|
+
backgroundColor: token('color.background.accent.purple.bolder', '#5243AA'),
|
|
97
|
+
}),
|
|
98
|
+
'accent.magenta.subtlest': css({
|
|
99
|
+
backgroundColor: token(
|
|
100
|
+
'color.background.accent.magenta.subtlest',
|
|
101
|
+
'#E774BB',
|
|
102
|
+
),
|
|
103
|
+
}),
|
|
104
|
+
'accent.magenta.subtler': css({
|
|
105
|
+
backgroundColor: token(
|
|
106
|
+
'color.background.accent.magenta.subtler',
|
|
107
|
+
'#E774BB',
|
|
108
|
+
),
|
|
109
|
+
}),
|
|
110
|
+
'accent.magenta.subtle': css({
|
|
111
|
+
backgroundColor: token('color.background.accent.magenta.subtle', '#E774BB'),
|
|
112
|
+
}),
|
|
113
|
+
'accent.magenta.bolder': css({
|
|
114
|
+
backgroundColor: token('color.background.accent.magenta.bolder', '#E774BB'),
|
|
115
|
+
}),
|
|
116
|
+
'accent.gray.subtlest': css({
|
|
117
|
+
backgroundColor: token('color.background.accent.gray.subtlest', '#6B778C'),
|
|
118
|
+
}),
|
|
119
|
+
'accent.gray.subtler': css({
|
|
120
|
+
backgroundColor: token('color.background.accent.gray.subtler', '#5E6C84'),
|
|
121
|
+
}),
|
|
122
|
+
'accent.gray.subtle': css({
|
|
123
|
+
backgroundColor: token('color.background.accent.gray.subtle', '#42526E'),
|
|
124
|
+
}),
|
|
125
|
+
'accent.gray.bolder': css({
|
|
126
|
+
backgroundColor: token('color.background.accent.gray.bolder', '#505F79'),
|
|
127
|
+
}),
|
|
5
128
|
disabled: css({
|
|
6
129
|
backgroundColor: token('color.background.disabled', '#091e4289'),
|
|
7
130
|
}),
|
|
@@ -91,6 +214,33 @@ exports[`@atlaskit/primitives border styles are generated correctly 1`] = `
|
|
|
91
214
|
'color.border': css({
|
|
92
215
|
borderColor: token('color.border', '#091e4221'),
|
|
93
216
|
}),
|
|
217
|
+
'accent.red': css({
|
|
218
|
+
borderColor: token('color.border.accent.red', '#FF5630'),
|
|
219
|
+
}),
|
|
220
|
+
'accent.orange': css({
|
|
221
|
+
borderColor: token('color.border.accent.orange', '#D94008'),
|
|
222
|
+
}),
|
|
223
|
+
'accent.yellow': css({
|
|
224
|
+
borderColor: token('color.border.accent.yellow', '#FFAB00'),
|
|
225
|
+
}),
|
|
226
|
+
'accent.green': css({
|
|
227
|
+
borderColor: token('color.border.accent.green', '#36B37E'),
|
|
228
|
+
}),
|
|
229
|
+
'accent.teal': css({
|
|
230
|
+
borderColor: token('color.border.accent.teal', '#00B8D9'),
|
|
231
|
+
}),
|
|
232
|
+
'accent.blue': css({
|
|
233
|
+
borderColor: token('color.border.accent.blue', '#0065FF'),
|
|
234
|
+
}),
|
|
235
|
+
'accent.purple': css({
|
|
236
|
+
borderColor: token('color.border.accent.purple', '#6554C0'),
|
|
237
|
+
}),
|
|
238
|
+
'accent.magenta': css({
|
|
239
|
+
borderColor: token('color.border.accent.magenta', '#CD519D'),
|
|
240
|
+
}),
|
|
241
|
+
'accent.gray': css({
|
|
242
|
+
borderColor: token('color.border.accent.gray', '#5E6C84'),
|
|
243
|
+
}),
|
|
94
244
|
disabled: css({
|
|
95
245
|
borderColor: token('color.border.disabled', '#FAFBFC'),
|
|
96
246
|
}),
|
|
@@ -138,6 +288,60 @@ exports[`@atlaskit/primitives text styles are generated correctly 1`] = `
|
|
|
138
288
|
'color.text': css({
|
|
139
289
|
color: token('color.text', '#172B4D'),
|
|
140
290
|
}),
|
|
291
|
+
'accent.red': css({
|
|
292
|
+
color: token('color.text.accent.red', '#DE350B'),
|
|
293
|
+
}),
|
|
294
|
+
'accent.red.bolder': css({
|
|
295
|
+
color: token('color.text.accent.red.bolder', '#BF2600'),
|
|
296
|
+
}),
|
|
297
|
+
'accent.orange': css({
|
|
298
|
+
color: token('color.text.accent.orange', '#F18D13'),
|
|
299
|
+
}),
|
|
300
|
+
'accent.orange.bolder': css({
|
|
301
|
+
color: token('color.text.accent.orange.bolder', '#B65C02'),
|
|
302
|
+
}),
|
|
303
|
+
'accent.yellow': css({
|
|
304
|
+
color: token('color.text.accent.yellow', '#FF991F'),
|
|
305
|
+
}),
|
|
306
|
+
'accent.yellow.bolder': css({
|
|
307
|
+
color: token('color.text.accent.yellow.bolder', '#FF8B00'),
|
|
308
|
+
}),
|
|
309
|
+
'accent.green': css({
|
|
310
|
+
color: token('color.text.accent.green', '#00875A'),
|
|
311
|
+
}),
|
|
312
|
+
'accent.green.bolder': css({
|
|
313
|
+
color: token('color.text.accent.green.bolder', '#006644'),
|
|
314
|
+
}),
|
|
315
|
+
'accent.teal': css({
|
|
316
|
+
color: token('color.text.accent.teal', '#00A3BF'),
|
|
317
|
+
}),
|
|
318
|
+
'accent.teal.bolder': css({
|
|
319
|
+
color: token('color.text.accent.teal.bolder', '#008DA6'),
|
|
320
|
+
}),
|
|
321
|
+
'accent.blue': css({
|
|
322
|
+
color: token('color.text.accent.blue', '#0052CC'),
|
|
323
|
+
}),
|
|
324
|
+
'accent.blue.bolder': css({
|
|
325
|
+
color: token('color.text.accent.blue.bolder', '#0747A6'),
|
|
326
|
+
}),
|
|
327
|
+
'accent.purple': css({
|
|
328
|
+
color: token('color.text.accent.purple', '#5243AA'),
|
|
329
|
+
}),
|
|
330
|
+
'accent.purple.bolder': css({
|
|
331
|
+
color: token('color.text.accent.purple.bolder', '#403294'),
|
|
332
|
+
}),
|
|
333
|
+
'accent.magenta': css({
|
|
334
|
+
color: token('color.text.accent.magenta', '#E774BB'),
|
|
335
|
+
}),
|
|
336
|
+
'accent.magenta.bolder': css({
|
|
337
|
+
color: token('color.text.accent.magenta.bolder', '#DA62AC'),
|
|
338
|
+
}),
|
|
339
|
+
'accent.gray': css({
|
|
340
|
+
color: token('color.text.accent.gray', '#505F79'),
|
|
341
|
+
}),
|
|
342
|
+
'accent.gray.bolder': css({
|
|
343
|
+
color: token('color.text.accent.gray.bolder', '#172B4D'),
|
|
344
|
+
}),
|
|
141
345
|
disabled: css({
|
|
142
346
|
color: token('color.text.disabled', '#A5ADBA'),
|
|
143
347
|
}),
|
|
@@ -18,6 +18,13 @@ const spacingTokensDependencyPath = require.resolve(
|
|
|
18
18
|
'../../tokens/src/artifacts/tokens-raw/atlassian-spacing',
|
|
19
19
|
);
|
|
20
20
|
|
|
21
|
+
const primitivesFileNames = {
|
|
22
|
+
'internal-box': 'base-box.partial.tsx',
|
|
23
|
+
box: 'box.tsx',
|
|
24
|
+
inline: 'inline.partial.tsx',
|
|
25
|
+
stack: 'stack.partial.tsx',
|
|
26
|
+
};
|
|
27
|
+
|
|
21
28
|
writeFile(
|
|
22
29
|
join(colorMapOutputFolder, 'color-map.tsx'),
|
|
23
30
|
createSignedArtifact(createColorMapTemplate(), 'yarn codegen-styles', {
|
|
@@ -30,7 +37,7 @@ writeFile(
|
|
|
30
37
|
|
|
31
38
|
// generate colors
|
|
32
39
|
Promise.all(
|
|
33
|
-
[{ target: 'box
|
|
40
|
+
[{ target: primitivesFileNames['internal-box'] }].map(({ target }) => {
|
|
34
41
|
const targetPath = join(
|
|
35
42
|
__dirname,
|
|
36
43
|
'../',
|
|
@@ -59,9 +66,9 @@ Promise.all(
|
|
|
59
66
|
// generate spacing values
|
|
60
67
|
return Promise.all(
|
|
61
68
|
[
|
|
62
|
-
{ path: ['internal', 'box
|
|
63
|
-
{ path: [
|
|
64
|
-
{ path: [
|
|
69
|
+
{ path: ['internal', primitivesFileNames['internal-box']] },
|
|
70
|
+
{ path: [primitivesFileNames.inline] },
|
|
71
|
+
{ path: [primitivesFileNames.stack] },
|
|
65
72
|
].map(({ path }) => {
|
|
66
73
|
const targetPath = join(__dirname, '../', 'src', 'components', ...path);
|
|
67
74
|
|
|
@@ -84,19 +91,27 @@ Promise.all(
|
|
|
84
91
|
.then(() => {
|
|
85
92
|
// generate other values
|
|
86
93
|
return Promise.all(
|
|
87
|
-
[{ path: ['internal', 'box
|
|
88
|
-
|
|
94
|
+
[{ path: ['internal', primitivesFileNames['internal-box']] }].map(
|
|
95
|
+
({ path }) => {
|
|
96
|
+
const targetPath = join(
|
|
97
|
+
__dirname,
|
|
98
|
+
'../',
|
|
99
|
+
'src',
|
|
100
|
+
'components',
|
|
101
|
+
...path,
|
|
102
|
+
);
|
|
89
103
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
104
|
+
const source = createPartialSignedArtifact(
|
|
105
|
+
options => options.map(createStylesFromTemplate).join('\n'),
|
|
106
|
+
'yarn codegen-styles',
|
|
107
|
+
{ id: 'misc', absoluteFilePath: targetPath },
|
|
108
|
+
);
|
|
95
109
|
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
110
|
+
return writeFile(targetPath, source).then(() =>
|
|
111
|
+
console.log(`${targetPath} written!`),
|
|
112
|
+
);
|
|
113
|
+
},
|
|
114
|
+
),
|
|
100
115
|
);
|
|
101
116
|
})
|
|
102
117
|
.then(() => {
|
|
@@ -106,7 +121,7 @@ Promise.all(
|
|
|
106
121
|
'src',
|
|
107
122
|
'components',
|
|
108
123
|
'internal',
|
|
109
|
-
'box
|
|
124
|
+
primitivesFileNames['internal-box'],
|
|
110
125
|
);
|
|
111
126
|
|
|
112
127
|
const source = createPartialSignedArtifact(
|
|
@@ -9,7 +9,6 @@ import tokens from '@atlaskit/tokens/src/artifacts/tokens-raw/atlassian-light';
|
|
|
9
9
|
import {
|
|
10
10
|
capitalize,
|
|
11
11
|
compose,
|
|
12
|
-
isAccent,
|
|
13
12
|
isHovered,
|
|
14
13
|
isPressed,
|
|
15
14
|
not,
|
|
@@ -21,6 +20,7 @@ import {
|
|
|
21
20
|
type Token = {
|
|
22
21
|
token: string;
|
|
23
22
|
fallback: string | ShadowDefintion;
|
|
23
|
+
isDeprecated: boolean;
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
// NB: Fallback CSS variables can be deleted when tokens are no longer behind a feature flag
|
|
@@ -60,17 +60,17 @@ const tokenStyles = {
|
|
|
60
60
|
const bothTokens = tokens.map((t, i) => [t, legacyTokens[i]]);
|
|
61
61
|
|
|
62
62
|
const activeTokens = bothTokens
|
|
63
|
-
.filter(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
)
|
|
63
|
+
.filter(([t]) => t.attributes.state !== 'deleted')
|
|
64
|
+
.map(t => {
|
|
65
|
+
return t;
|
|
66
|
+
})
|
|
67
67
|
.map(
|
|
68
68
|
([t, legacy]): Token => ({
|
|
69
69
|
token: t.name,
|
|
70
70
|
fallback: legacy.value as string | ShadowDefintion,
|
|
71
|
+
isDeprecated: t.attributes.state === 'deprecated',
|
|
71
72
|
}),
|
|
72
73
|
)
|
|
73
|
-
.filter(compose(pick('token'), not(isAccent)))
|
|
74
74
|
.filter(compose(pick('token'), not(isPressed)))
|
|
75
75
|
.filter(compose(pick('token'), not(isHovered)));
|
|
76
76
|
|
|
@@ -95,7 +95,10 @@ const ${objectName}Map = {
|
|
|
95
95
|
.map(t => {
|
|
96
96
|
// handle the default case eg color.border or color.text
|
|
97
97
|
const propName = t.token.replace(prefix, '');
|
|
98
|
-
return `
|
|
98
|
+
return `
|
|
99
|
+
${t.isDeprecated ? '// @deprecated' : ''}
|
|
100
|
+
'${propName}': ${tokenToStyle(cssProperty, t.token, t.fallback)}
|
|
101
|
+
`.trim();
|
|
99
102
|
})
|
|
100
103
|
.join(',\n\t')}
|
|
101
104
|
} as const;`,
|
|
@@ -10,6 +10,18 @@ const dimensionProperties = {
|
|
|
10
10
|
height: {
|
|
11
11
|
cssProperty: 'height',
|
|
12
12
|
},
|
|
13
|
+
minWidth: {
|
|
14
|
+
cssProperty: 'minWidth',
|
|
15
|
+
},
|
|
16
|
+
maxWidth: {
|
|
17
|
+
cssProperty: 'maxWidth',
|
|
18
|
+
},
|
|
19
|
+
minHeight: {
|
|
20
|
+
cssProperty: 'minHeight',
|
|
21
|
+
},
|
|
22
|
+
maxHeight: {
|
|
23
|
+
cssProperty: 'maxHeight',
|
|
24
|
+
},
|
|
13
25
|
} as const;
|
|
14
26
|
|
|
15
27
|
// placeholder adapted from packages/design-system/avatar/src/constants.ts
|
|
@@ -43,12 +55,12 @@ export const createDimensionStylesFromTemplate = (
|
|
|
43
55
|
`
|
|
44
56
|
const ${spacingProperty}Map = {
|
|
45
57
|
${activeTokens
|
|
46
|
-
.sort((a, b) =>
|
|
58
|
+
.sort((a, b) => a.name.localeCompare(b.name, undefined, { numeric: true }))
|
|
47
59
|
.map(token => {
|
|
48
60
|
return `'${token.name}': css({ ${cssProperty}: '${token.value}' })`;
|
|
49
61
|
})
|
|
50
62
|
.join(',\n\t')}
|
|
51
|
-
};`,
|
|
63
|
+
} as const;`,
|
|
52
64
|
{
|
|
53
65
|
singleQuote: true,
|
|
54
66
|
trailingComma: 'all',
|
|
@@ -7,37 +7,27 @@ import { capitalize, tokenToStyle } from './utils';
|
|
|
7
7
|
|
|
8
8
|
const spacingProperties = {
|
|
9
9
|
padding: {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
cssProperty: 'paddingBlockEnd',
|
|
20
|
-
},
|
|
21
|
-
paddingInline: {
|
|
22
|
-
cssProperty: 'paddingInline',
|
|
23
|
-
},
|
|
24
|
-
paddingInlineStart: {
|
|
25
|
-
cssProperty: 'paddingInlineStart',
|
|
26
|
-
},
|
|
27
|
-
paddingInlineEnd: {
|
|
28
|
-
cssProperty: 'paddingInlineEnd',
|
|
10
|
+
cssProperties: [
|
|
11
|
+
'padding',
|
|
12
|
+
'paddingBlock',
|
|
13
|
+
'paddingBlockStart',
|
|
14
|
+
'paddingBlockEnd',
|
|
15
|
+
'paddingInline',
|
|
16
|
+
'paddingInlineStart',
|
|
17
|
+
'paddingInlineEnd',
|
|
18
|
+
],
|
|
29
19
|
},
|
|
30
20
|
gap: {
|
|
31
|
-
|
|
21
|
+
cssProperties: ['gap'],
|
|
32
22
|
},
|
|
33
23
|
space: {
|
|
34
|
-
|
|
24
|
+
cssProperties: ['gap'],
|
|
35
25
|
},
|
|
36
26
|
columnGap: {
|
|
37
|
-
|
|
27
|
+
cssProperties: ['columnGap'],
|
|
38
28
|
},
|
|
39
29
|
rowGap: {
|
|
40
|
-
|
|
30
|
+
cssProperties: ['rowGap'],
|
|
41
31
|
},
|
|
42
32
|
} as const;
|
|
43
33
|
|
|
@@ -58,27 +48,32 @@ export const createSpacingStylesFromTemplate = (
|
|
|
58
48
|
throw new Error(`[codegen] Unknown option found "${spacingProperty}"`);
|
|
59
49
|
}
|
|
60
50
|
|
|
61
|
-
const {
|
|
51
|
+
const { cssProperties } = spacingProperties[spacingProperty];
|
|
62
52
|
|
|
63
53
|
return (
|
|
64
54
|
prettier.format(
|
|
65
55
|
`
|
|
66
|
-
const ${spacingProperty}Map =
|
|
56
|
+
const ${spacingProperty}Map = Object.fromEntries(
|
|
57
|
+
[
|
|
58
|
+
'${cssProperties.join("','")}',
|
|
59
|
+
].map((property: string) => [
|
|
60
|
+
property,
|
|
61
|
+
{
|
|
67
62
|
${activeTokens
|
|
68
|
-
.sort((a, b) =>
|
|
63
|
+
.sort((a, b) => a.name.localeCompare(b.name, undefined, { numeric: true }))
|
|
69
64
|
.map(token => {
|
|
70
65
|
const propName =
|
|
71
66
|
spacingProperty === 'space'
|
|
72
67
|
? token.name.replace(spacingTokenPrefix, '')
|
|
73
68
|
: token.name;
|
|
74
69
|
return `'${propName}': ${tokenToStyle(
|
|
75
|
-
|
|
70
|
+
'[property]' as any,
|
|
76
71
|
token.name,
|
|
77
72
|
token.fallback,
|
|
78
73
|
)}`;
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
|
|
74
|
+
})}
|
|
75
|
+
} as const,
|
|
76
|
+
]));`,
|
|
82
77
|
{
|
|
83
78
|
singleQuote: true,
|
|
84
79
|
trailingComma: 'all',
|
|
@@ -86,8 +81,17 @@ const ${spacingProperty}Map = {
|
|
|
86
81
|
plugins: [parserTypeScript],
|
|
87
82
|
},
|
|
88
83
|
) +
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
84
|
+
(cssProperties.length === 1
|
|
85
|
+
? `\nexport type ${capitalize(
|
|
86
|
+
spacingProperty,
|
|
87
|
+
)} = keyof typeof ${spacingProperty}Map.${cssProperties[0]};\n`
|
|
88
|
+
: cssProperties
|
|
89
|
+
.map(
|
|
90
|
+
cssProperty =>
|
|
91
|
+
`\nexport type ${capitalize(
|
|
92
|
+
cssProperty,
|
|
93
|
+
)} = keyof typeof ${spacingProperty}Map.${cssProperty};`,
|
|
94
|
+
)
|
|
95
|
+
.join('') + '\n')
|
|
92
96
|
);
|
|
93
97
|
};
|