@atlaskit/tokens 1.49.0 → 1.50.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 +1589 -1591
- package/README.md +14 -8
- package/codemods/css-to-design-tokens/lib/colors.tsx +47 -49
- package/codemods/css-to-design-tokens/lib/declaration.tsx +26 -26
- package/codemods/css-to-design-tokens/lib/legacy-colors.tsx +326 -326
- package/codemods/css-to-design-tokens/lib/meta.tsx +116 -122
- package/codemods/css-to-design-tokens/lib/tokens.tsx +28 -35
- package/codemods/css-to-design-tokens/lib/value.tsx +70 -72
- package/codemods/css-to-design-tokens/transform.tsx +68 -72
- package/codemods/hypermod.config.tsx +5 -5
- package/codemods/remove-fallbacks-color/transform.tsx +16 -18
- package/codemods/theme-to-design-tokens/transform.tsx +505 -588
- package/codemods/theme-to-design-tokens/utils/ast-meta.tsx +139 -147
- package/codemods/theme-to-design-tokens/utils/ast.tsx +23 -34
- package/codemods/theme-to-design-tokens/utils/color.tsx +25 -26
- package/codemods/theme-to-design-tokens/utils/css-utils.tsx +27 -30
- package/codemods/theme-to-design-tokens/utils/fuzzy-search.tsx +272 -290
- package/codemods/theme-to-design-tokens/utils/legacy-colors.tsx +224 -224
- package/codemods/theme-to-design-tokens/utils/named-colors.tsx +148 -148
- package/codemods/theme-to-design-tokens/utils/string-utils.tsx +10 -16
- package/codemods/utils/tokens.tsx +371 -371
- package/dist/cjs/artifacts/atlassian-dark-token-value-for-contrast-check.js +1 -1
- package/dist/cjs/artifacts/atlassian-light-token-value-for-contrast-check.js +1 -1
- package/dist/cjs/artifacts/generated-pairs.js +1 -1
- package/dist/cjs/artifacts/palettes-raw/typography-palette.js +45 -30
- package/dist/cjs/artifacts/theme-import-map.js +1 -1
- package/dist/cjs/artifacts/themes/atlassian-typography-minor3.js +2 -2
- package/dist/cjs/artifacts/token-default-values.js +1 -1
- package/dist/cjs/artifacts/token-names.js +1 -1
- package/dist/cjs/artifacts/tokens-raw/atlassian-typography-adg3.js +20 -20
- package/dist/cjs/artifacts/tokens-raw/atlassian-typography-minor3.js +13 -13
- package/dist/es2019/artifacts/atlassian-dark-token-value-for-contrast-check.js +1 -1
- package/dist/es2019/artifacts/atlassian-light-token-value-for-contrast-check.js +1 -1
- package/dist/es2019/artifacts/generated-pairs.js +1 -1
- package/dist/es2019/artifacts/palettes-raw/typography-palette.js +45 -30
- package/dist/es2019/artifacts/theme-import-map.js +1 -1
- package/dist/es2019/artifacts/themes/atlassian-typography-minor3.js +2 -2
- package/dist/es2019/artifacts/token-default-values.js +1 -1
- package/dist/es2019/artifacts/token-names.js +1 -1
- package/dist/es2019/artifacts/tokens-raw/atlassian-typography-adg3.js +20 -20
- package/dist/es2019/artifacts/tokens-raw/atlassian-typography-minor3.js +13 -13
- package/dist/esm/artifacts/atlassian-dark-token-value-for-contrast-check.js +1 -1
- package/dist/esm/artifacts/atlassian-light-token-value-for-contrast-check.js +1 -1
- package/dist/esm/artifacts/generated-pairs.js +1 -1
- package/dist/esm/artifacts/palettes-raw/typography-palette.js +45 -30
- package/dist/esm/artifacts/theme-import-map.js +1 -1
- package/dist/esm/artifacts/themes/atlassian-typography-minor3.js +2 -2
- package/dist/esm/artifacts/token-default-values.js +1 -1
- package/dist/esm/artifacts/token-names.js +1 -1
- package/dist/esm/artifacts/tokens-raw/atlassian-typography-adg3.js +20 -20
- package/dist/esm/artifacts/tokens-raw/atlassian-typography-minor3.js +13 -13
- package/dist/types/artifacts/atlassian-dark-token-value-for-contrast-check.d.ts +1 -1
- package/dist/types/artifacts/atlassian-light-token-value-for-contrast-check.d.ts +1 -1
- package/dist/types/artifacts/generated-pairs.d.ts +1 -1
- package/dist/types/artifacts/palettes-raw/typography-palette.d.ts +1 -1
- package/dist/types/artifacts/theme-import-map.d.ts +2 -2
- package/dist/types/artifacts/themes/atlassian-typography-minor3.d.ts +2 -2
- package/dist/types/artifacts/token-default-values.d.ts +1 -1
- package/dist/types/artifacts/token-names.d.ts +1 -1
- package/dist/types/artifacts/tokens-raw/atlassian-typography-adg3.d.ts +1 -1
- package/dist/types/artifacts/tokens-raw/atlassian-typography-minor3.d.ts +1 -1
- package/dist/types/artifacts/types-internal.d.ts +1 -1
- package/dist/types/artifacts/types.d.ts +1 -1
- package/dist/types/babel-plugin/plugin.d.ts +1 -1
- package/dist/types/custom-theme.d.ts +2 -2
- package/dist/types/enable-global-theme.d.ts +2 -2
- package/dist/types/entry-points/css-type-schema.codegen.d.ts +1 -1
- package/dist/types/entry-points/token-ids.d.ts +1 -1
- package/dist/types/get-global-theme.d.ts +1 -1
- package/dist/types/get-ssr-auto-script.d.ts +1 -1
- package/dist/types/get-theme-html-attrs.d.ts +1 -1
- package/dist/types/get-theme-styles.d.ts +1 -1
- package/dist/types/get-token.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/load-custom-theme-styles.d.ts +1 -1
- package/dist/types/set-global-theme.d.ts +2 -2
- package/dist/types/theme-state-transformer.d.ts +1 -1
- package/dist/types/utils/color-detection.d.ts +1 -1
- package/dist/types/utils/color-mode-listeners.d.ts +1 -1
- package/dist/types/utils/configure-page.d.ts +1 -1
- package/dist/types/utils/contrast-mode-listeners.d.ts +1 -1
- package/dist/types/utils/custom-theme-loading-utils.d.ts +1 -1
- package/dist/types/utils/custom-theme-token-contrast-check.d.ts +1 -1
- package/dist/types/utils/generate-custom-color-ramp.d.ts +2 -2
- package/dist/types/utils/get-increased-contrast-theme.d.ts +1 -1
- package/dist/types/utils/get-theme-preferences.d.ts +1 -1
- package/dist/types/utils/theme-loading.d.ts +1 -1
- package/dist/types-ts4.5/artifacts/atlassian-dark-token-value-for-contrast-check.d.ts +1 -1
- package/dist/types-ts4.5/artifacts/atlassian-light-token-value-for-contrast-check.d.ts +1 -1
- package/dist/types-ts4.5/artifacts/generated-pairs.d.ts +1 -1
- package/dist/types-ts4.5/artifacts/palettes-raw/typography-palette.d.ts +1 -1
- package/dist/types-ts4.5/artifacts/theme-import-map.d.ts +2 -2
- package/dist/types-ts4.5/artifacts/themes/atlassian-typography-minor3.d.ts +2 -2
- package/dist/types-ts4.5/artifacts/token-default-values.d.ts +1 -1
- package/dist/types-ts4.5/artifacts/token-names.d.ts +1 -1
- package/dist/types-ts4.5/artifacts/tokens-raw/atlassian-typography-adg3.d.ts +1 -1
- package/dist/types-ts4.5/artifacts/tokens-raw/atlassian-typography-minor3.d.ts +1 -1
- package/dist/types-ts4.5/artifacts/types-internal.d.ts +1 -1
- package/dist/types-ts4.5/artifacts/types.d.ts +1 -1
- package/dist/types-ts4.5/babel-plugin/plugin.d.ts +1 -1
- package/dist/types-ts4.5/custom-theme.d.ts +2 -2
- package/dist/types-ts4.5/enable-global-theme.d.ts +2 -2
- package/dist/types-ts4.5/entry-points/css-type-schema.codegen.d.ts +1 -1
- package/dist/types-ts4.5/entry-points/token-ids.d.ts +1 -1
- package/dist/types-ts4.5/get-global-theme.d.ts +1 -1
- package/dist/types-ts4.5/get-ssr-auto-script.d.ts +1 -1
- package/dist/types-ts4.5/get-theme-html-attrs.d.ts +1 -1
- package/dist/types-ts4.5/get-theme-styles.d.ts +1 -1
- package/dist/types-ts4.5/get-token.d.ts +1 -1
- package/dist/types-ts4.5/index.d.ts +1 -1
- package/dist/types-ts4.5/load-custom-theme-styles.d.ts +1 -1
- package/dist/types-ts4.5/set-global-theme.d.ts +2 -2
- package/dist/types-ts4.5/theme-state-transformer.d.ts +1 -1
- package/dist/types-ts4.5/utils/color-detection.d.ts +1 -1
- package/dist/types-ts4.5/utils/color-mode-listeners.d.ts +1 -1
- package/dist/types-ts4.5/utils/configure-page.d.ts +1 -1
- package/dist/types-ts4.5/utils/contrast-mode-listeners.d.ts +1 -1
- package/dist/types-ts4.5/utils/custom-theme-loading-utils.d.ts +1 -1
- package/dist/types-ts4.5/utils/custom-theme-token-contrast-check.d.ts +1 -1
- package/dist/types-ts4.5/utils/generate-custom-color-ramp.d.ts +2 -2
- package/dist/types-ts4.5/utils/get-increased-contrast-theme.d.ts +1 -1
- package/dist/types-ts4.5/utils/get-theme-preferences.d.ts +1 -1
- package/dist/types-ts4.5/utils/theme-loading.d.ts +1 -1
- package/package.json +3 -5
- package/report.api.md +2071 -2090
package/README.md
CHANGED
|
@@ -16,12 +16,14 @@ yarn add @atlaskit/tokens
|
|
|
16
16
|
|
|
17
17
|
A babel plugin to optimise performance and support fallbacks for Design System tokens.
|
|
18
18
|
|
|
19
|
-
It replaces any calls to the `@atlaskit/tokens` token() function with the CSS value the function
|
|
20
|
-
variations with fallbacks).
|
|
19
|
+
It replaces any calls to the `@atlaskit/tokens` token() function with the CSS value the function
|
|
20
|
+
would return (i.e. var(--token-name) or variations with fallbacks).
|
|
21
21
|
|
|
22
|
-
If there’s no fallback, the plugin (optionally) finds the token’s value from the default Atlassian
|
|
22
|
+
If there’s no fallback, the plugin (optionally) finds the token’s value from the default Atlassian
|
|
23
|
+
theme, and sets it as the fallback.
|
|
23
24
|
|
|
24
|
-
If there is a fallback defined in code, it’s inserted into the style (expressions are inserted using
|
|
25
|
+
If there is a fallback defined in code, it’s inserted into the style (expressions are inserted using
|
|
26
|
+
template strings).
|
|
25
27
|
|
|
26
28
|
## Usage
|
|
27
29
|
|
|
@@ -29,13 +31,17 @@ Add the plugin to your babel configuration:
|
|
|
29
31
|
|
|
30
32
|
```
|
|
31
33
|
{
|
|
32
|
-
"plugins": [
|
|
34
|
+
"plugins": [
|
|
35
|
+
["@atlaskit/tokens/babel-plugin", { "shouldUseAutoFallback": true }]
|
|
36
|
+
]
|
|
33
37
|
}
|
|
34
38
|
```
|
|
35
39
|
|
|
36
40
|
### Options
|
|
37
41
|
|
|
38
|
-
Currently the plugin supports one option, `shouldUseAutoFallback`. When enabled, the plugin will
|
|
39
|
-
Atlassian theme (currently `atlassian-light`) and use it as
|
|
42
|
+
Currently the plugin supports one option, `shouldUseAutoFallback`. When enabled, the plugin will
|
|
43
|
+
fetch the token's value in the default Atlassian theme (currently `atlassian-light`) and use it as
|
|
44
|
+
the fallback value.
|
|
40
45
|
|
|
41
|
-
This is useful for cases where tokens are in use, but token definitions aren't
|
|
46
|
+
This is useful for cases where tokens are in use, but token definitions aren't guaranteed to be
|
|
47
|
+
present in the top-level page CSS.
|
|
@@ -3,69 +3,67 @@ import { knownNamedColors, knownVariables } from './legacy-colors';
|
|
|
3
3
|
const NAMED_COLORS = Object.keys(knownNamedColors);
|
|
4
4
|
const GRADIENT_TYPES = ['linear', 'radial', 'conic'] as const;
|
|
5
5
|
const LESS_COLOR_FUNCTIONS = [
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
6
|
+
'lighten',
|
|
7
|
+
'darken',
|
|
8
|
+
'saturate',
|
|
9
|
+
'desaturate',
|
|
10
|
+
'fadein',
|
|
11
|
+
'fadeout',
|
|
12
|
+
'fade',
|
|
13
|
+
'spin',
|
|
14
|
+
'mix',
|
|
15
|
+
'greyscale',
|
|
16
|
+
'contrast',
|
|
17
|
+
'multiply',
|
|
18
|
+
'screen',
|
|
19
|
+
'overlay',
|
|
20
|
+
'softlight',
|
|
21
|
+
'hardlight',
|
|
22
|
+
'difference',
|
|
23
|
+
'exclusion',
|
|
24
|
+
'average',
|
|
25
|
+
'negation',
|
|
26
|
+
'tint',
|
|
27
|
+
'shade',
|
|
28
|
+
'luma',
|
|
29
|
+
'hue',
|
|
30
|
+
'saturation',
|
|
31
|
+
'lightness',
|
|
32
|
+
'alpha',
|
|
33
|
+
'red',
|
|
34
|
+
'green',
|
|
35
|
+
'blue',
|
|
36
36
|
];
|
|
37
37
|
|
|
38
38
|
const REGEXES = {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
39
|
+
// The CSS regular expression matches CSS variable declarations.
|
|
40
|
+
// It looks for the string "var(" followed by any characters except a closing parenthesis, and ending with a closing parenthesis.
|
|
41
|
+
CSS: /var\([^\)]+\)/g,
|
|
42
|
+
// The RAW_COLOR regular expression matches various CSS color formats including hexadecimal, RGB(A), HSL(A), LAB, LCH, and HWB.
|
|
43
|
+
// It allows for optional leading and trailing white spaces.
|
|
44
|
+
// For RGBA and HSLA, it allows any number (including negative numbers and numbers greater than 1) for the alpha channel.
|
|
45
|
+
// For RGB, HSL, LAB, LCH, and HWB, it expects three comma-separated values.
|
|
46
|
+
// It also allows optional white spaces around the commas and the values.
|
|
47
|
+
RAW_COLOR:
|
|
48
|
+
/^\s*(#([0-9a-f]{3}){1,2}|(rgba|hsla)\(\s*\d{1,3}%?\s*(,\s*\d{1,3}%?\s*){2},\s*-?\d*\.?\d+\s*\)|(rgb|hsl)\(\s*\d{1,3}%?\s*(,\s*\d{1,3}%?\s*){2}\)\s*|(lab|lch)\(\s*\d{1,3}%?\s+\d{1,3}%?\s+\d{1,3}%?\s*\)|hwb\(\s*\d{1,3}\s+\d{1,3}%?\s+\d{1,3}%?\s*\))\s*$/i,
|
|
49
49
|
};
|
|
50
50
|
|
|
51
51
|
export function isKnownCssVariable(value: string) {
|
|
52
|
-
|
|
52
|
+
return value in knownVariables;
|
|
53
53
|
}
|
|
54
54
|
export function isRawColor(value: string) {
|
|
55
|
-
|
|
55
|
+
return REGEXES.RAW_COLOR.test(value);
|
|
56
56
|
}
|
|
57
57
|
export function isNamedColor(value: string) {
|
|
58
|
-
|
|
58
|
+
return NAMED_COLORS.includes(value);
|
|
59
59
|
}
|
|
60
60
|
export function isGradient(value: string) {
|
|
61
|
-
|
|
62
|
-
value.startsWith(`${gradient}-gradient(`),
|
|
63
|
-
);
|
|
61
|
+
return GRADIENT_TYPES.some((gradient) => value.startsWith(`${gradient}-gradient(`));
|
|
64
62
|
}
|
|
65
63
|
export function extractBetweenParentheses(value: string) {
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
const match = value.match(/\((.*?)\)/);
|
|
65
|
+
return match ? match[1] : '';
|
|
68
66
|
}
|
|
69
67
|
export function isLessFunction(value: string) {
|
|
70
|
-
|
|
68
|
+
return LESS_COLOR_FUNCTIONS.some((func) => value.startsWith(`${func}(`));
|
|
71
69
|
}
|
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
const COLOR_PROPERTIES = [
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
2
|
+
'color',
|
|
3
|
+
'background',
|
|
4
|
+
'background-color',
|
|
5
|
+
'box-shadow',
|
|
6
|
+
'border',
|
|
7
|
+
'border-left',
|
|
8
|
+
'border-right',
|
|
9
|
+
'border-top',
|
|
10
|
+
'border-bottom',
|
|
11
|
+
'border-color',
|
|
12
|
+
'border-left-color',
|
|
13
|
+
'border-right-color',
|
|
14
|
+
'border-top-color',
|
|
15
|
+
'border-bottom-color',
|
|
16
|
+
'outline',
|
|
17
|
+
'outline-color',
|
|
18
|
+
'accent-color',
|
|
19
|
+
'caret-color',
|
|
20
|
+
'scrollbar-color',
|
|
21
|
+
'text-stroke',
|
|
22
22
|
] as const;
|
|
23
23
|
|
|
24
24
|
export function isColorRelatedProperty(prop: string) {
|
|
25
|
-
|
|
25
|
+
return COLOR_PROPERTIES.some((property) => property === prop);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
export function isCssDeclaration(prop: string) {
|
|
29
|
-
|
|
29
|
+
return prop.startsWith('--');
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export function extractCssVarName(prop: string) {
|
|
33
|
-
|
|
33
|
+
return prop.substring(prop.indexOf('(') + 1).split(/\,|\)/)[0];
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
export function extractLessVarName(prop: string) {
|
|
37
|
-
|
|
37
|
+
return prop.substring(1);
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
export function splitCssValue(value: string) {
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
const regex = /(?:[^\s()]+|\((?:[^()]+|\([^()]*\))*\))+/g;
|
|
42
|
+
return value.match(regex);
|
|
43
43
|
}
|