@atlaskit/tokens 0.9.0 → 0.9.3
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 +18 -0
- package/babel-plugin/package.json +3 -0
- package/css/atlassian-dark.css +2 -2
- package/css/atlassian-light.css +2 -2
- package/dist/cjs/artifacts/palettes-raw.js +1983 -0
- package/dist/cjs/artifacts/token-default-values.js +2 -2
- package/dist/cjs/artifacts/tokens-raw/atlassian-dark.js +378 -4
- package/dist/cjs/artifacts/tokens-raw/atlassian-light.js +378 -4
- package/dist/cjs/entry-points/palettes-raw.js +15 -0
- package/dist/cjs/entry-points/token-ids.js +1 -1
- package/dist/cjs/get-token.js +1 -1
- package/dist/cjs/tokens/atlassian-dark/color/background.js +2 -2
- package/dist/cjs/tokens/atlassian-light/color/background.js +2 -2
- package/dist/cjs/tokens/default/deprecated/deprecated.js +187 -0
- package/dist/cjs/tokens/palette.js +232 -116
- package/dist/cjs/utils/color-detection.js +129 -0
- package/dist/cjs/{token-ids.js → utils/token-ids.js} +1 -1
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/artifacts/palettes-raw.js +1976 -0
- package/dist/es2019/artifacts/token-default-values.js +2 -2
- package/dist/es2019/artifacts/tokens-raw/atlassian-dark.js +378 -4
- package/dist/es2019/artifacts/tokens-raw/atlassian-light.js +378 -4
- package/dist/es2019/entry-points/palettes-raw.js +1 -0
- package/dist/es2019/entry-points/token-ids.js +1 -1
- package/dist/es2019/get-token.js +1 -1
- package/dist/es2019/tokens/atlassian-dark/color/background.js +2 -2
- package/dist/es2019/tokens/atlassian-light/color/background.js +2 -2
- package/dist/es2019/tokens/default/deprecated/deprecated.js +187 -0
- package/dist/es2019/tokens/palette.js +232 -116
- package/dist/es2019/utils/color-detection.js +101 -0
- package/dist/es2019/{token-ids.js → utils/token-ids.js} +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/esm/artifacts/palettes-raw.js +1976 -0
- package/dist/esm/artifacts/token-default-values.js +2 -2
- package/dist/esm/artifacts/tokens-raw/atlassian-dark.js +378 -4
- package/dist/esm/artifacts/tokens-raw/atlassian-light.js +378 -4
- package/dist/esm/entry-points/palettes-raw.js +1 -0
- package/dist/esm/entry-points/token-ids.js +1 -1
- package/dist/esm/get-token.js +1 -1
- package/dist/esm/tokens/atlassian-dark/color/background.js +2 -2
- package/dist/esm/tokens/atlassian-light/color/background.js +2 -2
- package/dist/esm/tokens/default/deprecated/deprecated.js +187 -0
- package/dist/esm/tokens/palette.js +232 -116
- package/dist/esm/utils/color-detection.js +104 -0
- package/dist/esm/{token-ids.js → utils/token-ids.js} +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/types/artifacts/palettes-raw.d.ts +19 -0
- package/dist/types/artifacts/token-default-values.d.ts +2 -2
- package/dist/types/artifacts/tokens-raw/atlassian-dark.d.ts +43 -0
- package/dist/types/artifacts/tokens-raw/atlassian-light.d.ts +43 -0
- package/dist/types/entry-points/palettes-raw.d.ts +1 -0
- package/dist/types/entry-points/token-ids.d.ts +1 -1
- package/dist/types/tokens/atlassian-dark/utility/utility.d.ts +2 -10
- package/dist/types/tokens/atlassian-light/utility/utility.d.ts +2 -10
- package/dist/types/tokens/default/utility/utility.d.ts +2 -142
- package/dist/types/types.d.ts +22 -7
- package/dist/types/utils/color-detection.d.ts +38 -0
- package/dist/types/{token-ids.d.ts → utils/token-ids.d.ts} +0 -0
- package/package.json +15 -5
- package/palettes-raw/package.json +10 -0
- package/rename-mapping/package.json +3 -0
- package/token-ids/package.json +3 -0
- package/token-names/package.json +3 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { token } from '../index';
|
|
2
|
+
export var hexToRGBAValues = function hexToRGBAValues(hex) {
|
|
3
|
+
var hexColor = hex.replace('#', '');
|
|
4
|
+
return {
|
|
5
|
+
r: parseInt(hexColor.slice(0, 2), 16),
|
|
6
|
+
g: parseInt(hexColor.slice(2, 4), 16),
|
|
7
|
+
b: parseInt(hexColor.slice(4, 6), 16),
|
|
8
|
+
a: parseFloat((parseInt(hexColor.slice(6, 8), 16) / 255).toFixed(2))
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export var hexToRGBA = function hexToRGBA(hex) {
|
|
12
|
+
var _hexToRGBAValues = hexToRGBAValues(hex),
|
|
13
|
+
r = _hexToRGBAValues.r,
|
|
14
|
+
g = _hexToRGBAValues.g,
|
|
15
|
+
b = _hexToRGBAValues.b,
|
|
16
|
+
a = _hexToRGBAValues.a;
|
|
17
|
+
|
|
18
|
+
return "rgb".concat(a ? 'a' : '', "(").concat(r, ",").concat(g, ",").concat(b).concat(a ? ",".concat(a) : '', ")");
|
|
19
|
+
};
|
|
20
|
+
export var getLuminance = function getLuminance(_ref) {
|
|
21
|
+
var r = _ref.r,
|
|
22
|
+
g = _ref.g,
|
|
23
|
+
b = _ref.b;
|
|
24
|
+
return (r * 299 + g * 587 + b * 114) / 1000;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Returns an accessible hard-coded text color based on the color contrast with
|
|
28
|
+
* the background.
|
|
29
|
+
*
|
|
30
|
+
* @param hex - The Hex color code of the background
|
|
31
|
+
* @param [opts.hardcodedSurface] - If set, a design token will be returned instead
|
|
32
|
+
* of a hard-coded color. This is to support more transparent backgrounds
|
|
33
|
+
* to allow the text to invert colors depending on the current theme's surface color.
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
export var getTextColorForBackground = function getTextColorForBackground(hex, opts) {
|
|
37
|
+
var _hexToRGBAValues2 = hexToRGBAValues(hex),
|
|
38
|
+
r = _hexToRGBAValues2.r,
|
|
39
|
+
g = _hexToRGBAValues2.g,
|
|
40
|
+
b = _hexToRGBAValues2.b,
|
|
41
|
+
a = _hexToRGBAValues2.a;
|
|
42
|
+
|
|
43
|
+
var lum = getLuminance({
|
|
44
|
+
r: r,
|
|
45
|
+
g: g,
|
|
46
|
+
b: b
|
|
47
|
+
});
|
|
48
|
+
var alphaLimit = 0.42;
|
|
49
|
+
var alphaConditionsPerSurface = {
|
|
50
|
+
light: a < alphaLimit,
|
|
51
|
+
dark: a > alphaLimit
|
|
52
|
+
};
|
|
53
|
+
var alphaLimitExceeded = (opts === null || opts === void 0 ? void 0 : opts.hardcodedSurface) && alphaConditionsPerSurface[opts.hardcodedSurface];
|
|
54
|
+
|
|
55
|
+
if (!(opts !== null && opts !== void 0 && opts.hardcodedSurface) && a < alphaLimit) {
|
|
56
|
+
// This color is transparent, so the text will mainly cast onto the surface behind.
|
|
57
|
+
// Needs to use tokens otherwise Dark mode would cause black text on black surface
|
|
58
|
+
return token('color.text', 'black');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return lum > 150 && !a || a && alphaLimitExceeded ? 'black' : 'white';
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* Returns a border if determined to be required based on the color contrast with
|
|
65
|
+
* the background.
|
|
66
|
+
*
|
|
67
|
+
* @param hex - The Hex color code of the background
|
|
68
|
+
*/
|
|
69
|
+
|
|
70
|
+
export var getBorderForBackground = function getBorderForBackground(hex) {
|
|
71
|
+
var _hexToRGBAValues3 = hexToRGBAValues(hex),
|
|
72
|
+
r = _hexToRGBAValues3.r,
|
|
73
|
+
g = _hexToRGBAValues3.g,
|
|
74
|
+
b = _hexToRGBAValues3.b,
|
|
75
|
+
a = _hexToRGBAValues3.a;
|
|
76
|
+
|
|
77
|
+
var lum = getLuminance({
|
|
78
|
+
r: r,
|
|
79
|
+
g: g,
|
|
80
|
+
b: b
|
|
81
|
+
});
|
|
82
|
+
return lum > 240 || a < 0.2 ? "1px solid ".concat(token('color.border', '#091E4224')) : undefined;
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Returns a box shadow formatted for CSS from a ShadowToken raw value.
|
|
86
|
+
*
|
|
87
|
+
* @param rawShadow - ShadowToken raw value
|
|
88
|
+
*/
|
|
89
|
+
|
|
90
|
+
export var getBoxShadow = function getBoxShadow(rawShadow) {
|
|
91
|
+
return rawShadow.map(function (_ref2) {
|
|
92
|
+
var radius = _ref2.radius,
|
|
93
|
+
offset = _ref2.offset,
|
|
94
|
+
color = _ref2.color,
|
|
95
|
+
opacity = _ref2.opacity;
|
|
96
|
+
|
|
97
|
+
var _hexToRGBAValues4 = hexToRGBAValues(color),
|
|
98
|
+
r = _hexToRGBAValues4.r,
|
|
99
|
+
g = _hexToRGBAValues4.g,
|
|
100
|
+
b = _hexToRGBAValues4.b;
|
|
101
|
+
|
|
102
|
+
return "".concat(offset.x, "px ").concat(offset.y, "px ").concat(radius, "px rgba(").concat(r, ", ").concat(g, ", ").concat(b, ", ").concat(opacity, ")");
|
|
103
|
+
}).join(',');
|
|
104
|
+
};
|
package/dist/esm/version.json
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
declare const tokens: {
|
|
2
|
+
value: string;
|
|
3
|
+
attributes: {
|
|
4
|
+
group: string;
|
|
5
|
+
category: string;
|
|
6
|
+
};
|
|
7
|
+
filePath: string;
|
|
8
|
+
isSource: boolean;
|
|
9
|
+
original: {
|
|
10
|
+
value: string;
|
|
11
|
+
attributes: {
|
|
12
|
+
group: string;
|
|
13
|
+
category: string;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
name: string;
|
|
17
|
+
path: string[];
|
|
18
|
+
}[];
|
|
19
|
+
export default tokens;
|
|
@@ -235,8 +235,8 @@ declare const defaultTokenValues: {
|
|
|
235
235
|
readonly 'color.background.transparentNeutral.hover': "#091E420F";
|
|
236
236
|
readonly 'color.background.transparentNeutral.pressed': "#091E4224";
|
|
237
237
|
readonly 'color.blanket': "#091E427A";
|
|
238
|
-
readonly 'color.blanket.selected': "#
|
|
239
|
-
readonly 'color.blanket.danger': "#
|
|
238
|
+
readonly 'color.blanket.selected': "#388BFF14";
|
|
239
|
+
readonly 'color.blanket.danger': "#EF5C4814";
|
|
240
240
|
readonly 'color.interaction.hovered': "#ffffff33";
|
|
241
241
|
readonly 'color.interaction.pressed': "#ffffff5c";
|
|
242
242
|
readonly 'color.interaction.inverse.hovered': "#00000029";
|
|
@@ -4,6 +4,8 @@ declare const tokens: ({
|
|
|
4
4
|
state: string;
|
|
5
5
|
introduced: string;
|
|
6
6
|
description: string;
|
|
7
|
+
deprecated?: undefined;
|
|
8
|
+
deleted?: undefined;
|
|
7
9
|
replacement?: undefined;
|
|
8
10
|
};
|
|
9
11
|
value: string;
|
|
@@ -15,6 +17,8 @@ declare const tokens: ({
|
|
|
15
17
|
state: string;
|
|
16
18
|
introduced: string;
|
|
17
19
|
description: string;
|
|
20
|
+
deprecated?: undefined;
|
|
21
|
+
deleted?: undefined;
|
|
18
22
|
replacement?: undefined;
|
|
19
23
|
};
|
|
20
24
|
value: string;
|
|
@@ -26,6 +30,8 @@ declare const tokens: ({
|
|
|
26
30
|
group: string;
|
|
27
31
|
state: string;
|
|
28
32
|
introduced: string;
|
|
33
|
+
deprecated: string;
|
|
34
|
+
deleted: string;
|
|
29
35
|
replacement: string;
|
|
30
36
|
description: string;
|
|
31
37
|
};
|
|
@@ -37,6 +43,8 @@ declare const tokens: ({
|
|
|
37
43
|
group: string;
|
|
38
44
|
state: string;
|
|
39
45
|
introduced: string;
|
|
46
|
+
deprecated: string;
|
|
47
|
+
deleted: string;
|
|
40
48
|
replacement: string;
|
|
41
49
|
description: string;
|
|
42
50
|
};
|
|
@@ -49,6 +57,35 @@ declare const tokens: ({
|
|
|
49
57
|
group: string;
|
|
50
58
|
state: string;
|
|
51
59
|
introduced: string;
|
|
60
|
+
deprecated: string;
|
|
61
|
+
replacement: string;
|
|
62
|
+
description: string;
|
|
63
|
+
deleted?: undefined;
|
|
64
|
+
};
|
|
65
|
+
value: string;
|
|
66
|
+
filePath: string;
|
|
67
|
+
isSource: boolean;
|
|
68
|
+
original: {
|
|
69
|
+
attributes: {
|
|
70
|
+
group: string;
|
|
71
|
+
state: string;
|
|
72
|
+
introduced: string;
|
|
73
|
+
deprecated: string;
|
|
74
|
+
replacement: string;
|
|
75
|
+
description: string;
|
|
76
|
+
deleted?: undefined;
|
|
77
|
+
};
|
|
78
|
+
value: string;
|
|
79
|
+
};
|
|
80
|
+
name: string;
|
|
81
|
+
path: string[];
|
|
82
|
+
} | {
|
|
83
|
+
attributes: {
|
|
84
|
+
group: string;
|
|
85
|
+
state: string;
|
|
86
|
+
introduced: string;
|
|
87
|
+
deprecated: string;
|
|
88
|
+
deleted: string;
|
|
52
89
|
replacement: string;
|
|
53
90
|
description: string;
|
|
54
91
|
};
|
|
@@ -80,6 +117,8 @@ declare const tokens: ({
|
|
|
80
117
|
group: string;
|
|
81
118
|
state: string;
|
|
82
119
|
introduced: string;
|
|
120
|
+
deprecated: string;
|
|
121
|
+
deleted: string;
|
|
83
122
|
replacement: string;
|
|
84
123
|
description: string;
|
|
85
124
|
};
|
|
@@ -113,6 +152,8 @@ declare const tokens: ({
|
|
|
113
152
|
state: string;
|
|
114
153
|
introduced: string;
|
|
115
154
|
description: string;
|
|
155
|
+
deprecated?: undefined;
|
|
156
|
+
deleted?: undefined;
|
|
116
157
|
replacement?: undefined;
|
|
117
158
|
};
|
|
118
159
|
value: ({
|
|
@@ -144,6 +185,8 @@ declare const tokens: ({
|
|
|
144
185
|
state: string;
|
|
145
186
|
introduced: string;
|
|
146
187
|
description: string;
|
|
188
|
+
deprecated?: undefined;
|
|
189
|
+
deleted?: undefined;
|
|
147
190
|
replacement?: undefined;
|
|
148
191
|
};
|
|
149
192
|
value: ({
|
|
@@ -4,6 +4,8 @@ declare const tokens: ({
|
|
|
4
4
|
state: string;
|
|
5
5
|
introduced: string;
|
|
6
6
|
description: string;
|
|
7
|
+
deprecated?: undefined;
|
|
8
|
+
deleted?: undefined;
|
|
7
9
|
replacement?: undefined;
|
|
8
10
|
};
|
|
9
11
|
value: string;
|
|
@@ -15,6 +17,8 @@ declare const tokens: ({
|
|
|
15
17
|
state: string;
|
|
16
18
|
introduced: string;
|
|
17
19
|
description: string;
|
|
20
|
+
deprecated?: undefined;
|
|
21
|
+
deleted?: undefined;
|
|
18
22
|
replacement?: undefined;
|
|
19
23
|
};
|
|
20
24
|
value: string;
|
|
@@ -26,6 +30,8 @@ declare const tokens: ({
|
|
|
26
30
|
group: string;
|
|
27
31
|
state: string;
|
|
28
32
|
introduced: string;
|
|
33
|
+
deprecated: string;
|
|
34
|
+
deleted: string;
|
|
29
35
|
replacement: string;
|
|
30
36
|
description: string;
|
|
31
37
|
};
|
|
@@ -37,6 +43,8 @@ declare const tokens: ({
|
|
|
37
43
|
group: string;
|
|
38
44
|
state: string;
|
|
39
45
|
introduced: string;
|
|
46
|
+
deprecated: string;
|
|
47
|
+
deleted: string;
|
|
40
48
|
replacement: string;
|
|
41
49
|
description: string;
|
|
42
50
|
};
|
|
@@ -49,6 +57,35 @@ declare const tokens: ({
|
|
|
49
57
|
group: string;
|
|
50
58
|
state: string;
|
|
51
59
|
introduced: string;
|
|
60
|
+
deprecated: string;
|
|
61
|
+
replacement: string;
|
|
62
|
+
description: string;
|
|
63
|
+
deleted?: undefined;
|
|
64
|
+
};
|
|
65
|
+
value: string;
|
|
66
|
+
filePath: string;
|
|
67
|
+
isSource: boolean;
|
|
68
|
+
original: {
|
|
69
|
+
attributes: {
|
|
70
|
+
group: string;
|
|
71
|
+
state: string;
|
|
72
|
+
introduced: string;
|
|
73
|
+
deprecated: string;
|
|
74
|
+
replacement: string;
|
|
75
|
+
description: string;
|
|
76
|
+
deleted?: undefined;
|
|
77
|
+
};
|
|
78
|
+
value: string;
|
|
79
|
+
};
|
|
80
|
+
name: string;
|
|
81
|
+
path: string[];
|
|
82
|
+
} | {
|
|
83
|
+
attributes: {
|
|
84
|
+
group: string;
|
|
85
|
+
state: string;
|
|
86
|
+
introduced: string;
|
|
87
|
+
deprecated: string;
|
|
88
|
+
deleted: string;
|
|
52
89
|
replacement: string;
|
|
53
90
|
description: string;
|
|
54
91
|
};
|
|
@@ -68,6 +105,8 @@ declare const tokens: ({
|
|
|
68
105
|
group: string;
|
|
69
106
|
state: string;
|
|
70
107
|
introduced: string;
|
|
108
|
+
deprecated: string;
|
|
109
|
+
deleted: string;
|
|
71
110
|
replacement: string;
|
|
72
111
|
description: string;
|
|
73
112
|
};
|
|
@@ -89,6 +128,8 @@ declare const tokens: ({
|
|
|
89
128
|
state: string;
|
|
90
129
|
introduced: string;
|
|
91
130
|
description: string;
|
|
131
|
+
deprecated?: undefined;
|
|
132
|
+
deleted?: undefined;
|
|
92
133
|
replacement?: undefined;
|
|
93
134
|
};
|
|
94
135
|
value: {
|
|
@@ -108,6 +149,8 @@ declare const tokens: ({
|
|
|
108
149
|
state: string;
|
|
109
150
|
introduced: string;
|
|
110
151
|
description: string;
|
|
152
|
+
deprecated?: undefined;
|
|
153
|
+
deleted?: undefined;
|
|
111
154
|
replacement?: undefined;
|
|
112
155
|
};
|
|
113
156
|
value: {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '../artifacts/palettes-raw';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { getCSSCustomProperty, getTokenId, getFullyQualifiedTokenId, } from '../token-ids';
|
|
1
|
+
export { getCSSCustomProperty, getTokenId, getFullyQualifiedTokenId, } from '../utils/token-ids';
|
|
@@ -1,13 +1,5 @@
|
|
|
1
|
+
import type { UtilTokenSchema, ValueSchema } from '../../../types';
|
|
1
2
|
declare const _default: {
|
|
2
|
-
utility:
|
|
3
|
-
UNSAFE_util: {
|
|
4
|
-
transparent: {
|
|
5
|
-
value: string;
|
|
6
|
-
};
|
|
7
|
-
MISSING_TOKEN: {
|
|
8
|
-
value: string;
|
|
9
|
-
};
|
|
10
|
-
};
|
|
11
|
-
}, "UNSAFE_util">;
|
|
3
|
+
utility: ValueSchema<UtilTokenSchema>;
|
|
12
4
|
};
|
|
13
5
|
export default _default;
|
|
@@ -1,13 +1,5 @@
|
|
|
1
|
+
import type { UtilTokenSchema, ValueSchema } from '../../../types';
|
|
1
2
|
declare const _default: {
|
|
2
|
-
utility:
|
|
3
|
-
UNSAFE_util: {
|
|
4
|
-
transparent: {
|
|
5
|
-
value: string;
|
|
6
|
-
};
|
|
7
|
-
MISSING_TOKEN: {
|
|
8
|
-
value: string;
|
|
9
|
-
};
|
|
10
|
-
};
|
|
11
|
-
}, "UNSAFE_util">;
|
|
3
|
+
utility: ValueSchema<UtilTokenSchema>;
|
|
12
4
|
};
|
|
13
5
|
export default _default;
|