@atlaskit/ds-explorations 0.0.3 → 0.1.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.
- package/CHANGELOG.md +32 -0
- package/dist/cjs/components/box.partial.js +355 -185
- package/dist/cjs/components/inline.partial.js +124 -0
- package/dist/cjs/components/interaction-surface.partial.js +253 -0
- package/dist/cjs/components/stack.partial.js +116 -0
- package/dist/cjs/components/surface-provider.js +31 -0
- package/dist/cjs/components/text.partial.js +152 -49
- package/dist/cjs/components/types.js +5 -0
- package/dist/cjs/constants.js +3 -0
- package/dist/cjs/index.js +50 -3
- package/dist/cjs/internal/color-map.js +42 -0
- package/dist/cjs/internal/role-to-element.js +36 -0
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/components/box.partial.js +259 -113
- package/dist/es2019/components/inline.partial.js +111 -0
- package/dist/es2019/components/interaction-surface.partial.js +243 -0
- package/dist/es2019/components/stack.partial.js +106 -0
- package/dist/es2019/components/surface-provider.js +20 -0
- package/dist/es2019/components/text.partial.js +122 -35
- package/dist/es2019/components/types.js +1 -0
- package/dist/es2019/constants.js +3 -0
- package/dist/es2019/index.js +6 -1
- package/dist/es2019/internal/color-map.js +34 -0
- package/dist/es2019/internal/role-to-element.js +28 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/components/box.partial.js +274 -109
- package/dist/esm/components/inline.partial.js +110 -0
- package/dist/esm/components/interaction-surface.partial.js +242 -0
- package/dist/esm/components/stack.partial.js +105 -0
- package/dist/esm/components/surface-provider.js +20 -0
- package/dist/esm/components/text.partial.js +132 -34
- package/dist/esm/components/types.js +1 -0
- package/dist/esm/constants.js +3 -0
- package/dist/esm/index.js +6 -1
- package/dist/esm/internal/color-map.js +34 -0
- package/dist/esm/internal/role-to-element.js +28 -0
- package/dist/esm/version.json +1 -1
- package/dist/types/components/box.partial.d.ts +157 -76
- package/dist/types/components/inline.partial.d.ts +52 -0
- package/dist/types/components/interaction-surface.partial.d.ts +45 -0
- package/dist/types/components/stack.partial.d.ts +47 -0
- package/dist/types/components/surface-provider.d.ts +15 -0
- package/dist/types/components/text.partial.d.ts +100 -28
- package/dist/types/components/types.d.ts +13 -0
- package/dist/types/constants.d.ts +3 -0
- package/dist/types/index.d.ts +8 -2
- package/dist/types/internal/color-map.d.ts +34 -0
- package/dist/types/internal/role-to-element.d.ts +32 -0
- package/examples/00-basic.tsx +18 -1
- package/examples/01-box.tsx +126 -2
- package/examples/02-text.tsx +76 -2
- package/examples/03-stack.tsx +125 -0
- package/examples/04-inline.tsx +134 -0
- package/examples/{03-badge.tsx → 05-badge.tsx} +4 -4
- package/examples/{04-section-message.tsx → 06-section-message.tsx} +6 -6
- package/examples/{05-comment.tsx → 07-comment.tsx} +11 -9
- package/examples/08-lozenge.tsx +29 -0
- package/examples/99-interactions.tsx +175 -0
- package/package.json +8 -5
- package/report.api.md +457 -4
- package/scripts/__tests__/__snapshots__/codegen.test.tsx.snap +244 -50
- package/scripts/__tests__/codegen.test.tsx +5 -0
- package/scripts/codegen-styles.tsx +46 -10
- package/scripts/color-codegen-template.tsx +34 -12
- package/scripts/color-map-template.tsx +52 -0
- package/scripts/interaction-codegen.tsx +109 -0
- package/scripts/spacing-codegen-template.tsx +9 -1
- package/scripts/utils.tsx +5 -1
- package/src/components/__tests__/unit/box.test.tsx +50 -0
- package/src/components/__tests__/unit/inline.test.tsx +43 -0
- package/src/components/__tests__/unit/interaction-suface.test.tsx +70 -0
- package/src/components/__tests__/unit/stack.test.tsx +31 -0
- package/src/components/__tests__/unit/text.test.tsx +33 -0
- package/src/components/__tests__/visual-regression/__image_snapshots__/box-snapshot-test-tsx-box-basic-example-should-match-production-example-1-snap.png +3 -0
- package/src/components/__tests__/visual-regression/__image_snapshots__/box-snapshot-test-tsx-box-example-with-alignment-should-match-snapshot-1-snap.png +3 -0
- package/src/components/__tests__/visual-regression/__image_snapshots__/box-snapshot-test-tsx-box-example-with-background-and-padding-block-should-match-snapshot-1-snap.png +3 -0
- package/src/components/__tests__/visual-regression/__image_snapshots__/box-snapshot-test-tsx-box-example-with-background-and-padding-inline-should-match-snapshot-1-snap.png +3 -0
- package/src/components/__tests__/visual-regression/__image_snapshots__/box-snapshot-test-tsx-box-example-with-background-and-padding-should-match-snapshot-1-snap.png +3 -0
- package/src/components/__tests__/visual-regression/__image_snapshots__/box-snapshot-test-tsx-box-example-with-background-color-should-match-snapshot-1-snap.png +3 -0
- package/src/components/__tests__/visual-regression/__image_snapshots__/box-snapshot-test-tsx-box-example-with-border-color-should-match-snapshot-1-snap.png +3 -0
- package/src/components/__tests__/visual-regression/__image_snapshots__/box-snapshot-test-tsx-box-example-with-border-should-match-snapshot-1-snap.png +3 -0
- package/src/components/__tests__/visual-regression/__image_snapshots__/inline-snapshot-test-tsx-inline-alignment-example-should-match-snapshot-1-snap.png +3 -0
- package/src/components/__tests__/visual-regression/__image_snapshots__/inline-snapshot-test-tsx-inline-spacing-example-should-match-snapshot-1-snap.png +3 -0
- package/src/components/__tests__/visual-regression/__image_snapshots__/stack-snapshot-test-tsx-stack-alignment-example-should-match-snapshot-1-snap.png +3 -0
- package/src/components/__tests__/visual-regression/__image_snapshots__/stack-snapshot-test-tsx-stack-spacing-example-should-match-snapshot-1-snap.png +3 -0
- package/src/components/__tests__/visual-regression/__image_snapshots__/text-snapshot-test-tsx-text-example-with-font-sizes-should-match-snapshot-1-snap.png +3 -0
- package/src/components/__tests__/visual-regression/__image_snapshots__/text-snapshot-test-tsx-text-example-with-font-weights-should-match-snapshot-1-snap.png +3 -0
- package/src/components/__tests__/visual-regression/__image_snapshots__/text-snapshot-test-tsx-text-example-with-line-heights-should-match-snapshot-1-snap.png +3 -0
- package/src/components/__tests__/visual-regression/__image_snapshots__/text-snapshot-test-tsx-text-example-with-testing-should-match-snapshot-1-snap.png +3 -0
- package/src/components/__tests__/visual-regression/box-snapshot-test.tsx +33 -0
- package/src/components/__tests__/visual-regression/inline-snapshot-test.tsx +28 -0
- package/src/components/__tests__/visual-regression/stack-snapshot-test.tsx +28 -0
- package/src/components/__tests__/visual-regression/text-snapshot-test.tsx +31 -0
- package/src/components/box.partial.tsx +305 -127
- package/src/components/inline.partial.tsx +120 -0
- package/src/components/interaction-surface.partial.tsx +237 -0
- package/src/components/stack.partial.tsx +104 -0
- package/src/components/surface-provider.tsx +25 -0
- package/src/components/text.partial.tsx +149 -38
- package/src/components/types.tsx +15 -0
- package/src/constants.tsx +3 -0
- package/src/index.tsx +8 -1
- package/src/internal/color-map.tsx +34 -0
- package/src/internal/role-to-element.tsx +34 -0
- package/dist/cjs/components/inline.js +0 -45
- package/dist/cjs/components/stack.js +0 -33
- package/dist/es2019/components/inline.js +0 -31
- package/dist/es2019/components/stack.js +0 -22
- package/dist/esm/components/inline.js +0 -30
- package/dist/esm/components/stack.js +0 -21
- package/dist/types/components/inline.d.ts +0 -19
- package/dist/types/components/stack.d.ts +0 -16
- package/src/components/inline.tsx +0 -49
- package/src/components/stack.tsx +0 -30
|
@@ -3,158 +3,352 @@
|
|
|
3
3
|
exports[`@atlaskit/design-system-explorations bg styles are generated correctly 1`] = `
|
|
4
4
|
"const backgroundColorMap = {
|
|
5
5
|
disabled: css({
|
|
6
|
-
backgroundColor: token('color.background.disabled', '
|
|
6
|
+
backgroundColor: token('color.background.disabled', 'var(--ds-bg-fb)'),
|
|
7
7
|
}),
|
|
8
8
|
'inverse.subtle': css({
|
|
9
|
-
backgroundColor: token(
|
|
9
|
+
backgroundColor: token(
|
|
10
|
+
'color.background.inverse.subtle',
|
|
11
|
+
'var(--ds-bg-fb)',
|
|
12
|
+
),
|
|
10
13
|
}),
|
|
11
14
|
input: css({
|
|
12
|
-
backgroundColor: token('color.background.input', '
|
|
15
|
+
backgroundColor: token('color.background.input', 'var(--ds-bg-fb)'),
|
|
13
16
|
}),
|
|
14
17
|
neutral: css({
|
|
15
|
-
backgroundColor: token('color.background.neutral', '
|
|
18
|
+
backgroundColor: token('color.background.neutral', 'var(--ds-bg-fb)'),
|
|
16
19
|
}),
|
|
17
20
|
'neutral.subtle': css({
|
|
18
|
-
backgroundColor: token(
|
|
21
|
+
backgroundColor: token(
|
|
22
|
+
'color.background.neutral.subtle',
|
|
23
|
+
'var(--ds-bg-fb)',
|
|
24
|
+
),
|
|
19
25
|
}),
|
|
20
26
|
'neutral.bold': css({
|
|
21
|
-
backgroundColor: token('color.background.neutral.bold', '
|
|
27
|
+
backgroundColor: token('color.background.neutral.bold', 'var(--ds-bg-fb)'),
|
|
22
28
|
}),
|
|
23
29
|
'brand.bold': css({
|
|
24
|
-
backgroundColor: token('color.background.brand.bold', '
|
|
30
|
+
backgroundColor: token('color.background.brand.bold', 'var(--ds-bg-fb)'),
|
|
25
31
|
}),
|
|
26
32
|
selected: css({
|
|
27
|
-
backgroundColor: token('color.background.selected', '
|
|
33
|
+
backgroundColor: token('color.background.selected', 'var(--ds-bg-fb)'),
|
|
28
34
|
}),
|
|
29
35
|
'selected.bold': css({
|
|
30
|
-
backgroundColor: token('color.background.selected.bold', '
|
|
36
|
+
backgroundColor: token('color.background.selected.bold', 'var(--ds-bg-fb)'),
|
|
31
37
|
}),
|
|
32
38
|
danger: css({
|
|
33
|
-
backgroundColor: token('color.background.danger', '
|
|
39
|
+
backgroundColor: token('color.background.danger', 'var(--ds-bg-fb)'),
|
|
34
40
|
}),
|
|
35
41
|
'danger.bold': css({
|
|
36
|
-
backgroundColor: token('color.background.danger.bold', '
|
|
42
|
+
backgroundColor: token('color.background.danger.bold', 'var(--ds-bg-fb)'),
|
|
37
43
|
}),
|
|
38
44
|
warning: css({
|
|
39
|
-
backgroundColor: token('color.background.warning', '
|
|
45
|
+
backgroundColor: token('color.background.warning', 'var(--ds-bg-fb)'),
|
|
40
46
|
}),
|
|
41
47
|
'warning.bold': css({
|
|
42
|
-
backgroundColor: token('color.background.warning.bold', '
|
|
48
|
+
backgroundColor: token('color.background.warning.bold', 'var(--ds-bg-fb)'),
|
|
43
49
|
}),
|
|
44
50
|
success: css({
|
|
45
|
-
backgroundColor: token('color.background.success', '
|
|
51
|
+
backgroundColor: token('color.background.success', 'var(--ds-bg-fb)'),
|
|
46
52
|
}),
|
|
47
53
|
'success.bold': css({
|
|
48
|
-
backgroundColor: token('color.background.success.bold', '
|
|
54
|
+
backgroundColor: token('color.background.success.bold', 'var(--ds-bg-fb)'),
|
|
49
55
|
}),
|
|
50
56
|
discovery: css({
|
|
51
|
-
backgroundColor: token('color.background.discovery', '
|
|
57
|
+
backgroundColor: token('color.background.discovery', 'var(--ds-bg-fb)'),
|
|
52
58
|
}),
|
|
53
59
|
'discovery.bold': css({
|
|
54
|
-
backgroundColor: token(
|
|
60
|
+
backgroundColor: token(
|
|
61
|
+
'color.background.discovery.bold',
|
|
62
|
+
'var(--ds-bg-fb)',
|
|
63
|
+
),
|
|
55
64
|
}),
|
|
56
65
|
information: css({
|
|
57
|
-
backgroundColor: token('color.background.information', '
|
|
66
|
+
backgroundColor: token('color.background.information', 'var(--ds-bg-fb)'),
|
|
58
67
|
}),
|
|
59
68
|
'information.bold': css({
|
|
60
|
-
backgroundColor: token(
|
|
69
|
+
backgroundColor: token(
|
|
70
|
+
'color.background.information.bold',
|
|
71
|
+
'var(--ds-bg-fb)',
|
|
72
|
+
),
|
|
73
|
+
}),
|
|
74
|
+
'color.blanket': css({
|
|
75
|
+
backgroundColor: token('color.blanket', 'var(--ds-bg-fb)'),
|
|
76
|
+
}),
|
|
77
|
+
'color.blanket.selected': css({
|
|
78
|
+
backgroundColor: token('color.blanket.selected', 'var(--ds-bg-fb)'),
|
|
79
|
+
}),
|
|
80
|
+
'color.blanket.danger': css({
|
|
81
|
+
backgroundColor: token('color.blanket.danger', 'var(--ds-bg-fb)'),
|
|
82
|
+
}),
|
|
83
|
+
'elevation.surface': css({
|
|
84
|
+
backgroundColor: token('elevation.surface', 'var(--ds-bg-fb)'),
|
|
85
|
+
}),
|
|
86
|
+
'elevation.surface.sunken': css({
|
|
87
|
+
backgroundColor: token('elevation.surface.sunken', 'var(--ds-bg-fb)'),
|
|
88
|
+
}),
|
|
89
|
+
'elevation.surface.raised': css({
|
|
90
|
+
backgroundColor: token('elevation.surface.raised', 'var(--ds-bg-fb)'),
|
|
91
|
+
}),
|
|
92
|
+
'elevation.surface.overlay': css({
|
|
93
|
+
backgroundColor: token('elevation.surface.overlay', 'var(--ds-bg-fb)'),
|
|
61
94
|
}),
|
|
62
95
|
};
|
|
63
96
|
|
|
64
|
-
type BackgroundColor = keyof typeof backgroundColorMap;
|
|
97
|
+
export type BackgroundColor = keyof typeof backgroundColorMap;
|
|
65
98
|
"
|
|
66
99
|
`;
|
|
67
100
|
|
|
68
101
|
exports[`@atlaskit/design-system-explorations border styles are generated correctly 1`] = `
|
|
69
102
|
"const borderColorMap = {
|
|
70
|
-
|
|
71
|
-
borderColor: token('color.border', '
|
|
103
|
+
'color.border': css({
|
|
104
|
+
borderColor: token('color.border', 'var(--ds-bo-fb)'),
|
|
72
105
|
}),
|
|
73
106
|
bold: css({
|
|
74
|
-
borderColor: token('color.border.bold', '
|
|
107
|
+
borderColor: token('color.border.bold', 'var(--ds-bo-fb)'),
|
|
75
108
|
}),
|
|
76
109
|
inverse: css({
|
|
77
|
-
borderColor: token('color.border.inverse', '
|
|
110
|
+
borderColor: token('color.border.inverse', 'var(--ds-bo-fb)'),
|
|
78
111
|
}),
|
|
79
112
|
focused: css({
|
|
80
|
-
borderColor: token('color.border.focused', '
|
|
113
|
+
borderColor: token('color.border.focused', 'var(--ds-bo-fb)'),
|
|
81
114
|
}),
|
|
82
115
|
input: css({
|
|
83
|
-
borderColor: token('color.border.input', '
|
|
116
|
+
borderColor: token('color.border.input', 'var(--ds-bo-fb)'),
|
|
84
117
|
}),
|
|
85
118
|
disabled: css({
|
|
86
|
-
borderColor: token('color.border.disabled', '
|
|
119
|
+
borderColor: token('color.border.disabled', 'var(--ds-bo-fb)'),
|
|
87
120
|
}),
|
|
88
121
|
brand: css({
|
|
89
|
-
borderColor: token('color.border.brand', '
|
|
122
|
+
borderColor: token('color.border.brand', 'var(--ds-bo-fb)'),
|
|
123
|
+
}),
|
|
124
|
+
selected: css({
|
|
125
|
+
borderColor: token('color.border.selected', 'var(--ds-bo-fb)'),
|
|
126
|
+
}),
|
|
127
|
+
danger: css({
|
|
128
|
+
borderColor: token('color.border.danger', 'var(--ds-bo-fb)'),
|
|
129
|
+
}),
|
|
130
|
+
warning: css({
|
|
131
|
+
borderColor: token('color.border.warning', 'var(--ds-bo-fb)'),
|
|
132
|
+
}),
|
|
133
|
+
success: css({
|
|
134
|
+
borderColor: token('color.border.success', 'var(--ds-bo-fb)'),
|
|
135
|
+
}),
|
|
136
|
+
discovery: css({
|
|
137
|
+
borderColor: token('color.border.discovery', 'var(--ds-bo-fb)'),
|
|
138
|
+
}),
|
|
139
|
+
information: css({
|
|
140
|
+
borderColor: token('color.border.information', 'var(--ds-bo-fb)'),
|
|
141
|
+
}),
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
export type BorderColor = keyof typeof borderColorMap;
|
|
145
|
+
"
|
|
146
|
+
`;
|
|
147
|
+
|
|
148
|
+
exports[`@atlaskit/design-system-explorations border styles are generated correctly 2`] = `
|
|
149
|
+
"const backgroundActiveColorMap = {
|
|
150
|
+
'inverse.subtle': css({
|
|
151
|
+
':active': {
|
|
152
|
+
backgroundColor: token('color.background.inverse.subtle.pressed'),
|
|
153
|
+
},
|
|
154
|
+
}),
|
|
155
|
+
input: css({
|
|
156
|
+
':active': { backgroundColor: token('color.background.input.pressed') },
|
|
157
|
+
}),
|
|
158
|
+
neutral: css({
|
|
159
|
+
':active': { backgroundColor: token('color.background.neutral.pressed') },
|
|
160
|
+
}),
|
|
161
|
+
'neutral.subtle': css({
|
|
162
|
+
':active': {
|
|
163
|
+
backgroundColor: token('color.background.neutral.subtle.pressed'),
|
|
164
|
+
},
|
|
165
|
+
}),
|
|
166
|
+
'neutral.bold': css({
|
|
167
|
+
':active': {
|
|
168
|
+
backgroundColor: token('color.background.neutral.bold.pressed'),
|
|
169
|
+
},
|
|
170
|
+
}),
|
|
171
|
+
'brand.bold': css({
|
|
172
|
+
':active': {
|
|
173
|
+
backgroundColor: token('color.background.brand.bold.pressed'),
|
|
174
|
+
},
|
|
175
|
+
}),
|
|
176
|
+
selected: css({
|
|
177
|
+
':active': { backgroundColor: token('color.background.selected.pressed') },
|
|
178
|
+
}),
|
|
179
|
+
'selected.bold': css({
|
|
180
|
+
':active': {
|
|
181
|
+
backgroundColor: token('color.background.selected.bold.pressed'),
|
|
182
|
+
},
|
|
183
|
+
}),
|
|
184
|
+
danger: css({
|
|
185
|
+
':active': { backgroundColor: token('color.background.danger.pressed') },
|
|
186
|
+
}),
|
|
187
|
+
'danger.bold': css({
|
|
188
|
+
':active': {
|
|
189
|
+
backgroundColor: token('color.background.danger.bold.pressed'),
|
|
190
|
+
},
|
|
191
|
+
}),
|
|
192
|
+
warning: css({
|
|
193
|
+
':active': { backgroundColor: token('color.background.warning.pressed') },
|
|
194
|
+
}),
|
|
195
|
+
'warning.bold': css({
|
|
196
|
+
':active': {
|
|
197
|
+
backgroundColor: token('color.background.warning.bold.pressed'),
|
|
198
|
+
},
|
|
199
|
+
}),
|
|
200
|
+
success: css({
|
|
201
|
+
':active': { backgroundColor: token('color.background.success.pressed') },
|
|
202
|
+
}),
|
|
203
|
+
'success.bold': css({
|
|
204
|
+
':active': {
|
|
205
|
+
backgroundColor: token('color.background.success.bold.pressed'),
|
|
206
|
+
},
|
|
207
|
+
}),
|
|
208
|
+
discovery: css({
|
|
209
|
+
':active': { backgroundColor: token('color.background.discovery.pressed') },
|
|
210
|
+
}),
|
|
211
|
+
'discovery.bold': css({
|
|
212
|
+
':active': {
|
|
213
|
+
backgroundColor: token('color.background.discovery.bold.pressed'),
|
|
214
|
+
},
|
|
215
|
+
}),
|
|
216
|
+
information: css({
|
|
217
|
+
':active': {
|
|
218
|
+
backgroundColor: token('color.background.information.pressed'),
|
|
219
|
+
},
|
|
220
|
+
}),
|
|
221
|
+
'information.bold': css({
|
|
222
|
+
':active': {
|
|
223
|
+
backgroundColor: token('color.background.information.bold.pressed'),
|
|
224
|
+
},
|
|
225
|
+
}),
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
const backgroundHoverColorMap = {
|
|
229
|
+
'inverse.subtle': css({
|
|
230
|
+
':hover': {
|
|
231
|
+
backgroundColor: token('color.background.inverse.subtle.hovered'),
|
|
232
|
+
},
|
|
233
|
+
}),
|
|
234
|
+
input: css({
|
|
235
|
+
':hover': { backgroundColor: token('color.background.input.hovered') },
|
|
236
|
+
}),
|
|
237
|
+
neutral: css({
|
|
238
|
+
':hover': { backgroundColor: token('color.background.neutral.hovered') },
|
|
239
|
+
}),
|
|
240
|
+
'neutral.subtle': css({
|
|
241
|
+
':hover': {
|
|
242
|
+
backgroundColor: token('color.background.neutral.subtle.hovered'),
|
|
243
|
+
},
|
|
244
|
+
}),
|
|
245
|
+
'neutral.bold': css({
|
|
246
|
+
':hover': {
|
|
247
|
+
backgroundColor: token('color.background.neutral.bold.hovered'),
|
|
248
|
+
},
|
|
249
|
+
}),
|
|
250
|
+
'brand.bold': css({
|
|
251
|
+
':hover': { backgroundColor: token('color.background.brand.bold.hovered') },
|
|
90
252
|
}),
|
|
91
253
|
selected: css({
|
|
92
|
-
|
|
254
|
+
':hover': { backgroundColor: token('color.background.selected.hovered') },
|
|
255
|
+
}),
|
|
256
|
+
'selected.bold': css({
|
|
257
|
+
':hover': {
|
|
258
|
+
backgroundColor: token('color.background.selected.bold.hovered'),
|
|
259
|
+
},
|
|
93
260
|
}),
|
|
94
261
|
danger: css({
|
|
95
|
-
|
|
262
|
+
':hover': { backgroundColor: token('color.background.danger.hovered') },
|
|
263
|
+
}),
|
|
264
|
+
'danger.bold': css({
|
|
265
|
+
':hover': {
|
|
266
|
+
backgroundColor: token('color.background.danger.bold.hovered'),
|
|
267
|
+
},
|
|
96
268
|
}),
|
|
97
269
|
warning: css({
|
|
98
|
-
|
|
270
|
+
':hover': { backgroundColor: token('color.background.warning.hovered') },
|
|
271
|
+
}),
|
|
272
|
+
'warning.bold': css({
|
|
273
|
+
':hover': {
|
|
274
|
+
backgroundColor: token('color.background.warning.bold.hovered'),
|
|
275
|
+
},
|
|
99
276
|
}),
|
|
100
277
|
success: css({
|
|
101
|
-
|
|
278
|
+
':hover': { backgroundColor: token('color.background.success.hovered') },
|
|
279
|
+
}),
|
|
280
|
+
'success.bold': css({
|
|
281
|
+
':hover': {
|
|
282
|
+
backgroundColor: token('color.background.success.bold.hovered'),
|
|
283
|
+
},
|
|
102
284
|
}),
|
|
103
285
|
discovery: css({
|
|
104
|
-
|
|
286
|
+
':hover': { backgroundColor: token('color.background.discovery.hovered') },
|
|
287
|
+
}),
|
|
288
|
+
'discovery.bold': css({
|
|
289
|
+
':hover': {
|
|
290
|
+
backgroundColor: token('color.background.discovery.bold.hovered'),
|
|
291
|
+
},
|
|
105
292
|
}),
|
|
106
293
|
information: css({
|
|
107
|
-
|
|
294
|
+
':hover': {
|
|
295
|
+
backgroundColor: token('color.background.information.hovered'),
|
|
296
|
+
},
|
|
297
|
+
}),
|
|
298
|
+
'information.bold': css({
|
|
299
|
+
':hover': {
|
|
300
|
+
backgroundColor: token('color.background.information.bold.hovered'),
|
|
301
|
+
},
|
|
108
302
|
}),
|
|
109
303
|
};
|
|
110
304
|
|
|
111
|
-
type
|
|
305
|
+
type InteractionBackgroundColor = keyof typeof backgroundHoverColorMap;
|
|
112
306
|
"
|
|
113
307
|
`;
|
|
114
308
|
|
|
115
309
|
exports[`@atlaskit/design-system-explorations text styles are generated correctly 1`] = `
|
|
116
310
|
"const textColorMap = {
|
|
117
|
-
|
|
118
|
-
color: token('color.text', '
|
|
311
|
+
'color.text': css({
|
|
312
|
+
color: token('color.text', 'var(--ds-co-fb)'),
|
|
119
313
|
}),
|
|
120
314
|
subtle: css({
|
|
121
|
-
color: token('color.text.subtle', '
|
|
315
|
+
color: token('color.text.subtle', 'var(--ds-co-fb)'),
|
|
122
316
|
}),
|
|
123
317
|
subtlest: css({
|
|
124
|
-
color: token('color.text.subtlest', '
|
|
318
|
+
color: token('color.text.subtlest', 'var(--ds-co-fb)'),
|
|
125
319
|
}),
|
|
126
320
|
disabled: css({
|
|
127
|
-
color: token('color.text.disabled', '
|
|
321
|
+
color: token('color.text.disabled', 'var(--ds-co-fb)'),
|
|
128
322
|
}),
|
|
129
323
|
inverse: css({
|
|
130
|
-
color: token('color.text.inverse', '
|
|
324
|
+
color: token('color.text.inverse', 'var(--ds-co-fb)'),
|
|
131
325
|
}),
|
|
132
326
|
brand: css({
|
|
133
|
-
color: token('color.text.brand', '
|
|
327
|
+
color: token('color.text.brand', 'var(--ds-co-fb)'),
|
|
134
328
|
}),
|
|
135
329
|
selected: css({
|
|
136
|
-
color: token('color.text.selected', '
|
|
330
|
+
color: token('color.text.selected', 'var(--ds-co-fb)'),
|
|
137
331
|
}),
|
|
138
332
|
danger: css({
|
|
139
|
-
color: token('color.text.danger', '
|
|
333
|
+
color: token('color.text.danger', 'var(--ds-co-fb)'),
|
|
140
334
|
}),
|
|
141
335
|
warning: css({
|
|
142
|
-
color: token('color.text.warning', '
|
|
336
|
+
color: token('color.text.warning', 'var(--ds-co-fb)'),
|
|
143
337
|
}),
|
|
144
338
|
'warning.inverse': css({
|
|
145
|
-
color: token('color.text.warning.inverse', '
|
|
339
|
+
color: token('color.text.warning.inverse', 'var(--ds-co-fb)'),
|
|
146
340
|
}),
|
|
147
341
|
success: css({
|
|
148
|
-
color: token('color.text.success', '
|
|
342
|
+
color: token('color.text.success', 'var(--ds-co-fb)'),
|
|
149
343
|
}),
|
|
150
344
|
discovery: css({
|
|
151
|
-
color: token('color.text.discovery', '
|
|
345
|
+
color: token('color.text.discovery', 'var(--ds-co-fb)'),
|
|
152
346
|
}),
|
|
153
347
|
information: css({
|
|
154
|
-
color: token('color.text.information', '
|
|
348
|
+
color: token('color.text.information', 'var(--ds-co-fb)'),
|
|
155
349
|
}),
|
|
156
350
|
};
|
|
157
351
|
|
|
158
|
-
type TextColor = keyof typeof textColorMap;
|
|
352
|
+
export type TextColor = keyof typeof textColorMap;
|
|
159
353
|
"
|
|
160
354
|
`;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createColorStylesFromTemplate } from '../color-codegen-template';
|
|
2
|
+
import { createInteractionStylesFromTemplate } from '../interaction-codegen';
|
|
2
3
|
describe('@atlaskit/design-system-explorations', () => {
|
|
3
4
|
test('text styles are generated correctly', () => {
|
|
4
5
|
expect(createColorStylesFromTemplate('text')).toMatchSnapshot();
|
|
@@ -12,6 +13,10 @@ describe('@atlaskit/design-system-explorations', () => {
|
|
|
12
13
|
expect(createColorStylesFromTemplate('border')).toMatchSnapshot();
|
|
13
14
|
});
|
|
14
15
|
|
|
16
|
+
test('border styles are generated correctly', () => {
|
|
17
|
+
expect(createInteractionStylesFromTemplate('background')).toMatchSnapshot();
|
|
18
|
+
});
|
|
19
|
+
|
|
15
20
|
test('incorrect config throws', () => {
|
|
16
21
|
expect(() =>
|
|
17
22
|
createColorStylesFromTemplate('fizzbuzz' as any),
|
|
@@ -1,13 +1,23 @@
|
|
|
1
1
|
/* eslint-disable no-console */
|
|
2
|
+
import { writeFile } from 'fs/promises';
|
|
2
3
|
import { join } from 'path';
|
|
3
4
|
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import { createPartialSignedArtifact } from '@af/codegen';
|
|
5
|
+
import { createPartialSignedArtifact, createSignedArtifact } from '@af/codegen';
|
|
7
6
|
|
|
8
7
|
import { createColorStylesFromTemplate } from './color-codegen-template';
|
|
8
|
+
import { createColorMapTemplate } from './color-map-template';
|
|
9
|
+
import { createInteractionStylesFromTemplate } from './interaction-codegen';
|
|
9
10
|
import { createSpacingStylesFromTemplate } from './spacing-codegen-template';
|
|
10
11
|
|
|
12
|
+
writeFile(
|
|
13
|
+
join(__dirname, '../', 'src', 'internal', 'color-map.tsx'),
|
|
14
|
+
createSignedArtifact(
|
|
15
|
+
createColorMapTemplate(),
|
|
16
|
+
'yarn codegen-styles',
|
|
17
|
+
'Some artifact',
|
|
18
|
+
),
|
|
19
|
+
).then(() => console.log('color-map.tsx written!'));
|
|
20
|
+
|
|
11
21
|
// generate colors
|
|
12
22
|
Promise.all(
|
|
13
23
|
[{ target: 'text.partial.tsx' }, { target: 'box.partial.tsx' }].map(
|
|
@@ -25,19 +35,45 @@ Promise.all(
|
|
|
25
35
|
);
|
|
26
36
|
},
|
|
27
37
|
),
|
|
28
|
-
)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
38
|
+
)
|
|
39
|
+
.then(() => {
|
|
40
|
+
// generate spacing values
|
|
41
|
+
return Promise.all(
|
|
42
|
+
[
|
|
43
|
+
{ target: 'box.partial.tsx' },
|
|
44
|
+
{ target: 'stack.partial.tsx' },
|
|
45
|
+
{ target: 'inline.partial.tsx' },
|
|
46
|
+
].map(({ target }) => {
|
|
47
|
+
const targetPath = join(__dirname, '../', 'src', 'components', target);
|
|
48
|
+
|
|
49
|
+
const source = createPartialSignedArtifact(
|
|
50
|
+
(options) => options.map(createSpacingStylesFromTemplate).join('\n'),
|
|
51
|
+
'yarn codegen-styles',
|
|
52
|
+
{ id: 'spacing', absoluteFilePath: targetPath },
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
return writeFile(targetPath, source).then(() =>
|
|
56
|
+
console.log(`${targetPath} written!`),
|
|
57
|
+
);
|
|
58
|
+
}),
|
|
59
|
+
);
|
|
60
|
+
})
|
|
61
|
+
.then(() => {
|
|
62
|
+
const targetPath = join(
|
|
63
|
+
__dirname,
|
|
64
|
+
'../',
|
|
65
|
+
'src',
|
|
66
|
+
'components',
|
|
67
|
+
'interaction-surface.partial.tsx',
|
|
68
|
+
);
|
|
32
69
|
|
|
33
70
|
const source = createPartialSignedArtifact(
|
|
34
|
-
(options) => options.map(
|
|
71
|
+
(options) => options.map(createInteractionStylesFromTemplate).join('\n'),
|
|
35
72
|
'yarn codegen-styles',
|
|
36
|
-
{ id: '
|
|
73
|
+
{ id: 'interactions', absoluteFilePath: targetPath },
|
|
37
74
|
);
|
|
38
75
|
|
|
39
76
|
return writeFile(targetPath, source).then(() =>
|
|
40
77
|
console.log(`${targetPath} written!`),
|
|
41
78
|
);
|
|
42
79
|
});
|
|
43
|
-
});
|
|
@@ -15,18 +15,34 @@ import {
|
|
|
15
15
|
tokenToStyle,
|
|
16
16
|
} from './utils';
|
|
17
17
|
|
|
18
|
+
type Token = {
|
|
19
|
+
token: string;
|
|
20
|
+
fallback: string;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// NB: Fallback CSS variables can be deleted when tokens are no longer behind a feature flag
|
|
18
24
|
const colors = {
|
|
19
25
|
text: {
|
|
20
26
|
prefix: 'color.text.',
|
|
21
27
|
cssProperty: 'color',
|
|
28
|
+
legacyFallbackCSSProperty: '--ds-co-fb',
|
|
29
|
+
filterFn: <T extends Token>(t: T) => t.token.startsWith(colors.text.prefix),
|
|
22
30
|
},
|
|
23
31
|
background: {
|
|
24
32
|
prefix: 'color.background.',
|
|
25
33
|
cssProperty: 'backgroundColor',
|
|
34
|
+
legacyFallbackCSSProperty: '--ds-bg-fb',
|
|
35
|
+
filterFn: <T extends Token>(t: T) =>
|
|
36
|
+
t.token.startsWith(colors.background.prefix) ||
|
|
37
|
+
t.token.startsWith('elevation.surface') ||
|
|
38
|
+
t.token.startsWith('color.blanket'),
|
|
26
39
|
},
|
|
27
40
|
border: {
|
|
28
41
|
prefix: 'color.border.',
|
|
29
42
|
cssProperty: 'borderColor',
|
|
43
|
+
legacyFallbackCSSProperty: '--ds-bo-fb',
|
|
44
|
+
filterFn: <T extends Token>(t: T) =>
|
|
45
|
+
t.token.startsWith(colors.border.prefix),
|
|
30
46
|
},
|
|
31
47
|
} as const;
|
|
32
48
|
|
|
@@ -35,12 +51,12 @@ const activeTokens = tokens
|
|
|
35
51
|
(t) =>
|
|
36
52
|
t.attributes.state !== 'deleted' && t.attributes.state !== 'deprecated',
|
|
37
53
|
)
|
|
38
|
-
.map(
|
|
39
|
-
|
|
54
|
+
.map(
|
|
55
|
+
(t): Token => ({
|
|
40
56
|
token: t.name,
|
|
41
|
-
fallback: t.value,
|
|
42
|
-
}
|
|
43
|
-
|
|
57
|
+
fallback: t.value as string,
|
|
58
|
+
}),
|
|
59
|
+
)
|
|
44
60
|
.filter(compose(pick('token'), not(isAccent)))
|
|
45
61
|
.filter(compose(pick('token'), not(isPressed)))
|
|
46
62
|
.filter(compose(pick('token'), not(isHovered)));
|
|
@@ -52,31 +68,37 @@ export const createColorStylesFromTemplate = (
|
|
|
52
68
|
throw new Error(`[codegen] Unknown option found "${colorProperty}"`);
|
|
53
69
|
}
|
|
54
70
|
|
|
55
|
-
const { prefix, cssProperty } = colors[
|
|
71
|
+
const { prefix, cssProperty, filterFn, legacyFallbackCSSProperty } = colors[
|
|
72
|
+
colorProperty
|
|
73
|
+
];
|
|
56
74
|
|
|
57
75
|
return (
|
|
58
76
|
prettier.format(
|
|
59
77
|
`
|
|
60
78
|
const ${colorProperty}ColorMap = {
|
|
61
79
|
${activeTokens
|
|
62
|
-
.filter(
|
|
80
|
+
.filter(filterFn)
|
|
63
81
|
// @ts-ignore
|
|
64
82
|
.map((t) => ({ ...t, token: t.token.replaceAll('.[default]', '') }))
|
|
65
83
|
.map((t) => {
|
|
66
84
|
// handle the default case eg color.border or color.text
|
|
67
|
-
const
|
|
68
|
-
const propName = !t.token.startsWith(prefix) ? 'default' : replacedProp;
|
|
85
|
+
const propName = t.token.replace(prefix, '');
|
|
69
86
|
return `'${propName}': ${tokenToStyle(
|
|
70
87
|
cssProperty,
|
|
71
88
|
t.token,
|
|
72
|
-
|
|
89
|
+
`"var(${legacyFallbackCSSProperty})"`,
|
|
73
90
|
)}`;
|
|
74
91
|
})
|
|
75
92
|
.join(',\n\t')}
|
|
76
93
|
};`,
|
|
77
|
-
{
|
|
94
|
+
{
|
|
95
|
+
singleQuote: true,
|
|
96
|
+
parser: 'typescript',
|
|
97
|
+
trailingComma: 'all',
|
|
98
|
+
plugins: [parserTypeScript],
|
|
99
|
+
},
|
|
78
100
|
) +
|
|
79
|
-
`\
|
|
101
|
+
`\nexport type ${capitalize(
|
|
80
102
|
colorProperty,
|
|
81
103
|
)}Color = keyof typeof ${colorProperty}ColorMap;\n`
|
|
82
104
|
);
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import prettier from 'prettier';
|
|
2
|
+
import parserTypeScript from 'prettier/parser-typescript';
|
|
3
|
+
|
|
4
|
+
// eslint-disable-next-line @atlassian/tangerine/import/entry-points
|
|
5
|
+
import tokens from '@atlaskit/tokens/src/artifacts/tokens-raw/atlassian-light';
|
|
6
|
+
|
|
7
|
+
import { compose, isAccent, not, pick } from './utils';
|
|
8
|
+
|
|
9
|
+
type Token = {
|
|
10
|
+
token: string;
|
|
11
|
+
fallback: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const activeTokens = tokens
|
|
15
|
+
.filter(
|
|
16
|
+
(t) =>
|
|
17
|
+
t.attributes.state !== 'deleted' && t.attributes.state !== 'deprecated',
|
|
18
|
+
)
|
|
19
|
+
.map(
|
|
20
|
+
(t): Token => ({
|
|
21
|
+
token: t.name,
|
|
22
|
+
fallback: t.value as string,
|
|
23
|
+
}),
|
|
24
|
+
)
|
|
25
|
+
.filter(compose(pick('token'), not(isAccent)))
|
|
26
|
+
.filter((t) => t.token.includes('background'))
|
|
27
|
+
.filter((t) => t.token.includes('bold'))
|
|
28
|
+
// @ts-ignore
|
|
29
|
+
.map((t) => ({ ...t, token: t.token.replaceAll('.[default]', '') }));
|
|
30
|
+
|
|
31
|
+
export const createColorMapTemplate = () => {
|
|
32
|
+
return prettier.format(
|
|
33
|
+
`
|
|
34
|
+
export const colorMap = {
|
|
35
|
+
${activeTokens
|
|
36
|
+
.map((t) => {
|
|
37
|
+
// handle the default case eg color.border or color.text
|
|
38
|
+
const propName = t.token.replace('color.background.', '');
|
|
39
|
+
return `'${propName}': '${
|
|
40
|
+
propName.includes('warning') ? 'warning.inverse' : 'inverse'
|
|
41
|
+
}'`;
|
|
42
|
+
})
|
|
43
|
+
.join(',\n\t')}
|
|
44
|
+
} as const;`,
|
|
45
|
+
{
|
|
46
|
+
singleQuote: true,
|
|
47
|
+
parser: 'typescript',
|
|
48
|
+
trailingComma: 'all',
|
|
49
|
+
plugins: [parserTypeScript],
|
|
50
|
+
},
|
|
51
|
+
);
|
|
52
|
+
};
|