@atlaskit/tokens 1.43.1 → 1.43.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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/tokens
2
2
 
3
+ ## 1.43.2
4
+
5
+ ### Patch Changes
6
+
7
+ - [#94316](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/94316) [`35fd5ed8e1d7`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/35fd5ed8e1d7) - Upgrading internal dependency `bind-event-listener` to `@^3.0.0`
8
+
3
9
  ## 1.43.1
4
10
 
5
11
  ### Patch Changes
@@ -1,9 +1,11 @@
1
1
  import cssToDesignTokens from './css-to-design-tokens/transform';
2
+ import removeFallbacksColor from './remove-fallbacks-color/transform';
2
3
  import themeToDesignTokens from './theme-to-design-tokens/transform';
3
4
 
4
5
  export default {
5
6
  presets: {
6
7
  'theme-to-design-tokens': themeToDesignTokens,
7
8
  'css-to-design-tokens': cssToDesignTokens,
9
+ 'remove-fallbacks-color': removeFallbacksColor,
8
10
  },
9
11
  };
@@ -0,0 +1,26 @@
1
+ import { hasImportDeclaration } from '@hypermod/utils';
2
+ import type { API, FileInfo } from 'jscodeshift';
3
+
4
+ export default async function transformer(file: FileInfo, api: API) {
5
+ const j = api.jscodeshift;
6
+ const source = j(file.source);
7
+
8
+ if (!hasImportDeclaration(j, source, '@atlaskit/tokens')) {
9
+ return file.source;
10
+ }
11
+
12
+ source
13
+ .find(j.CallExpression, { callee: { name: 'token' } })
14
+ .forEach((path) => {
15
+ if (
16
+ path.node.arguments.length > 1 &&
17
+ j.StringLiteral.check(path.node.arguments[0]) &&
18
+ /^color\.|elevation/.test(path.node.arguments[0].value)
19
+ ) {
20
+ // Remove the second argument
21
+ path.node.arguments.splice(1, 1);
22
+ }
23
+ });
24
+
25
+ return source.toSource();
26
+ }
@@ -8,7 +8,7 @@ exports.default = void 0;
8
8
  var _warnOnce = _interopRequireDefault(require("@atlaskit/ds-lib/warn-once"));
9
9
  var _tokenNames = _interopRequireDefault(require("./artifacts/token-names"));
10
10
  var name = "@atlaskit/tokens";
11
- var version = "1.43.1";
11
+ var version = "1.43.2";
12
12
  /**
13
13
  * Takes a dot-separated token name and and an optional fallback, and returns the current computed CSS value for the
14
14
  * resulting CSS Custom Property.
@@ -9,7 +9,7 @@ var _warnOnce = _interopRequireDefault(require("@atlaskit/ds-lib/warn-once"));
9
9
  var _tokenNames = _interopRequireDefault(require("./artifacts/token-names"));
10
10
  var _constants = require("./constants");
11
11
  var name = "@atlaskit/tokens";
12
- var version = "1.43.1";
12
+ var version = "1.43.2";
13
13
  /**
14
14
  * Takes a dot-separated token name and an optional fallback, and returns the CSS custom property for the corresponding token.
15
15
  * This should be used to implement design decisions throughout your application.
@@ -1,7 +1,7 @@
1
1
  import warnOnce from '@atlaskit/ds-lib/warn-once';
2
2
  import tokens from './artifacts/token-names';
3
3
  const name = "@atlaskit/tokens";
4
- const version = "1.43.1";
4
+ const version = "1.43.2";
5
5
  /**
6
6
  * Takes a dot-separated token name and and an optional fallback, and returns the current computed CSS value for the
7
7
  * resulting CSS Custom Property.
@@ -2,7 +2,7 @@ import warnOnce from '@atlaskit/ds-lib/warn-once';
2
2
  import tokens from './artifacts/token-names';
3
3
  import { TOKEN_NOT_FOUND_CSS_VAR } from './constants';
4
4
  const name = "@atlaskit/tokens";
5
- const version = "1.43.1";
5
+ const version = "1.43.2";
6
6
  /**
7
7
  * Takes a dot-separated token name and an optional fallback, and returns the CSS custom property for the corresponding token.
8
8
  * This should be used to implement design decisions throughout your application.
@@ -1,7 +1,7 @@
1
1
  import warnOnce from '@atlaskit/ds-lib/warn-once';
2
2
  import tokens from './artifacts/token-names';
3
3
  var name = "@atlaskit/tokens";
4
- var version = "1.43.1";
4
+ var version = "1.43.2";
5
5
  /**
6
6
  * Takes a dot-separated token name and and an optional fallback, and returns the current computed CSS value for the
7
7
  * resulting CSS Custom Property.
@@ -2,7 +2,7 @@ import warnOnce from '@atlaskit/ds-lib/warn-once';
2
2
  import tokens from './artifacts/token-names';
3
3
  import { TOKEN_NOT_FOUND_CSS_VAR } from './constants';
4
4
  var name = "@atlaskit/tokens";
5
- var version = "1.43.1";
5
+ var version = "1.43.2";
6
6
  /**
7
7
  * Takes a dot-separated token name and an optional fallback, and returns the CSS custom property for the corresponding token.
8
8
  * This should be used to implement design decisions throughout your application.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/tokens",
3
- "version": "1.43.1",
3
+ "version": "1.43.2",
4
4
  "description": "Design tokens are the single source of truth to name and store design decisions.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -38,16 +38,17 @@
38
38
  "@babel/runtime": "^7.0.0",
39
39
  "@babel/traverse": "^7.23.2",
40
40
  "@babel/types": "^7.20.0",
41
- "bind-event-listener": "^2.1.1"
41
+ "bind-event-listener": "^3.0.0"
42
42
  },
43
43
  "peerDependencies": {
44
44
  "react": "^16.8.0"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@af/accessibility-testing": "*",
48
- "@atlaskit/checkbox": "*",
49
- "@atlaskit/radio": "*",
50
- "@atlaskit/tooltip": "*",
48
+ "@atlaskit/calendar": "^14.2.0",
49
+ "@atlaskit/checkbox": "^13.1.0",
50
+ "@atlaskit/radio": "^6.1.3",
51
+ "@atlaskit/tooltip": "^18.2.1",
51
52
  "@atlaskit/visual-regression": "*",
52
53
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
53
54
  "@atlassian/codegen": "^0.1.0",
@@ -1,489 +0,0 @@
1
- import { Parser } from 'jscodeshift';
2
-
3
- import __noop from '@atlaskit/ds-lib/noop';
4
-
5
- import transformer from '../transform';
6
-
7
- /* eslint-disable no-console */
8
- export async function withMockedConsoleWarn(fn: any) {
9
- const originalWarn = console.warn;
10
- const warn = jest.fn();
11
- console.warn = warn;
12
-
13
- await fn(warn);
14
-
15
- console.warn = originalWarn;
16
- }
17
- /* eslint-enable no-console */
18
-
19
- async function applyTransform(
20
- transform: any,
21
- input: string,
22
- options: {
23
- parser: string | Parser;
24
- } = {
25
- parser: 'babel',
26
- },
27
- ) {
28
- // Handle ES6 modules using default export for the transform
29
- const transformer = transform.default ? transform.default : transform;
30
- const output = await transformer(
31
- { source: input },
32
- {
33
- jscodeshift: __noop,
34
- stats: __noop,
35
- },
36
- options || {},
37
- );
38
-
39
- return (output || '').trim();
40
- }
41
-
42
- describe('PostCSS Transform', () => {
43
- it(`standard CSS`, async () => {
44
- const input = `
45
- .normal {
46
- color: #eeeeee;
47
- }
48
- .normal-selected {
49
- color: #eeeeee;
50
- }
51
- `;
52
- const result = await applyTransform(transformer, input);
53
- expect(result).toMatchInlineSnapshot(`
54
- ".normal {
55
- color: var(--ds-surface-sunken, #eeeeee);
56
- }
57
- .normal-selected {
58
- color: var(--ds-surface-sunken, #eeeeee);
59
- }"
60
- `);
61
- });
62
-
63
- it(`standard LESS`, async () => {
64
- const input = `
65
- .container {
66
- .mixin-1();
67
- .mixin-2;
68
- .mixin-3 (@width: 100px) {
69
- color: #eeeeee;
70
- }
71
- }
72
- `;
73
- const result = await applyTransform(transformer, input);
74
- expect(result).toMatchInlineSnapshot(`
75
- ".container {
76
- .mixin-1();
77
- .mixin-2;
78
- .mixin-3 (@width: 100px) {
79
- color: var(--ds-surface-sunken, #eeeeee);
80
- }
81
- }"
82
- `);
83
- });
84
-
85
- it(`box-shadows`, async () => {
86
- const input = `.container { box-shadow: 0px 1px 5px 0px var(--adg3-color-N40); }`;
87
- const result = await applyTransform(transformer, input);
88
- expect(result).toMatchInlineSnapshot(
89
- `".container { box-shadow: var(MISSING_TOKEN, 0px 1px 5px 0px var(--adg3-color-N40)); }"`,
90
- );
91
- });
92
-
93
- it(`should not transform value with 'url()'`, async () => {
94
- const input = `.user-time-icon { background: url(@spriteUrl) no-repeat; }`;
95
- const result = await applyTransform(transformer, input);
96
- expect(result).toMatchInlineSnapshot(
97
- `".user-time-icon { background: url(@spriteUrl) no-repeat; }"`,
98
- );
99
- });
100
-
101
- it(`should not transform value with less functions`, async () => {
102
- await withMockedConsoleWarn(async (warn: any) => {
103
- const input = `.user-time-icon { background: lighten(@spriteUrl) no-repeat; }`;
104
- const result = await applyTransform(transformer, input);
105
- expect(result).toMatchInlineSnapshot(
106
- `".user-time-icon { background: lighten(@spriteUrl) no-repeat; }"`,
107
- );
108
- expect(warn).toHaveBeenCalledTimes(1);
109
- });
110
- });
111
-
112
- it(`should not transform box-shadow: none`, async () => {
113
- const input = `.container { box-shadow: none; }`;
114
- const result = await applyTransform(transformer, input);
115
- expect(result).toMatchInlineSnapshot(`".container { box-shadow: none; }"`);
116
- });
117
-
118
- it(`should not transform border radius`, async () => {
119
- const input = `.container { border-radius: 3px; }`;
120
- const result = await applyTransform(transformer, input);
121
- expect(result).toMatchInlineSnapshot(
122
- `".container { border-radius: 3px; }"`,
123
- );
124
- });
125
-
126
- it(`chained selectors`, async () => {
127
- const input = `
128
- h1,h2,h3 {
129
- color: #eeeeee;
130
- }
131
- `;
132
- const result = await applyTransform(transformer, input);
133
- expect(result).toMatchInlineSnapshot(`
134
- "h1,h2,h3 {
135
- color: var(--ds-surface-sunken, #eeeeee);
136
- }"
137
- `);
138
- });
139
-
140
- it(`does not transform CSS var declarations`, async () => {
141
- const input = `--adg3-color-R50: #ffebe6;`;
142
- const result = await applyTransform(transformer, input);
143
- expect(result).toMatchInlineSnapshot(`"--adg3-color-R50: #ffebe6;"`);
144
- });
145
-
146
- it(`standard CSS with ADG3 variables`, async () => {
147
- const input = `
148
- .normal {
149
- color: var(--adg3-color-N800);
150
- color: var(--adg3-color-T400);
151
- color: var(--adg3-color-B400);
152
- }
153
- `;
154
- const result = await applyTransform(transformer, input);
155
- expect(result).toMatchInlineSnapshot(`
156
- ".normal {
157
- color: var(--ds-text, var(--adg3-color-N800));
158
- color: var(--ds-text-accent-teal, var(--adg3-color-T400));
159
- color: var(--ds-text-brand, var(--adg3-color-B400));
160
- }"
161
- `);
162
- });
163
-
164
- it(`deeply nested CSS`, async () => {
165
- const input = `
166
- .normal {
167
- color: #eeeeee;
168
- .deep {
169
- color: #eeeeee;
170
- .deeper {
171
- color: #eeeeee;
172
- }
173
- }
174
- }
175
- `;
176
- const result = await applyTransform(transformer, input);
177
- expect(result).toMatchInlineSnapshot(`
178
- ".normal {
179
- color: var(--ds-surface-sunken, #eeeeee);
180
- .deep {
181
- color: var(--ds-surface-sunken, #eeeeee);
182
- .deeper {
183
- color: var(--ds-surface-sunken, #eeeeee);
184
- }
185
- }
186
- }"
187
- `);
188
- });
189
-
190
- it(`interaction states CSS`, async () => {
191
- const input = `
192
- .normal {
193
- color: #eeeeee;
194
- }
195
- .normal:hover {
196
- color: #eeeeee;
197
- }
198
- .normal:active {
199
- color: #eeeeee;
200
- }
201
- `;
202
- const result = await applyTransform(transformer, input);
203
- expect(result).toMatchInlineSnapshot(`
204
- ".normal {
205
- color: var(--ds-surface-sunken, #eeeeee);
206
- }
207
- .normal:hover {
208
- color: var(--ds-surface-sunken, #eeeeee);
209
- }
210
- .normal:active {
211
- color: var(--ds-surface-sunken, #eeeeee);
212
- }"
213
- `);
214
- });
215
-
216
- it(`nested interaction states CSS`, async () => {
217
- const input = `
218
- .normal {
219
- color: #eeeeee;
220
- &:hover {
221
- color: #eeeeee;
222
- }
223
- &:active {
224
- color: #eeeeee;
225
- }
226
- }
227
- `;
228
- const result = await applyTransform(transformer, input);
229
- expect(result).toMatchInlineSnapshot(`
230
- ".normal {
231
- color: var(--ds-surface-sunken, #eeeeee);
232
- &:hover {
233
- color: var(--ds-surface-sunken, #eeeeee);
234
- }
235
- &:active {
236
- color: var(--ds-surface-sunken, #eeeeee);
237
- }
238
- }"
239
- `);
240
- });
241
-
242
- it(`nested CSS`, async () => {
243
- const input = `
244
- .normal {
245
- color: #000000;
246
- width: var(--gutter-size);
247
- .nested {
248
- color: #000000;
249
- }
250
- }
251
- `;
252
- const result = await applyTransform(transformer, input);
253
- expect(result).toMatchInlineSnapshot(`
254
- ".normal {
255
- color: var(--ds-text, #000000);
256
- width: var(--gutter-size);
257
- .nested {
258
- color: var(--ds-text, #000000);
259
- }
260
- }"
261
- `);
262
- });
263
-
264
- it(`avoids already converted colors`, async () => {
265
- const input = `
266
- .normal {
267
- color: var(--ds-text, #000000);
268
- }
269
- `;
270
- const result = await applyTransform(transformer, input);
271
- expect(result).toMatchInlineSnapshot(`
272
- ".normal {
273
- color: var(--ds-text, #000000);
274
- }"
275
- `);
276
- });
277
-
278
- it(`aliased adg-3 colors`, async () => {
279
- const input = `
280
- .container {
281
- box-shadow: 0px 1px 5px 0px var(--adg3-color-N40);
282
- border: 1px solid var(--adg3-color-N40);
283
- }
284
- `;
285
- const result = await applyTransform(transformer, input);
286
- expect(result).toMatchInlineSnapshot(`
287
- ".container {
288
- box-shadow: var(MISSING_TOKEN, 0px 1px 5px 0px var(--adg3-color-N40));
289
- border: 1px solid var(--ds-border, var(--adg3-color-N40));
290
- }"
291
- `);
292
- });
293
-
294
- it(`should transform border properties`, async () => {
295
- const input = `
296
- .normal {
297
- border-top: 1px solid #eee;
298
- border-bottom: 1px solid #eee;
299
- }
300
- `;
301
- const result = await applyTransform(transformer, input);
302
- expect(result).toMatchInlineSnapshot(`
303
- ".normal {
304
- border-top: 1px solid var(--ds-surface-sunken, #eee);
305
- border-bottom: 1px solid var(--ds-surface-sunken, #eee);
306
- }"
307
- `);
308
- });
309
-
310
- it(`named colors`, async () => {
311
- const input = `
312
- .normal {
313
- color: red;
314
- color: crimson;
315
- color: cyan;
316
- color: darkblue;
317
- color: darkcyan;
318
- color: fuchsia;
319
- color: lightgreen;
320
- color: lightskyblue;
321
- background-color: red;
322
- background-color: crimson;
323
- background-color: cyan;
324
- background-color: darkblue;
325
- background-color: darkcyan;
326
- background-color: fuchsia;
327
- background-color: lightgreen;
328
- background-color: lightskyblue;
329
- border-color: red;
330
- border-color: crimson;
331
- border-color: cyan;
332
- border-color: darkblue;
333
- border-color: darkcyan;
334
- border-color: fuchsia;
335
- border-color: lightgreen;
336
- border-color: lightskyblue;
337
- }
338
- `;
339
- const result = await applyTransform(transformer, input);
340
- expect(result).toMatchInlineSnapshot(`
341
- ".normal {
342
- color: var(--ds-text-accent-orange, red);
343
- color: var(--ds-text-danger, crimson);
344
- color: var(--ds-text-accent-teal, cyan);
345
- color: var(--ds-text-accent-blue-bolder, darkblue);
346
- color: var(--ds-text-accent-teal-bolder, darkcyan);
347
- color: var(--ds-text-subtle, fuchsia);
348
- color: var(--ds-text-accent-green, lightgreen);
349
- color: var(--ds-text-accent-blue, lightskyblue);
350
- background-color: var(--ds-background-danger, red);
351
- background-color: var(--ds-background-danger, crimson);
352
- background-color: var(--ds-background-accent-teal-subtle, cyan);
353
- background-color: var(--ds-background-accent-blue-bolder, darkblue);
354
- background-color: var(--ds-background-accent-teal-bolder, darkcyan);
355
- background-color: var(--ds-background-accent-magenta-subtle, fuchsia);
356
- background-color: var(--ds-background-accent-green-subtle, lightgreen);
357
- background-color: var(--ds-background-accent-blue-subtle, lightskyblue);
358
- border-color: var(--ds-border-accent-orange, red);
359
- border-color: var(--ds-border-danger, crimson);
360
- border-color: var(--ds-border-accent-teal, cyan);
361
- border-color: var(--ds-border-accent-blue, darkblue);
362
- border-color: var(--ds-border-accent-teal, darkcyan);
363
- border-color: var(--ds-border-accent-magenta, fuchsia);
364
- border-color: var(--ds-border-accent-green, lightgreen);
365
- border-color: var(--ds-border-accent-blue, lightskyblue);
366
- }"
367
- `);
368
- });
369
-
370
- it(`raw colors`, async () => {
371
- const input = `
372
- .normal {
373
- color: #ffffff;
374
- color: #fff;
375
- color: #000000;
376
- color: #f0f0f0;
377
- color: #eeeeee;
378
- color: #cccccc;
379
- color: #292929;
380
- color: #003366;
381
- background-color: #ffffff;
382
- background-color: #fff;
383
- background-color: #000000;
384
- background-color: #f0f0f0;
385
- background-color: #eeeeee;
386
- background-color: #cccccc;
387
- background-color: #292929;
388
- background-color: #003366;
389
- border-color: #ffffff;
390
- border-color: #fff;
391
- border-color: #000000;
392
- border-color: #f0f0f0;
393
- border-color: #eeeeee;
394
- border-color: #cccccc;
395
- border-color: #292929;
396
- border-color: #003366;
397
- }
398
- `;
399
- const result = await applyTransform(transformer, input);
400
- expect(result).toMatchInlineSnapshot(`
401
- ".normal {
402
- color: var(--ds-surface, #ffffff);
403
- color: var(--ds-surface, #fff);
404
- color: var(--ds-text, #000000);
405
- color: var(--ds-surface, #f0f0f0);
406
- color: var(--ds-surface-sunken, #eeeeee);
407
- color: var(--ds-text-accent-gray, #cccccc);
408
- color: var(--ds-text, #292929);
409
- color: var(--ds-text, #003366);
410
- background-color: var(--ds-surface, #ffffff);
411
- background-color: var(--ds-surface, #fff);
412
- background-color: var(--ds-background-input, #000000);
413
- background-color: var(--ds-surface, #f0f0f0);
414
- background-color: var(--ds-surface-sunken, #eeeeee);
415
- background-color: var(--ds-background-accent-gray-subtle, #cccccc);
416
- background-color: var(--ds-background-input, #292929);
417
- background-color: var(--ds-background-input, #003366);
418
- border-color: var(--ds-surface, #ffffff);
419
- border-color: var(--ds-surface, #fff);
420
- border-color: var(--ds-border, #000000);
421
- border-color: var(--ds-surface, #f0f0f0);
422
- border-color: var(--ds-surface-sunken, #eeeeee);
423
- border-color: var(--ds-border-accent-gray, #cccccc);
424
- border-color: var(--ds-border, #292929);
425
- border-color: var(--ds-border, #003366);
426
- }"
427
- `);
428
- });
429
-
430
- it(`omits less variable use`, async () => {
431
- const input = `.normal { border-bottom: @grid/2 solid @gh-background-color-column; }`;
432
- const result = await applyTransform(transformer, input);
433
- expect(result).toMatchInlineSnapshot(
434
- `".normal { border-bottom: @grid/2 solid @gh-background-color-column; }"`,
435
- );
436
- });
437
-
438
- it(`gradients`, async () => {
439
- const input = `
440
- .container {
441
- background: linear-gradient(red, blue);
442
- background: radial-gradient(red, blue);
443
- background: conic-gradient(red, orange, yellow, green, blue);
444
- }
445
- `;
446
- const result = await applyTransform(transformer, input);
447
- expect(result).toMatchInlineSnapshot(`
448
- ".container {
449
- background: linear-gradient(var(--ds-background-danger, red), var(--ds-background-accent-blue-subtle, blue));
450
- background: radial-gradient(var(--ds-background-danger, red), var(--ds-background-accent-blue-subtle, blue));
451
- background: conic-gradient(var(--ds-background-danger, red), var(--ds-background-input, orange), var(--ds-background-accent-yellow-subtle, yellow), var(--ds-background-accent-green-subtle, green), var(--ds-background-accent-blue-subtle, blue));
452
- }"
453
- `);
454
- });
455
-
456
- it(`border color`, async () => {
457
- const input = `
458
- .some-div {
459
- border-color: red yellow green hsla(60, 90%, 50%, .8);
460
- }
461
- `;
462
- const result = await applyTransform(transformer, input);
463
- expect(result).toMatchInlineSnapshot(`
464
- ".some-div {
465
- border-color: var(--ds-border-accent-orange, red) var(--ds-border-accent-yellow, yellow) var(--ds-border-accent-green, green) var(--ds-border, hsla(60, 90%, 50%, .8));
466
- }"
467
- `);
468
- });
469
-
470
- it(`other color properties`, async () => {
471
- const input = `
472
- .properties {
473
- accent-color: darkred;
474
- caret-color: red;
475
- text-stroke: 4px navy;
476
- scrollbar-color: rebeccapurple green;
477
- }
478
- `;
479
- const result = await applyTransform(transformer, input);
480
- expect(result).toMatchInlineSnapshot(`
481
- ".properties {
482
- accent-color: var(--ds-background-accent-orange-bolder-hovered, darkred);
483
- caret-color: var(--ds-background-accent-orange-subtler-hovered, red);
484
- text-stroke: 4px var(--ds-text-accent-blue-bolder, navy);
485
- scrollbar-color: var(--ds-text-accent-purple, rebeccapurple) var(--ds-text-accent-green, green);
486
- }"
487
- `);
488
- });
489
- });