@atlaskit/tokens 1.49.1 → 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 +1584 -1594
- 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/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-minor3.js +3 -3
- 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/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-minor3.js +3 -3
- 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/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-minor3.js +3 -3
- 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/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-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/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-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
|
@@ -1,13 +1,9 @@
|
|
|
1
1
|
import type { FileInfo } from 'jscodeshift';
|
|
2
|
-
import postcss, { Plugin } from 'postcss';
|
|
2
|
+
import postcss, { type Plugin } from 'postcss';
|
|
3
3
|
// @ts-ignore
|
|
4
4
|
import lessSyntax from 'postcss-less';
|
|
5
5
|
|
|
6
|
-
import {
|
|
7
|
-
isColorRelatedProperty,
|
|
8
|
-
isCssDeclaration,
|
|
9
|
-
splitCssValue,
|
|
10
|
-
} from './lib/declaration';
|
|
6
|
+
import { isColorRelatedProperty, isCssDeclaration, splitCssValue } from './lib/declaration';
|
|
11
7
|
import { getBaseDeclarationMeta } from './lib/meta';
|
|
12
8
|
import findToken from './lib/tokens';
|
|
13
9
|
import parseValue from './lib/value';
|
|
@@ -17,83 +13,83 @@ const POSTCSS_OPTIONS = { syntax: lessSyntax, from: undefined };
|
|
|
17
13
|
// https://github.com/postcss/postcss/blob/main/docs/writing-a-plugin.md
|
|
18
14
|
// https://astexplorer.net/#/2uBU1BLuJ1
|
|
19
15
|
const plugin = (): Plugin => {
|
|
20
|
-
|
|
16
|
+
const processed = Symbol('processed');
|
|
21
17
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
18
|
+
return {
|
|
19
|
+
postcssPlugin: 'UsingTokens',
|
|
20
|
+
AtRule(atRule) {
|
|
21
|
+
// @ts-expect-error
|
|
22
|
+
if (atRule[processed]) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
29
25
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
26
|
+
// @ts-expect-error: The 'variable' property does not exist on 'AtRule' according to the TypeScript definitions.
|
|
27
|
+
// However, the 'postcss-less' library adds a 'variable' property to 'AtRule' when parsing LESS variables.
|
|
28
|
+
// This property indicates whether the 'AtRule' is a LESS variable.
|
|
29
|
+
if (atRule.variable) {
|
|
30
|
+
// TODO https://hello.atlassian.net/browse/DCA11Y-637
|
|
31
|
+
}
|
|
36
32
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
33
|
+
// @ts-expect-error
|
|
34
|
+
atRule[processed] = true;
|
|
35
|
+
},
|
|
36
|
+
Declaration: (decl) => {
|
|
37
|
+
// @ts-expect-error
|
|
38
|
+
if (decl[processed]) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (decl.value === 'none') {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
48
44
|
|
|
49
|
-
|
|
45
|
+
const baseMeta = getBaseDeclarationMeta(decl);
|
|
50
46
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
47
|
+
if (isCssDeclaration(decl.prop)) {
|
|
48
|
+
// TODO https://hello.atlassian.net/browse/DCA11Y-637
|
|
49
|
+
}
|
|
54
50
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
51
|
+
if (isColorRelatedProperty(decl.prop)) {
|
|
52
|
+
const values = splitCssValue(decl.value);
|
|
53
|
+
if (!values) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
60
56
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
57
|
+
switch (decl.prop) {
|
|
58
|
+
case 'box-shadow':
|
|
59
|
+
const meta = values.reduce((acc: string[], curr: string) => {
|
|
60
|
+
const parsedValue = parseValue(curr);
|
|
61
|
+
if (!parsedValue) {
|
|
62
|
+
return acc;
|
|
63
|
+
}
|
|
64
|
+
return [...acc, ...parsedValue.getMeta()];
|
|
65
|
+
}, baseMeta);
|
|
70
66
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
67
|
+
const token = findToken(meta);
|
|
68
|
+
decl.value = `var(${token}, ${decl.value})`;
|
|
69
|
+
break;
|
|
70
|
+
default:
|
|
71
|
+
const replacedValues = values.map((value) => {
|
|
72
|
+
const parsedValue = parseValue(value);
|
|
73
|
+
if (!parsedValue) {
|
|
74
|
+
return value;
|
|
75
|
+
}
|
|
80
76
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
77
|
+
return parsedValue.getReplacement(baseMeta);
|
|
78
|
+
});
|
|
79
|
+
decl.value = replacedValues.join(' ');
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
87
83
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
84
|
+
// @ts-expect-error
|
|
85
|
+
decl[processed] = true;
|
|
86
|
+
},
|
|
87
|
+
};
|
|
92
88
|
};
|
|
93
89
|
|
|
94
90
|
export default async function transformer(file: FileInfo | string) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
91
|
+
const processor = postcss([plugin()]);
|
|
92
|
+
const src = typeof file === 'string' ? file : file.source;
|
|
93
|
+
const { css } = await processor.process(src, POSTCSS_OPTIONS);
|
|
94
|
+
return css;
|
|
99
95
|
}
|
|
@@ -3,9 +3,9 @@ import removeFallbacksColor from './remove-fallbacks-color/transform';
|
|
|
3
3
|
import themeToDesignTokens from './theme-to-design-tokens/transform';
|
|
4
4
|
|
|
5
5
|
export default {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
presets: {
|
|
7
|
+
'theme-to-design-tokens': themeToDesignTokens,
|
|
8
|
+
'css-to-design-tokens': cssToDesignTokens,
|
|
9
|
+
'remove-fallbacks-color': removeFallbacksColor,
|
|
10
|
+
},
|
|
11
11
|
};
|
|
@@ -2,25 +2,23 @@ import { hasImportDeclaration } from '@hypermod/utils';
|
|
|
2
2
|
import type { API, FileInfo } from 'jscodeshift';
|
|
3
3
|
|
|
4
4
|
export default async function transformer(file: FileInfo, api: API) {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
const j = api.jscodeshift;
|
|
6
|
+
const source = j(file.source);
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
if (!hasImportDeclaration(j, source, '@atlaskit/tokens')) {
|
|
9
|
+
return file.source;
|
|
10
|
+
}
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
});
|
|
12
|
+
source.find(j.CallExpression, { callee: { name: 'token' } }).forEach((path) => {
|
|
13
|
+
if (
|
|
14
|
+
path.node.arguments.length > 1 &&
|
|
15
|
+
j.StringLiteral.check(path.node.arguments[0]) &&
|
|
16
|
+
/^color\.|elevation/.test(path.node.arguments[0].value)
|
|
17
|
+
) {
|
|
18
|
+
// Remove the second argument
|
|
19
|
+
path.node.arguments.splice(1, 1);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
24
22
|
|
|
25
|
-
|
|
23
|
+
return source.toSource();
|
|
26
24
|
}
|