@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.
Files changed (114) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/dist/cjs/components/box.partial.js +355 -185
  3. package/dist/cjs/components/inline.partial.js +124 -0
  4. package/dist/cjs/components/interaction-surface.partial.js +253 -0
  5. package/dist/cjs/components/stack.partial.js +116 -0
  6. package/dist/cjs/components/surface-provider.js +31 -0
  7. package/dist/cjs/components/text.partial.js +152 -49
  8. package/dist/cjs/components/types.js +5 -0
  9. package/dist/cjs/constants.js +3 -0
  10. package/dist/cjs/index.js +50 -3
  11. package/dist/cjs/internal/color-map.js +42 -0
  12. package/dist/cjs/internal/role-to-element.js +36 -0
  13. package/dist/cjs/version.json +1 -1
  14. package/dist/es2019/components/box.partial.js +259 -113
  15. package/dist/es2019/components/inline.partial.js +111 -0
  16. package/dist/es2019/components/interaction-surface.partial.js +243 -0
  17. package/dist/es2019/components/stack.partial.js +106 -0
  18. package/dist/es2019/components/surface-provider.js +20 -0
  19. package/dist/es2019/components/text.partial.js +122 -35
  20. package/dist/es2019/components/types.js +1 -0
  21. package/dist/es2019/constants.js +3 -0
  22. package/dist/es2019/index.js +6 -1
  23. package/dist/es2019/internal/color-map.js +34 -0
  24. package/dist/es2019/internal/role-to-element.js +28 -0
  25. package/dist/es2019/version.json +1 -1
  26. package/dist/esm/components/box.partial.js +274 -109
  27. package/dist/esm/components/inline.partial.js +110 -0
  28. package/dist/esm/components/interaction-surface.partial.js +242 -0
  29. package/dist/esm/components/stack.partial.js +105 -0
  30. package/dist/esm/components/surface-provider.js +20 -0
  31. package/dist/esm/components/text.partial.js +132 -34
  32. package/dist/esm/components/types.js +1 -0
  33. package/dist/esm/constants.js +3 -0
  34. package/dist/esm/index.js +6 -1
  35. package/dist/esm/internal/color-map.js +34 -0
  36. package/dist/esm/internal/role-to-element.js +28 -0
  37. package/dist/esm/version.json +1 -1
  38. package/dist/types/components/box.partial.d.ts +157 -76
  39. package/dist/types/components/inline.partial.d.ts +52 -0
  40. package/dist/types/components/interaction-surface.partial.d.ts +45 -0
  41. package/dist/types/components/stack.partial.d.ts +47 -0
  42. package/dist/types/components/surface-provider.d.ts +15 -0
  43. package/dist/types/components/text.partial.d.ts +100 -28
  44. package/dist/types/components/types.d.ts +13 -0
  45. package/dist/types/constants.d.ts +3 -0
  46. package/dist/types/index.d.ts +8 -2
  47. package/dist/types/internal/color-map.d.ts +34 -0
  48. package/dist/types/internal/role-to-element.d.ts +32 -0
  49. package/examples/00-basic.tsx +18 -1
  50. package/examples/01-box.tsx +126 -2
  51. package/examples/02-text.tsx +76 -2
  52. package/examples/03-stack.tsx +125 -0
  53. package/examples/04-inline.tsx +134 -0
  54. package/examples/{03-badge.tsx → 05-badge.tsx} +4 -4
  55. package/examples/{04-section-message.tsx → 06-section-message.tsx} +6 -6
  56. package/examples/{05-comment.tsx → 07-comment.tsx} +11 -9
  57. package/examples/08-lozenge.tsx +29 -0
  58. package/examples/99-interactions.tsx +175 -0
  59. package/package.json +8 -5
  60. package/report.api.md +457 -4
  61. package/scripts/__tests__/__snapshots__/codegen.test.tsx.snap +244 -50
  62. package/scripts/__tests__/codegen.test.tsx +5 -0
  63. package/scripts/codegen-styles.tsx +46 -10
  64. package/scripts/color-codegen-template.tsx +34 -12
  65. package/scripts/color-map-template.tsx +52 -0
  66. package/scripts/interaction-codegen.tsx +109 -0
  67. package/scripts/spacing-codegen-template.tsx +9 -1
  68. package/scripts/utils.tsx +5 -1
  69. package/src/components/__tests__/unit/box.test.tsx +50 -0
  70. package/src/components/__tests__/unit/inline.test.tsx +43 -0
  71. package/src/components/__tests__/unit/interaction-suface.test.tsx +70 -0
  72. package/src/components/__tests__/unit/stack.test.tsx +31 -0
  73. package/src/components/__tests__/unit/text.test.tsx +33 -0
  74. package/src/components/__tests__/visual-regression/__image_snapshots__/box-snapshot-test-tsx-box-basic-example-should-match-production-example-1-snap.png +3 -0
  75. package/src/components/__tests__/visual-regression/__image_snapshots__/box-snapshot-test-tsx-box-example-with-alignment-should-match-snapshot-1-snap.png +3 -0
  76. 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
  77. 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
  78. 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
  79. 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
  80. 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
  81. package/src/components/__tests__/visual-regression/__image_snapshots__/box-snapshot-test-tsx-box-example-with-border-should-match-snapshot-1-snap.png +3 -0
  82. package/src/components/__tests__/visual-regression/__image_snapshots__/inline-snapshot-test-tsx-inline-alignment-example-should-match-snapshot-1-snap.png +3 -0
  83. package/src/components/__tests__/visual-regression/__image_snapshots__/inline-snapshot-test-tsx-inline-spacing-example-should-match-snapshot-1-snap.png +3 -0
  84. package/src/components/__tests__/visual-regression/__image_snapshots__/stack-snapshot-test-tsx-stack-alignment-example-should-match-snapshot-1-snap.png +3 -0
  85. package/src/components/__tests__/visual-regression/__image_snapshots__/stack-snapshot-test-tsx-stack-spacing-example-should-match-snapshot-1-snap.png +3 -0
  86. 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
  87. 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
  88. 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
  89. package/src/components/__tests__/visual-regression/__image_snapshots__/text-snapshot-test-tsx-text-example-with-testing-should-match-snapshot-1-snap.png +3 -0
  90. package/src/components/__tests__/visual-regression/box-snapshot-test.tsx +33 -0
  91. package/src/components/__tests__/visual-regression/inline-snapshot-test.tsx +28 -0
  92. package/src/components/__tests__/visual-regression/stack-snapshot-test.tsx +28 -0
  93. package/src/components/__tests__/visual-regression/text-snapshot-test.tsx +31 -0
  94. package/src/components/box.partial.tsx +305 -127
  95. package/src/components/inline.partial.tsx +120 -0
  96. package/src/components/interaction-surface.partial.tsx +237 -0
  97. package/src/components/stack.partial.tsx +104 -0
  98. package/src/components/surface-provider.tsx +25 -0
  99. package/src/components/text.partial.tsx +149 -38
  100. package/src/components/types.tsx +15 -0
  101. package/src/constants.tsx +3 -0
  102. package/src/index.tsx +8 -1
  103. package/src/internal/color-map.tsx +34 -0
  104. package/src/internal/role-to-element.tsx +34 -0
  105. package/dist/cjs/components/inline.js +0 -45
  106. package/dist/cjs/components/stack.js +0 -33
  107. package/dist/es2019/components/inline.js +0 -31
  108. package/dist/es2019/components/stack.js +0 -22
  109. package/dist/esm/components/inline.js +0 -30
  110. package/dist/esm/components/stack.js +0 -21
  111. package/dist/types/components/inline.d.ts +0 -19
  112. package/dist/types/components/stack.d.ts +0 -16
  113. package/src/components/inline.tsx +0 -49
  114. 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', '#091E4208'),
6
+ backgroundColor: token('color.background.disabled', 'var(--ds-bg-fb)'),
7
7
  }),
8
8
  'inverse.subtle': css({
9
- backgroundColor: token('color.background.inverse.subtle', '#00000029'),
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', '#FFFFFF'),
15
+ backgroundColor: token('color.background.input', 'var(--ds-bg-fb)'),
13
16
  }),
14
17
  neutral: css({
15
- backgroundColor: token('color.background.neutral', '#091E420F'),
18
+ backgroundColor: token('color.background.neutral', 'var(--ds-bg-fb)'),
16
19
  }),
17
20
  'neutral.subtle': css({
18
- backgroundColor: token('color.background.neutral.subtle', '#00000000'),
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', '#44546F'),
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', '#0C66E4'),
30
+ backgroundColor: token('color.background.brand.bold', 'var(--ds-bg-fb)'),
25
31
  }),
26
32
  selected: css({
27
- backgroundColor: token('color.background.selected', '#E9F2FF'),
33
+ backgroundColor: token('color.background.selected', 'var(--ds-bg-fb)'),
28
34
  }),
29
35
  'selected.bold': css({
30
- backgroundColor: token('color.background.selected.bold', '#0C66E4'),
36
+ backgroundColor: token('color.background.selected.bold', 'var(--ds-bg-fb)'),
31
37
  }),
32
38
  danger: css({
33
- backgroundColor: token('color.background.danger', '#FFEDEB'),
39
+ backgroundColor: token('color.background.danger', 'var(--ds-bg-fb)'),
34
40
  }),
35
41
  'danger.bold': css({
36
- backgroundColor: token('color.background.danger.bold', '#CA3521'),
42
+ backgroundColor: token('color.background.danger.bold', 'var(--ds-bg-fb)'),
37
43
  }),
38
44
  warning: css({
39
- backgroundColor: token('color.background.warning', '#FFF7D6'),
45
+ backgroundColor: token('color.background.warning', 'var(--ds-bg-fb)'),
40
46
  }),
41
47
  'warning.bold': css({
42
- backgroundColor: token('color.background.warning.bold', '#E2B203'),
48
+ backgroundColor: token('color.background.warning.bold', 'var(--ds-bg-fb)'),
43
49
  }),
44
50
  success: css({
45
- backgroundColor: token('color.background.success', '#DFFCF0'),
51
+ backgroundColor: token('color.background.success', 'var(--ds-bg-fb)'),
46
52
  }),
47
53
  'success.bold': css({
48
- backgroundColor: token('color.background.success.bold', '#1F845A'),
54
+ backgroundColor: token('color.background.success.bold', 'var(--ds-bg-fb)'),
49
55
  }),
50
56
  discovery: css({
51
- backgroundColor: token('color.background.discovery', '#F3F0FF'),
57
+ backgroundColor: token('color.background.discovery', 'var(--ds-bg-fb)'),
52
58
  }),
53
59
  'discovery.bold': css({
54
- backgroundColor: token('color.background.discovery.bold', '#6E5DC6'),
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', '#E9F2FF'),
66
+ backgroundColor: token('color.background.information', 'var(--ds-bg-fb)'),
58
67
  }),
59
68
  'information.bold': css({
60
- backgroundColor: token('color.background.information.bold', '#0C66E4'),
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
- default: css({
71
- borderColor: token('color.border', '#091E4224'),
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', '#758195'),
107
+ borderColor: token('color.border.bold', 'var(--ds-bo-fb)'),
75
108
  }),
76
109
  inverse: css({
77
- borderColor: token('color.border.inverse', '#FFFFFF'),
110
+ borderColor: token('color.border.inverse', 'var(--ds-bo-fb)'),
78
111
  }),
79
112
  focused: css({
80
- borderColor: token('color.border.focused', '#388BFF'),
113
+ borderColor: token('color.border.focused', 'var(--ds-bo-fb)'),
81
114
  }),
82
115
  input: css({
83
- borderColor: token('color.border.input', '#091E4224'),
116
+ borderColor: token('color.border.input', 'var(--ds-bo-fb)'),
84
117
  }),
85
118
  disabled: css({
86
- borderColor: token('color.border.disabled', '#091E420F'),
119
+ borderColor: token('color.border.disabled', 'var(--ds-bo-fb)'),
87
120
  }),
88
121
  brand: css({
89
- borderColor: token('color.border.brand', '#0C66E4'),
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
- borderColor: token('color.border.selected', '#0C66E4'),
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
- borderColor: token('color.border.danger', '#E34935'),
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
- borderColor: token('color.border.warning', '#D97008'),
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
- borderColor: token('color.border.success', '#22A06B'),
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
- borderColor: token('color.border.discovery', '#8270DB'),
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
- borderColor: token('color.border.information', '#1D7AFC'),
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 BorderColor = keyof typeof borderColorMap;
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
- default: css({
118
- color: token('color.text', '#172B4D'),
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', '#44546F'),
315
+ color: token('color.text.subtle', 'var(--ds-co-fb)'),
122
316
  }),
123
317
  subtlest: css({
124
- color: token('color.text.subtlest', '#626F86'),
318
+ color: token('color.text.subtlest', 'var(--ds-co-fb)'),
125
319
  }),
126
320
  disabled: css({
127
- color: token('color.text.disabled', '#091E424F'),
321
+ color: token('color.text.disabled', 'var(--ds-co-fb)'),
128
322
  }),
129
323
  inverse: css({
130
- color: token('color.text.inverse', '#FFFFFF'),
324
+ color: token('color.text.inverse', 'var(--ds-co-fb)'),
131
325
  }),
132
326
  brand: css({
133
- color: token('color.text.brand', '#0C66E4'),
327
+ color: token('color.text.brand', 'var(--ds-co-fb)'),
134
328
  }),
135
329
  selected: css({
136
- color: token('color.text.selected', '#0C66E4'),
330
+ color: token('color.text.selected', 'var(--ds-co-fb)'),
137
331
  }),
138
332
  danger: css({
139
- color: token('color.text.danger', '#AE2A19'),
333
+ color: token('color.text.danger', 'var(--ds-co-fb)'),
140
334
  }),
141
335
  warning: css({
142
- color: token('color.text.warning', '#974F0C'),
336
+ color: token('color.text.warning', 'var(--ds-co-fb)'),
143
337
  }),
144
338
  'warning.inverse': css({
145
- color: token('color.text.warning.inverse', '#172B4D'),
339
+ color: token('color.text.warning.inverse', 'var(--ds-co-fb)'),
146
340
  }),
147
341
  success: css({
148
- color: token('color.text.success', '#216E4E'),
342
+ color: token('color.text.success', 'var(--ds-co-fb)'),
149
343
  }),
150
344
  discovery: css({
151
- color: token('color.text.discovery', '#5E4DB2'),
345
+ color: token('color.text.discovery', 'var(--ds-co-fb)'),
152
346
  }),
153
347
  information: css({
154
- color: token('color.text.information', '#0055CC'),
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 { writeFile } from 'fs-extra';
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
- ).then(() => {
29
- // generate spacing values
30
- [{ target: 'box.partial.tsx' }].forEach(({ target }) => {
31
- const targetPath = join(__dirname, '../', 'src', 'components', target);
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(createSpacingStylesFromTemplate).join('\n'),
71
+ (options) => options.map(createInteractionStylesFromTemplate).join('\n'),
35
72
  'yarn codegen-styles',
36
- { id: 'spacing', absoluteFilePath: targetPath },
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((t) => {
39
- return {
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[colorProperty];
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(({ token }) => token.includes(prefix))
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 replacedProp = t.token.replace(prefix, '');
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
- t.fallback as string,
89
+ `"var(${legacyFallbackCSSProperty})"`,
73
90
  )}`;
74
91
  })
75
92
  .join(',\n\t')}
76
93
  };`,
77
- { singleQuote: true, parser: 'typescript', plugins: [parserTypeScript] },
94
+ {
95
+ singleQuote: true,
96
+ parser: 'typescript',
97
+ trailingComma: 'all',
98
+ plugins: [parserTypeScript],
99
+ },
78
100
  ) +
79
- `\ntype ${capitalize(
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
+ };