@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
|
@@ -3,171 +3,165 @@ import type { Declaration, Node, Rule } from 'postcss';
|
|
|
3
3
|
import { uniqueWordsFromTokens } from '../../utils/tokens';
|
|
4
4
|
|
|
5
5
|
import { extractCssVarName } from './declaration';
|
|
6
|
-
import {
|
|
7
|
-
knownNamedColors,
|
|
8
|
-
knownRawColors,
|
|
9
|
-
knownVariables,
|
|
10
|
-
} from './legacy-colors';
|
|
6
|
+
import { knownNamedColors, knownRawColors, knownVariables } from './legacy-colors';
|
|
11
7
|
|
|
12
8
|
function filterDuplicateFoundations(meta: string[]) {
|
|
13
|
-
|
|
14
|
-
|
|
9
|
+
const foundations = ['text', 'background', 'shadow', 'border'];
|
|
10
|
+
let hasFoundation = false;
|
|
15
11
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
return meta.filter((val) => {
|
|
13
|
+
if (!hasFoundation && foundations.includes(val)) {
|
|
14
|
+
hasFoundation = true;
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
21
17
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
18
|
+
if (hasFoundation && foundations.includes(val)) {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
25
21
|
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
return true;
|
|
23
|
+
});
|
|
28
24
|
}
|
|
29
25
|
|
|
30
26
|
const REPLACEMENTS: Record<string, string> = {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
27
|
+
':': '',
|
|
28
|
+
',': '',
|
|
29
|
+
texts: 'text',
|
|
30
|
+
error: 'danger',
|
|
31
|
+
invalid: 'danger',
|
|
32
|
+
removed: 'danger',
|
|
33
|
+
removal: 'danger',
|
|
34
|
+
remove: 'danger',
|
|
35
|
+
focus: 'focused',
|
|
36
|
+
valid: 'success',
|
|
37
|
+
successful: 'success',
|
|
38
|
+
risk: 'warning',
|
|
39
|
+
caution: 'warning',
|
|
40
|
+
warn: 'warning',
|
|
41
|
+
primary: 'bold',
|
|
42
|
+
info: 'bold',
|
|
43
|
+
secondary: 'subtle',
|
|
44
|
+
hyperlink: 'link',
|
|
45
|
+
anchor: 'link',
|
|
46
|
+
active: 'pressed',
|
|
47
|
+
hover: 'hovered',
|
|
48
|
+
dragged: 'overlay',
|
|
49
|
+
dragging: 'overlay',
|
|
50
|
+
drag: 'overlay',
|
|
51
|
+
'background-color': 'background',
|
|
52
|
+
color: 'text',
|
|
53
|
+
icons: 'icon',
|
|
54
|
+
arrow: 'icon',
|
|
55
|
+
glyph: 'icon',
|
|
56
|
+
stroke: 'border',
|
|
57
|
+
'border-left': 'border',
|
|
58
|
+
'border-right': 'border',
|
|
59
|
+
'border-top': 'border',
|
|
60
|
+
'border-bottom': 'border',
|
|
61
|
+
'box-shadow': 'shadow',
|
|
66
62
|
};
|
|
67
63
|
const ADDITIONAL_META: Record<string, string> = {
|
|
68
|
-
|
|
69
|
-
|
|
64
|
+
grey: 'neutral',
|
|
65
|
+
red: 'danger',
|
|
70
66
|
};
|
|
71
67
|
|
|
72
68
|
export function cleanMeta(meta: string[]) {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
return filterDuplicateFoundations(cleanMeta);
|
|
69
|
+
const cleanMeta = meta
|
|
70
|
+
.reduce(
|
|
71
|
+
(accum: string[], val: string) => [
|
|
72
|
+
...accum,
|
|
73
|
+
...(typeof val === 'string' ? val.split(/(?=[A-Z])/g).map((e) => e.toLowerCase()) : []),
|
|
74
|
+
],
|
|
75
|
+
[],
|
|
76
|
+
)
|
|
77
|
+
.reduce((accum: string[], val: string) => {
|
|
78
|
+
if (val in ADDITIONAL_META) {
|
|
79
|
+
accum.push(val, ADDITIONAL_META[val]);
|
|
80
|
+
} else {
|
|
81
|
+
accum.push(val);
|
|
82
|
+
}
|
|
83
|
+
accum.push(val in REPLACEMENTS ? REPLACEMENTS[val] : val);
|
|
84
|
+
|
|
85
|
+
return accum;
|
|
86
|
+
}, [])
|
|
87
|
+
.filter((val: string) => uniqueWordsFromTokens.includes(val))
|
|
88
|
+
.reduce((accum: string[], val: string) => {
|
|
89
|
+
if (!accum.includes(val)) {
|
|
90
|
+
accum.push(val);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
return accum;
|
|
94
|
+
}, []);
|
|
95
|
+
|
|
96
|
+
return filterDuplicateFoundations(cleanMeta);
|
|
103
97
|
}
|
|
104
98
|
|
|
105
99
|
export function getBaseDeclarationMeta(decl: Declaration): string[] {
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
100
|
+
const parentSelectors = getParentSelectors(decl)
|
|
101
|
+
.split(/\-|\.|\,|\ |\:|\&/)
|
|
102
|
+
.filter(Boolean);
|
|
109
103
|
|
|
110
|
-
|
|
104
|
+
return [getPropertyMeta(decl.prop), ...parentSelectors];
|
|
111
105
|
}
|
|
112
106
|
|
|
113
107
|
function getPropertyMeta(prop: string) {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
108
|
+
if (prop === 'color') {
|
|
109
|
+
return 'text';
|
|
110
|
+
}
|
|
117
111
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
112
|
+
if (prop.startsWith('background')) {
|
|
113
|
+
return 'background';
|
|
114
|
+
}
|
|
121
115
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
116
|
+
if (prop.includes('shadow')) {
|
|
117
|
+
return 'shadow';
|
|
118
|
+
}
|
|
125
119
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
120
|
+
if (prop.includes('border')) {
|
|
121
|
+
return 'border';
|
|
122
|
+
}
|
|
129
123
|
|
|
130
|
-
|
|
124
|
+
return '';
|
|
131
125
|
}
|
|
132
126
|
|
|
133
127
|
function isRule(node: Node): node is Rule {
|
|
134
|
-
|
|
128
|
+
return node.type === 'rule';
|
|
135
129
|
}
|
|
136
130
|
|
|
137
131
|
function getParentSelectors(node: Node): string {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
132
|
+
if (isRule(node)) {
|
|
133
|
+
// @ts-expect-error
|
|
134
|
+
return getParentSelectors(node.parent) + ' ' + node.selector;
|
|
135
|
+
}
|
|
142
136
|
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
137
|
+
if (node.parent) {
|
|
138
|
+
return getParentSelectors(node.parent);
|
|
139
|
+
}
|
|
146
140
|
|
|
147
|
-
|
|
141
|
+
return '';
|
|
148
142
|
}
|
|
149
143
|
|
|
150
144
|
export function getCssVarMeta(cssVariable: string) {
|
|
151
|
-
|
|
152
|
-
|
|
145
|
+
const tokenName = extractCssVarName(cssVariable);
|
|
146
|
+
const meta = knownVariables[tokenName];
|
|
153
147
|
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
148
|
+
if (!meta || meta.length === 0) {
|
|
149
|
+
return tokenName.split('-');
|
|
150
|
+
}
|
|
157
151
|
|
|
158
|
-
|
|
152
|
+
return meta;
|
|
159
153
|
}
|
|
160
154
|
|
|
161
155
|
export function getRawColorMeta(rawColor: string) {
|
|
162
|
-
|
|
156
|
+
let cleanColor = rawColor.toLowerCase();
|
|
163
157
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
158
|
+
if (cleanColor.length === 4) {
|
|
159
|
+
cleanColor = cleanColor + cleanColor.substring(cleanColor.indexOf('#') + 1);
|
|
160
|
+
}
|
|
167
161
|
|
|
168
|
-
|
|
162
|
+
return knownRawColors[cleanColor] ?? [];
|
|
169
163
|
}
|
|
170
164
|
|
|
171
165
|
export function getNamedColorMeta(namedColor: string) {
|
|
172
|
-
|
|
166
|
+
return knownNamedColors[namedColor] ?? [];
|
|
173
167
|
}
|
|
@@ -4,51 +4,44 @@ import { activeTokens } from '../../utils/tokens';
|
|
|
4
4
|
import { cleanMeta } from './meta';
|
|
5
5
|
|
|
6
6
|
const COLOR_TOKEN_SEARCH_TYPES = [
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
7
|
+
'text',
|
|
8
|
+
'link',
|
|
9
|
+
'icon',
|
|
10
|
+
'border',
|
|
11
|
+
'background',
|
|
12
|
+
'blanket',
|
|
13
|
+
'skeleton',
|
|
14
|
+
'chart',
|
|
15
|
+
'surface',
|
|
16
|
+
'shadow',
|
|
17
17
|
];
|
|
18
18
|
|
|
19
19
|
function filterTokens(meta: string[]) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
token.startsWith(`elevation.${type}`),
|
|
29
|
-
),
|
|
30
|
-
)
|
|
31
|
-
: activeTokens;
|
|
20
|
+
const commonSearchTypes = COLOR_TOKEN_SEARCH_TYPES.filter((type) => meta.includes(type));
|
|
21
|
+
return commonSearchTypes.length !== 0
|
|
22
|
+
? activeTokens.filter((token) =>
|
|
23
|
+
commonSearchTypes.some(
|
|
24
|
+
(type) => token.startsWith(`color.${type}`) || token.startsWith(`elevation.${type}`),
|
|
25
|
+
),
|
|
26
|
+
)
|
|
27
|
+
: activeTokens;
|
|
32
28
|
}
|
|
33
29
|
|
|
34
30
|
function tokenToVar(token: string) {
|
|
35
|
-
|
|
36
|
-
.replace(/\./g, '-')
|
|
37
|
-
.replace('color-', '')
|
|
38
|
-
.replace('elevation-', '')}`;
|
|
31
|
+
return `--ds-${token.replace(/\./g, '-').replace('color-', '').replace('elevation-', '')}`;
|
|
39
32
|
}
|
|
40
33
|
|
|
41
34
|
export default function findToken(meta: string[]) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
35
|
+
const filteredTokens = filterTokens(meta);
|
|
36
|
+
const tokenFuzzySearch = Search(filteredTokens, false);
|
|
37
|
+
const cleanSearchTerms = cleanMeta(meta).join(' ');
|
|
38
|
+
const results: string[] = tokenFuzzySearch.get(cleanSearchTerms);
|
|
46
39
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
40
|
+
if (!results || results.length === 0) {
|
|
41
|
+
return 'MISSING_TOKEN';
|
|
42
|
+
}
|
|
50
43
|
|
|
51
|
-
|
|
44
|
+
const candidates = results.map((result) => result[1]);
|
|
52
45
|
|
|
53
|
-
|
|
46
|
+
return tokenToVar(candidates[0]);
|
|
54
47
|
}
|
|
@@ -1,85 +1,83 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
extractBetweenParentheses,
|
|
3
|
+
isGradient,
|
|
4
|
+
isKnownCssVariable,
|
|
5
|
+
isLessFunction,
|
|
6
|
+
isNamedColor,
|
|
7
|
+
isRawColor,
|
|
8
8
|
} from './colors';
|
|
9
9
|
import { extractCssVarName } from './declaration';
|
|
10
10
|
import { getCssVarMeta, getNamedColorMeta, getRawColorMeta } from './meta';
|
|
11
11
|
import findToken from './tokens';
|
|
12
12
|
|
|
13
13
|
interface Value {
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
getReplacement: (additionalMeta?: string[]) => string;
|
|
15
|
+
getMeta: () => string[];
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
export default function parseValue(value: string): Value | null {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
};
|
|
70
|
-
}
|
|
19
|
+
if (isLessFunction(value)) {
|
|
20
|
+
// eslint-disable-next-line no-console
|
|
21
|
+
console.warn('Cannot parse - less function detected, would cause compilation error');
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
if (isGradient(value)) {
|
|
25
|
+
return {
|
|
26
|
+
getReplacement(additionalMeta = []) {
|
|
27
|
+
const gradientContent = extractBetweenParentheses(value);
|
|
28
|
+
const values = gradientContent.split(',');
|
|
29
|
+
const replacedValues = values.map((val) => {
|
|
30
|
+
const parsedValue = parseValue(val.trim());
|
|
31
|
+
return parsedValue ? parsedValue.getReplacement(additionalMeta) : val;
|
|
32
|
+
});
|
|
33
|
+
return value.replace(gradientContent, replacedValues.join(', '));
|
|
34
|
+
},
|
|
35
|
+
getMeta() {
|
|
36
|
+
const BASE_META: string[] = [];
|
|
37
|
+
const gradientContent = extractBetweenParentheses(value);
|
|
38
|
+
const values = gradientContent.split(',');
|
|
39
|
+
const metas = values.reduce((acc, val) => {
|
|
40
|
+
const parsedValue = parseValue(val.trim());
|
|
41
|
+
return parsedValue ? [...acc, ...parsedValue.getMeta()] : acc;
|
|
42
|
+
}, BASE_META);
|
|
43
|
+
return metas;
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
if (isKnownCssVariable(extractCssVarName(value))) {
|
|
48
|
+
return {
|
|
49
|
+
getReplacement(additionalMeta = []) {
|
|
50
|
+
const token = findToken([...additionalMeta, ...this.getMeta()]);
|
|
51
|
+
return `var(${token}, ${value})`;
|
|
52
|
+
},
|
|
53
|
+
getMeta() {
|
|
54
|
+
return getCssVarMeta(value);
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
if (isRawColor(value)) {
|
|
59
|
+
return {
|
|
60
|
+
getReplacement(additionalMeta = []) {
|
|
61
|
+
const token = findToken([...additionalMeta, ...this.getMeta()]);
|
|
62
|
+
return `var(${token}, ${value})`;
|
|
63
|
+
},
|
|
64
|
+
getMeta() {
|
|
65
|
+
return getRawColorMeta(value);
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
}
|
|
71
69
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
70
|
+
if (isNamedColor(value)) {
|
|
71
|
+
return {
|
|
72
|
+
getReplacement(additionalMeta = []) {
|
|
73
|
+
const token = findToken([...additionalMeta, ...this.getMeta()]);
|
|
74
|
+
return `var(${token}, ${value})`;
|
|
75
|
+
},
|
|
76
|
+
getMeta() {
|
|
77
|
+
return getNamedColorMeta(value);
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
}
|
|
83
81
|
|
|
84
|
-
|
|
82
|
+
return null;
|
|
85
83
|
}
|