@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 +6 -0
- package/codemods/hypermod.config.tsx +2 -0
- package/codemods/remove-fallbacks-color/transform.tsx +26 -0
- package/dist/cjs/get-token-value.js +1 -1
- package/dist/cjs/get-token.js +1 -1
- package/dist/es2019/get-token-value.js +1 -1
- package/dist/es2019/get-token.js +1 -1
- package/dist/esm/get-token-value.js +1 -1
- package/dist/esm/get-token.js +1 -1
- package/package.json +6 -5
- package/codemods/css-to-design-tokens/__tests__/css-to-design-tokens.test.tsx +0 -489
- package/codemods/css-to-design-tokens/__tests__/utils.test.tsx +0 -145
- package/codemods/theme-to-design-tokens/__tests__/theme-to-design-tokens.test.tsx +0 -1104
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import { isRawColor } from '../lib/colors';
|
|
2
|
-
import { splitCssValue } from '../lib/declaration';
|
|
3
|
-
|
|
4
|
-
describe('Utils', () => {
|
|
5
|
-
describe('splitCssValue', () => {
|
|
6
|
-
describe('Handling simple CSS values', () => {
|
|
7
|
-
it('should split a simple CSS value correctly', () => {
|
|
8
|
-
const result = splitCssValue('red blue');
|
|
9
|
-
expect(result).toEqual(['red', 'blue']);
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it('should handle multiple spaces correctly', () => {
|
|
13
|
-
const result = splitCssValue('red blue');
|
|
14
|
-
expect(result).toEqual(['red', 'blue']);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('should handle CSS values with special characters correctly', () => {
|
|
18
|
-
const result = splitCssValue('1px solid #000');
|
|
19
|
-
expect(result).toEqual(['1px', 'solid', '#000']);
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
describe('Handling CSS functions', () => {
|
|
24
|
-
it('should split a CSS value with a function correctly', () => {
|
|
25
|
-
const result = splitCssValue('linear-gradient(red, blue)');
|
|
26
|
-
expect(result).toEqual(['linear-gradient(red, blue)']);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it('should handle CSS values with commas correctly', () => {
|
|
30
|
-
const result = splitCssValue('rgba(255, 255, 255, 0.6)');
|
|
31
|
-
expect(result).toEqual(['rgba(255, 255, 255, 0.6)']);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it('should handle CSS values with multiple functions correctly', () => {
|
|
35
|
-
const result = splitCssValue('linear-gradient(red, blue) no-repeat');
|
|
36
|
-
expect(result).toEqual(['linear-gradient(red, blue)', 'no-repeat']);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('should handle less functions correctly', () => {
|
|
40
|
-
const result = splitCssValue('darken(#000, 10%)');
|
|
41
|
-
expect(result).toEqual(['darken(#000, 10%)']);
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('should handle CSS url() function correctly', () => {
|
|
45
|
-
const result = splitCssValue('url(http://example.com/image.jpg)');
|
|
46
|
-
expect(result).toEqual(['url(http://example.com/image.jpg)']);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it('should handle multiple CSS functions correctly', () => {
|
|
50
|
-
const result = splitCssValue(
|
|
51
|
-
'linear-gradient(red, blue) url(http://example.com/image.jpg)',
|
|
52
|
-
);
|
|
53
|
-
expect(result).toEqual([
|
|
54
|
-
'linear-gradient(red, blue)',
|
|
55
|
-
'url(http://example.com/image.jpg)',
|
|
56
|
-
]);
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
it('should handle CSS functions with nested functions correctly', () => {
|
|
60
|
-
const result = splitCssValue(
|
|
61
|
-
'linear-gradient(to right, rgba(255, 0, 0, 0.5), rgba(0, 255, 0, 0.5))',
|
|
62
|
-
);
|
|
63
|
-
expect(result).toEqual([
|
|
64
|
-
'linear-gradient(to right, rgba(255, 0, 0, 0.5), rgba(0, 255, 0, 0.5))',
|
|
65
|
-
]);
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
describe('Handling edge cases', () => {
|
|
70
|
-
it('should return null for an empty string', () => {
|
|
71
|
-
const result = splitCssValue('');
|
|
72
|
-
expect(result).toBeNull();
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
it('should handle no spaces between commas correctly', () => {
|
|
76
|
-
const result = splitCssValue('rgba(255,255,255,0.6)');
|
|
77
|
-
expect(result).toEqual(['rgba(255,255,255,0.6)']);
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
it('should handle extra spaces around commas correctly', () => {
|
|
81
|
-
const result = splitCssValue('rgba(255 , 255 , 255 , 0.6)');
|
|
82
|
-
expect(result).toEqual(['rgba(255 , 255 , 255 , 0.6)']);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it('should handle other whitespace characters correctly', () => {
|
|
86
|
-
const result = splitCssValue('red\tblue\nblack');
|
|
87
|
-
expect(result).toEqual(['red', 'blue', 'black']);
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it('should handle CSS values with exclamation mark correctly', () => {
|
|
91
|
-
const result = splitCssValue('color: red !important');
|
|
92
|
-
expect(result).toEqual(['color:', 'red', '!important']);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it('should ignore leading and trailing spaces', () => {
|
|
96
|
-
const result = splitCssValue(' red blue ');
|
|
97
|
-
expect(result).toEqual(['red', 'blue']);
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
describe('isRawColor', () => {
|
|
103
|
-
it('should return true for valid raw color values', () => {
|
|
104
|
-
expect(isRawColor('#fff')).toBe(true);
|
|
105
|
-
expect(isRawColor('#ffffff')).toBe(true);
|
|
106
|
-
expect(isRawColor('rgb(255, 255, 255)')).toBe(true);
|
|
107
|
-
expect(isRawColor('rgba(255, 255, 255, 1)')).toBe(true);
|
|
108
|
-
expect(isRawColor('hsl(120, 100%, 50%)')).toBe(true);
|
|
109
|
-
expect(isRawColor('hsla(120, 100%, 50%, 0.3)')).toBe(true);
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
it('should return false for invalid raw color values', () => {
|
|
113
|
-
expect(isRawColor('#ggg')).toBe(false);
|
|
114
|
-
expect(isRawColor('rgb(255, 255)')).toBe(false);
|
|
115
|
-
expect(isRawColor('rgba(255, 255, 255)')).toBe(false);
|
|
116
|
-
expect(isRawColor('hsl(120, 100%)')).toBe(false);
|
|
117
|
-
expect(isRawColor('hsla(120, 100%, 50%)')).toBe(false);
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
it('should return false for CSS variables', () => {
|
|
121
|
-
expect(isRawColor('var(--main-color)')).toBe(false);
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
it('should return true for valid raw color values with leading spaces', () => {
|
|
125
|
-
expect(isRawColor(' #fff')).toBe(true);
|
|
126
|
-
expect(isRawColor(' rgba(255, 255, 255, 1)')).toBe(true);
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
it('should return true for valid raw color values with multiple spaces', () => {
|
|
130
|
-
expect(isRawColor('rgb(255, 255, 255)')).toBe(true);
|
|
131
|
-
expect(isRawColor('rgba(255, 255, 255, 1)')).toBe(true);
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
it('should return true for valid raw color values with any number for the alpha channel', () => {
|
|
135
|
-
expect(isRawColor('rgba(255, 255, 255, 5)')).toBe(true);
|
|
136
|
-
expect(isRawColor('rgba(255, 255, 255, -1)')).toBe(true);
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
it('should return true for less often used color formats', () => {
|
|
140
|
-
expect(isRawColor('lab(50% 0 0)')).toBe(true);
|
|
141
|
-
expect(isRawColor('lch(50% 0 0)')).toBe(true);
|
|
142
|
-
expect(isRawColor('hwb(0 0% 0%)')).toBe(true);
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
});
|