@atlaskit/tokens 13.0.3 → 13.0.4
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 +7 -0
- package/codemods/css-to-design-tokens/lib/meta.tsx +1 -1
- package/codemods/css-to-design-tokens/lib/tokens.tsx +1 -1
- package/codemods/theme-to-design-tokens/transform.tsx +16 -14
- package/codemods/theme-to-design-tokens/utils/ast-meta.tsx +2 -151
- package/codemods/theme-to-design-tokens/utils/ast.tsx +3 -35
- package/codemods/theme-to-design-tokens/utils/clean-meta.tsx +63 -0
- package/codemods/theme-to-design-tokens/utils/color.tsx +3 -11
- package/codemods/theme-to-design-tokens/utils/contains-replaceable-css-declarations.tsx +13 -0
- package/codemods/theme-to-design-tokens/utils/css-utils.tsx +2 -35
- package/codemods/theme-to-design-tokens/utils/find-end-index-of-css-expression.tsx +21 -0
- package/codemods/theme-to-design-tokens/utils/find-first-nonspace-index-after.tsx +9 -0
- package/codemods/theme-to-design-tokens/utils/get-closest-decendant-of-type.tsx +10 -0
- package/codemods/theme-to-design-tokens/utils/get-meta-from-ancestors.tsx +87 -0
- package/codemods/theme-to-design-tokens/utils/is-bold-color.tsx +4 -0
- package/codemods/theme-to-design-tokens/utils/is-decendant-of-token.tsx +14 -0
- package/codemods/theme-to-design-tokens/utils/is-legacy-color.tsx +4 -0
- package/codemods/theme-to-design-tokens/utils/is-legacy-named-color.tsx +4 -0
- package/codemods/theme-to-design-tokens/utils/is-parent-of-token.tsx +13 -0
- package/codemods/theme-to-design-tokens/utils/kebabize.tsx +2 -0
- package/codemods/theme-to-design-tokens/utils/legacy-color-meta-map.tsx +88 -0
- package/codemods/theme-to-design-tokens/utils/legacy-color-mixins.tsx +26 -0
- package/codemods/theme-to-design-tokens/utils/legacy-colors.tsx +2 -115
- package/codemods/theme-to-design-tokens/utils/split-at-index.tsx +3 -0
- package/codemods/theme-to-design-tokens/utils/string-utils.tsx +3 -16
- package/codemods/utils/active-tokens.tsx +284 -0
- package/codemods/utils/tokens.tsx +2 -376
- package/codemods/utils/unique-words-from-tokens.tsx +91 -0
- package/dist/cjs/artifacts/replacement-mapping.js +5 -2
- package/dist/cjs/artifacts/tokens-raw/atlassian-motion.js +3 -3
- package/dist/cjs/custom-theme.js +10 -60
- package/dist/cjs/entry-points/token-metadata.codegen.js +1 -10
- package/dist/cjs/get-custom-theme-styles.js +57 -0
- package/dist/cjs/get-global-theme.js +2 -2
- package/dist/cjs/get-theme-html-attrs.js +2 -2
- package/dist/cjs/get-theme-styles.js +6 -5
- package/dist/cjs/load-custom-theme-styles.js +2 -2
- package/dist/cjs/set-global-theme.js +4 -3
- package/dist/cjs/theme-color-modes.js +13 -0
- package/dist/cjs/theme-config.js +19 -16
- package/dist/cjs/theme-ids.js +13 -0
- package/dist/cjs/theme-state-transformer.js +2 -2
- package/dist/cjs/utils/color-detection.js +9 -12
- package/dist/cjs/utils/color-utils.js +38 -47
- package/dist/cjs/utils/custom-theme-loading-utils.js +7 -11
- package/dist/cjs/utils/generate-custom-color-ramp.js +16 -19
- package/dist/cjs/utils/get-alpha.js +13 -0
- package/dist/cjs/utils/get-closest-color-index.js +20 -0
- package/dist/cjs/utils/get-css-custom-property.js +32 -0
- package/dist/cjs/utils/get-fully-qualified-token-id.js +19 -0
- package/dist/cjs/utils/get-theme-override-preferences.js +12 -0
- package/dist/cjs/utils/get-theme-preferences.js +8 -5
- package/dist/cjs/utils/get-token-id.js +26 -0
- package/dist/cjs/utils/hct-color-utils/argb-from-rgb.js +12 -0
- package/dist/cjs/utils/hct-color-utils/clamp-double.js +20 -0
- package/dist/cjs/utils/hct-color-utils/clamp-int.js +20 -0
- package/dist/cjs/utils/hct-color-utils/color-utils.js +34 -59
- package/dist/cjs/utils/hct-color-utils/delinearized.js +27 -0
- package/dist/cjs/utils/hct-color-utils/hct.js +19 -95
- package/dist/cjs/utils/hct-color-utils/lerp.js +14 -0
- package/dist/cjs/utils/hct-color-utils/linearized.js +22 -0
- package/dist/cjs/utils/hct-color-utils/math-utils.js +38 -107
- package/dist/cjs/utils/hct-color-utils/matrix-multiply.js +15 -0
- package/dist/cjs/utils/hct-color-utils/sanitize-degrees-double.js +19 -0
- package/dist/cjs/utils/hct-color-utils/signum.js +20 -0
- package/dist/cjs/utils/hct-color-utils/viewing-conditions.js +98 -0
- package/dist/cjs/utils/hex-to-rgba-values.js +15 -0
- package/dist/cjs/utils/hsl-to-rgb.js +18 -0
- package/dist/cjs/utils/is-valid-brand-hex.js +9 -0
- package/dist/cjs/utils/limit-size-of-custom-style-elements.js +16 -0
- package/dist/cjs/utils/load-theme-css.js +32 -0
- package/dist/cjs/utils/relative-luminance-w3-c.js +18 -0
- package/dist/cjs/utils/rgb-to-hex.js +9 -0
- package/dist/cjs/utils/theme-loading.js +10 -25
- package/dist/cjs/utils/token-ids.js +21 -62
- package/dist/es2019/artifacts/replacement-mapping.js +5 -2
- package/dist/es2019/artifacts/tokens-raw/atlassian-motion.js +3 -3
- package/dist/es2019/custom-theme.js +4 -66
- package/dist/es2019/entry-points/token-metadata.codegen.js +1 -10
- package/dist/es2019/get-custom-theme-styles.js +60 -0
- package/dist/es2019/get-global-theme.js +1 -1
- package/dist/es2019/get-theme-html-attrs.js +1 -1
- package/dist/es2019/get-theme-styles.js +4 -3
- package/dist/es2019/load-custom-theme-styles.js +1 -1
- package/dist/es2019/set-global-theme.js +3 -2
- package/dist/es2019/theme-color-modes.js +7 -0
- package/dist/es2019/theme-config.js +4 -16
- package/dist/es2019/theme-ids.js +7 -0
- package/dist/es2019/theme-state-transformer.js +1 -1
- package/dist/es2019/utils/color-detection.js +3 -11
- package/dist/es2019/utils/color-utils.js +8 -34
- package/dist/es2019/utils/custom-theme-loading-utils.js +2 -8
- package/dist/es2019/utils/generate-custom-color-ramp.js +7 -15
- package/dist/es2019/utils/get-alpha.js +7 -0
- package/dist/es2019/utils/get-closest-color-index.js +14 -0
- package/dist/es2019/utils/get-css-custom-property.js +23 -0
- package/dist/es2019/utils/get-fully-qualified-token-id.js +11 -0
- package/dist/es2019/utils/get-theme-override-preferences.js +4 -0
- package/dist/es2019/utils/get-theme-preferences.js +1 -4
- package/dist/es2019/utils/get-token-id.js +18 -0
- package/dist/es2019/utils/hct-color-utils/argb-from-rgb.js +6 -0
- package/dist/es2019/utils/hct-color-utils/clamp-double.js +14 -0
- package/dist/es2019/utils/hct-color-utils/clamp-int.js +14 -0
- package/dist/es2019/utils/hct-color-utils/color-utils.js +7 -45
- package/dist/es2019/utils/hct-color-utils/delinearized.js +20 -0
- package/dist/es2019/utils/hct-color-utils/hct.js +3 -76
- package/dist/es2019/utils/hct-color-utils/lerp.js +8 -0
- package/dist/es2019/utils/hct-color-utils/linearized.js +16 -0
- package/dist/es2019/utils/hct-color-utils/math-utils.js +6 -105
- package/dist/es2019/utils/hct-color-utils/matrix-multiply.js +9 -0
- package/dist/es2019/utils/hct-color-utils/sanitize-degrees-double.js +13 -0
- package/dist/es2019/utils/hct-color-utils/signum.js +14 -0
- package/dist/es2019/utils/hct-color-utils/viewing-conditions.js +78 -0
- package/dist/es2019/utils/hex-to-rgba-values.js +9 -0
- package/dist/es2019/utils/hsl-to-rgb.js +8 -0
- package/dist/es2019/utils/is-valid-brand-hex.js +1 -0
- package/dist/es2019/utils/limit-size-of-custom-style-elements.js +8 -0
- package/dist/es2019/utils/load-theme-css.js +7 -0
- package/dist/es2019/utils/relative-luminance-w3-c.js +12 -0
- package/dist/es2019/utils/rgb-to-hex.js +3 -0
- package/dist/es2019/utils/theme-loading.js +3 -8
- package/dist/es2019/utils/token-ids.js +3 -54
- package/dist/esm/artifacts/replacement-mapping.js +5 -2
- package/dist/esm/artifacts/tokens-raw/atlassian-motion.js +3 -3
- package/dist/esm/custom-theme.js +4 -58
- package/dist/esm/entry-points/token-metadata.codegen.js +1 -10
- package/dist/esm/get-custom-theme-styles.js +52 -0
- package/dist/esm/get-global-theme.js +1 -1
- package/dist/esm/get-theme-html-attrs.js +1 -1
- package/dist/esm/get-theme-styles.js +4 -3
- package/dist/esm/load-custom-theme-styles.js +1 -1
- package/dist/esm/set-global-theme.js +3 -2
- package/dist/esm/theme-color-modes.js +7 -0
- package/dist/esm/theme-config.js +6 -17
- package/dist/esm/theme-ids.js +7 -0
- package/dist/esm/theme-state-transformer.js +1 -1
- package/dist/esm/utils/color-detection.js +3 -11
- package/dist/esm/utils/color-utils.js +8 -40
- package/dist/esm/utils/custom-theme-loading-utils.js +2 -11
- package/dist/esm/utils/generate-custom-color-ramp.js +7 -15
- package/dist/esm/utils/get-alpha.js +7 -0
- package/dist/esm/utils/get-closest-color-index.js +14 -0
- package/dist/esm/utils/get-css-custom-property.js +26 -0
- package/dist/esm/utils/get-fully-qualified-token-id.js +13 -0
- package/dist/esm/utils/get-theme-override-preferences.js +5 -0
- package/dist/esm/utils/get-theme-preferences.js +1 -4
- package/dist/esm/utils/get-token-id.js +20 -0
- package/dist/esm/utils/hct-color-utils/argb-from-rgb.js +6 -0
- package/dist/esm/utils/hct-color-utils/clamp-double.js +14 -0
- package/dist/esm/utils/hct-color-utils/clamp-int.js +14 -0
- package/dist/esm/utils/hct-color-utils/color-utils.js +7 -45
- package/dist/esm/utils/hct-color-utils/delinearized.js +20 -0
- package/dist/esm/utils/hct-color-utils/hct.js +5 -87
- package/dist/esm/utils/hct-color-utils/lerp.js +8 -0
- package/dist/esm/utils/hct-color-utils/linearized.js +16 -0
- package/dist/esm/utils/hct-color-utils/math-utils.js +6 -105
- package/dist/esm/utils/hct-color-utils/matrix-multiply.js +9 -0
- package/dist/esm/utils/hct-color-utils/sanitize-degrees-double.js +13 -0
- package/dist/esm/utils/hct-color-utils/signum.js +14 -0
- package/dist/esm/utils/hct-color-utils/viewing-conditions.js +89 -0
- package/dist/esm/utils/hex-to-rgba-values.js +9 -0
- package/dist/esm/utils/hsl-to-rgb.js +12 -0
- package/dist/esm/utils/is-valid-brand-hex.js +3 -0
- package/dist/esm/utils/limit-size-of-custom-style-elements.js +10 -0
- package/dist/esm/utils/load-theme-css.js +25 -0
- package/dist/esm/utils/relative-luminance-w3-c.js +12 -0
- package/dist/esm/utils/rgb-to-hex.js +3 -0
- package/dist/esm/utils/theme-loading.js +3 -24
- package/dist/esm/utils/token-ids.js +3 -61
- package/dist/types/artifacts/replacement-mapping.d.ts +1 -1
- package/dist/types/artifacts/tokens-raw/atlassian-motion.d.ts +1 -1
- package/dist/types/artifacts/types-internal.d.ts +2 -2
- package/dist/types/artifacts/types.d.ts +2 -2
- package/dist/types/custom-theme.d.ts +1 -20
- package/dist/types/entry-points/token-metadata.codegen.d.ts +1 -1
- package/dist/types/get-custom-theme-styles.d.ts +16 -0
- package/dist/types/get-global-theme.d.ts +1 -1
- package/dist/types/theme-color-modes.d.ts +7 -0
- package/dist/types/theme-config.d.ts +4 -14
- package/dist/types/theme-ids.d.ts +7 -0
- package/dist/types/theme-state-transformer.d.ts +1 -1
- package/dist/types/utils/color-detection.d.ts +1 -6
- package/dist/types/utils/color-utils.d.ts +5 -5
- package/dist/types/utils/custom-theme-loading-utils.d.ts +1 -2
- package/dist/types/utils/generate-custom-color-ramp.d.ts +1 -2
- package/dist/types/utils/get-alpha.d.ts +1 -0
- package/dist/types/utils/get-closest-color-index.d.ts +2 -0
- package/dist/types/utils/get-css-custom-property.d.ts +15 -0
- package/dist/types/utils/get-fully-qualified-token-id.d.ts +11 -0
- package/dist/types/utils/get-theme-override-preferences.d.ts +2 -0
- package/dist/types/utils/get-theme-preferences.d.ts +1 -1
- package/dist/types/utils/get-token-id.d.ts +15 -0
- package/dist/types/utils/hct-color-utils/argb-from-rgb.d.ts +4 -0
- package/dist/types/utils/hct-color-utils/clamp-double.d.ts +7 -0
- package/dist/types/utils/hct-color-utils/clamp-int.d.ts +7 -0
- package/dist/types/utils/hct-color-utils/color-utils.d.ts +3 -23
- package/dist/types/utils/hct-color-utils/delinearized.d.ts +9 -0
- package/dist/types/utils/hct-color-utils/hct.d.ts +3 -48
- package/dist/types/utils/hct-color-utils/lerp.d.ts +6 -0
- package/dist/types/utils/hct-color-utils/linearized.d.ts +9 -0
- package/dist/types/utils/hct-color-utils/math-utils.d.ts +6 -60
- package/dist/types/utils/hct-color-utils/matrix-multiply.d.ts +4 -0
- package/dist/types/utils/hct-color-utils/sanitize-degrees-double.d.ts +7 -0
- package/dist/types/utils/hct-color-utils/signum.d.ts +6 -0
- package/dist/types/utils/hct-color-utils/viewing-conditions.d.ts +47 -0
- package/dist/types/utils/hex-to-rgba-values.d.ts +6 -0
- package/dist/types/utils/hsl-to-rgb.d.ts +1 -0
- package/dist/types/utils/is-valid-brand-hex.d.ts +1 -0
- package/dist/types/utils/limit-size-of-custom-style-elements.d.ts +1 -0
- package/dist/types/utils/load-theme-css.d.ts +2 -0
- package/dist/types/utils/relative-luminance-w3-c.d.ts +1 -0
- package/dist/types/utils/rgb-to-hex.d.ts +1 -0
- package/dist/types/utils/theme-loading.d.ts +1 -1
- package/dist/types/utils/token-ids.d.ts +3 -41
- package/dist/types-ts4.5/artifacts/replacement-mapping.d.ts +1 -1
- package/dist/types-ts4.5/artifacts/tokens-raw/atlassian-motion.d.ts +1 -1
- package/dist/types-ts4.5/artifacts/types-internal.d.ts +2 -2
- package/dist/types-ts4.5/artifacts/types.d.ts +2 -2
- package/dist/types-ts4.5/custom-theme.d.ts +1 -20
- package/dist/types-ts4.5/entry-points/token-metadata.codegen.d.ts +1 -1
- package/dist/types-ts4.5/get-custom-theme-styles.d.ts +16 -0
- package/dist/types-ts4.5/get-global-theme.d.ts +1 -1
- package/dist/types-ts4.5/theme-color-modes.d.ts +11 -0
- package/dist/types-ts4.5/theme-config.d.ts +4 -29
- package/dist/types-ts4.5/theme-ids.d.ts +18 -0
- package/dist/types-ts4.5/theme-state-transformer.d.ts +1 -1
- package/dist/types-ts4.5/utils/color-detection.d.ts +1 -6
- package/dist/types-ts4.5/utils/color-utils.d.ts +5 -9
- package/dist/types-ts4.5/utils/custom-theme-loading-utils.d.ts +1 -2
- package/dist/types-ts4.5/utils/generate-custom-color-ramp.d.ts +1 -2
- package/dist/types-ts4.5/utils/get-alpha.d.ts +1 -0
- package/dist/types-ts4.5/utils/get-closest-color-index.d.ts +2 -0
- package/dist/types-ts4.5/utils/get-css-custom-property.d.ts +15 -0
- package/dist/types-ts4.5/utils/get-fully-qualified-token-id.d.ts +11 -0
- package/dist/types-ts4.5/utils/get-theme-override-preferences.d.ts +2 -0
- package/dist/types-ts4.5/utils/get-theme-preferences.d.ts +1 -1
- package/dist/types-ts4.5/utils/get-token-id.d.ts +15 -0
- package/dist/types-ts4.5/utils/hct-color-utils/argb-from-rgb.d.ts +4 -0
- package/dist/types-ts4.5/utils/hct-color-utils/clamp-double.d.ts +7 -0
- package/dist/types-ts4.5/utils/hct-color-utils/clamp-int.d.ts +7 -0
- package/dist/types-ts4.5/utils/hct-color-utils/color-utils.d.ts +3 -23
- package/dist/types-ts4.5/utils/hct-color-utils/delinearized.d.ts +9 -0
- package/dist/types-ts4.5/utils/hct-color-utils/hct.d.ts +3 -48
- package/dist/types-ts4.5/utils/hct-color-utils/lerp.d.ts +6 -0
- package/dist/types-ts4.5/utils/hct-color-utils/linearized.d.ts +9 -0
- package/dist/types-ts4.5/utils/hct-color-utils/math-utils.d.ts +6 -60
- package/dist/types-ts4.5/utils/hct-color-utils/matrix-multiply.d.ts +4 -0
- package/dist/types-ts4.5/utils/hct-color-utils/sanitize-degrees-double.d.ts +7 -0
- package/dist/types-ts4.5/utils/hct-color-utils/signum.d.ts +6 -0
- package/dist/types-ts4.5/utils/hct-color-utils/viewing-conditions.d.ts +47 -0
- package/dist/types-ts4.5/utils/hex-to-rgba-values.d.ts +6 -0
- package/dist/types-ts4.5/utils/hsl-to-rgb.d.ts +5 -0
- package/dist/types-ts4.5/utils/is-valid-brand-hex.d.ts +1 -0
- package/dist/types-ts4.5/utils/limit-size-of-custom-style-elements.d.ts +1 -0
- package/dist/types-ts4.5/utils/load-theme-css.d.ts +2 -0
- package/dist/types-ts4.5/utils/relative-luminance-w3-c.d.ts +1 -0
- package/dist/types-ts4.5/utils/rgb-to-hex.d.ts +1 -0
- package/dist/types-ts4.5/utils/theme-loading.d.ts +1 -1
- package/dist/types-ts4.5/utils/token-ids.d.ts +3 -41
- package/package.json +4 -4
|
@@ -1,105 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* @license
|
|
8
|
-
* Copyright 2021 Google LLC
|
|
9
|
-
*
|
|
10
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
11
|
-
* you may not use this file except in compliance with the License.
|
|
12
|
-
* You may obtain a copy of the License at
|
|
13
|
-
*
|
|
14
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
15
|
-
*
|
|
16
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
17
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19
|
-
* See the License for the specific language governing permissions and
|
|
20
|
-
* limitations under the License.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
// This file is automatically generated. Do not modify it.
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Utility methods for mathematical operations.
|
|
27
|
-
*/
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* The signum function.
|
|
31
|
-
*
|
|
32
|
-
* @return 1 if num > 0, -1 if num < 0, and 0 if num = 0
|
|
33
|
-
*/
|
|
34
|
-
export function signum(num) {
|
|
35
|
-
if (num < 0) {
|
|
36
|
-
return -1;
|
|
37
|
-
} else if (num === 0) {
|
|
38
|
-
return 0;
|
|
39
|
-
} else {
|
|
40
|
-
return 1;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* The linear interpolation function.
|
|
46
|
-
*
|
|
47
|
-
* @return start if amount = 0 and stop if amount = 1
|
|
48
|
-
*/
|
|
49
|
-
export function lerp(start, stop, amount) {
|
|
50
|
-
return (1.0 - amount) * start + amount * stop;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Clamps an integer between two integers.
|
|
55
|
-
*
|
|
56
|
-
* @return input when min <= input <= max, and either min or max
|
|
57
|
-
* otherwise.
|
|
58
|
-
*/
|
|
59
|
-
export function clampInt(min, max, input) {
|
|
60
|
-
if (input < min) {
|
|
61
|
-
return min;
|
|
62
|
-
} else if (input > max) {
|
|
63
|
-
return max;
|
|
64
|
-
}
|
|
65
|
-
return input;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Clamps an integer between two floating-point numbers.
|
|
70
|
-
*
|
|
71
|
-
* @return input when min <= input <= max, and either min or max
|
|
72
|
-
* otherwise.
|
|
73
|
-
*/
|
|
74
|
-
export function clampDouble(min, max, input) {
|
|
75
|
-
if (input < min) {
|
|
76
|
-
return min;
|
|
77
|
-
} else if (input > max) {
|
|
78
|
-
return max;
|
|
79
|
-
}
|
|
80
|
-
return input;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Sanitizes a degree measure as a floating-point number.
|
|
85
|
-
*
|
|
86
|
-
* @return a degree measure between 0.0 (inclusive) and 360.0
|
|
87
|
-
* (exclusive).
|
|
88
|
-
*/
|
|
89
|
-
export function sanitizeDegreesDouble(degrees) {
|
|
90
|
-
degrees = degrees % 360.0;
|
|
91
|
-
if (degrees < 0) {
|
|
92
|
-
degrees = degrees + 360.0;
|
|
93
|
-
}
|
|
94
|
-
return degrees;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Multiplies a 1x3 row vector with a 3x3 matrix.
|
|
99
|
-
*/
|
|
100
|
-
export function matrixMultiply(row, matrix) {
|
|
101
|
-
const a = row[0] * matrix[0][0] + row[1] * matrix[0][1] + row[2] * matrix[0][2];
|
|
102
|
-
const b = row[0] * matrix[1][0] + row[1] * matrix[1][1] + row[2] * matrix[1][2];
|
|
103
|
-
const c = row[0] * matrix[2][0] + row[1] * matrix[2][1] + row[2] * matrix[2][2];
|
|
104
|
-
return [a, b, c];
|
|
105
|
-
}
|
|
1
|
+
export { signum } from './signum';
|
|
2
|
+
export { lerp } from './lerp';
|
|
3
|
+
export { clampInt } from './clamp-int';
|
|
4
|
+
export { clampDouble } from './clamp-double';
|
|
5
|
+
export { sanitizeDegreesDouble } from './sanitize-degrees-double';
|
|
6
|
+
export { matrixMultiply } from './matrix-multiply';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Multiplies a 1x3 row vector with a 3x3 matrix.
|
|
3
|
+
*/
|
|
4
|
+
export function matrixMultiply(row, matrix) {
|
|
5
|
+
const a = row[0] * matrix[0][0] + row[1] * matrix[0][1] + row[2] * matrix[0][2];
|
|
6
|
+
const b = row[0] * matrix[1][0] + row[1] * matrix[1][1] + row[2] * matrix[1][2];
|
|
7
|
+
const c = row[0] * matrix[2][0] + row[1] * matrix[2][1] + row[2] * matrix[2][2];
|
|
8
|
+
return [a, b, c];
|
|
9
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sanitizes a degree measure as a floating-point number.
|
|
3
|
+
*
|
|
4
|
+
* @return a degree measure between 0.0 (inclusive) and 360.0
|
|
5
|
+
* (exclusive).
|
|
6
|
+
*/
|
|
7
|
+
export function sanitizeDegreesDouble(degrees) {
|
|
8
|
+
degrees = degrees % 360.0;
|
|
9
|
+
if (degrees < 0) {
|
|
10
|
+
degrees = degrees + 360.0;
|
|
11
|
+
}
|
|
12
|
+
return degrees;
|
|
13
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
var _ViewingConditions;
|
|
3
|
+
import * as utils from './color-utils';
|
|
4
|
+
import * as math from './math-utils';
|
|
5
|
+
export class ViewingConditions {
|
|
6
|
+
/**
|
|
7
|
+
* Create ViewingConditions from a simple, physically relevant, set of
|
|
8
|
+
* parameters.
|
|
9
|
+
*
|
|
10
|
+
* @param whitePoint White point, measured in the XYZ color space.
|
|
11
|
+
* default = D65, or sunny day afternoon
|
|
12
|
+
* @param adaptingLuminance The luminance of the adapting field. Informally,
|
|
13
|
+
* how bright it is in the room where the color is viewed. Can be
|
|
14
|
+
* calculated from lux by multiplying lux by 0.0586. default = 11.72,
|
|
15
|
+
* or 200 lux.
|
|
16
|
+
* @param backgroundLstar The lightness of the area surrounding the color.
|
|
17
|
+
* measured by L* in L*a*b*. default = 50.0
|
|
18
|
+
* @param surround A general description of the lighting surrounding the
|
|
19
|
+
* color. 0 is pitch dark, like watching a movie in a theater. 1.0 is a
|
|
20
|
+
* dimly light room, like watching TV at home at night. 2.0 means there
|
|
21
|
+
* is no difference between the lighting on the color and around it.
|
|
22
|
+
* default = 2.0
|
|
23
|
+
* @param discountingIlluminant Whether the eye accounts for the tint of the
|
|
24
|
+
* ambient lighting, such as knowing an apple is still red in green light.
|
|
25
|
+
* default = false, the eye does not perform this process on
|
|
26
|
+
* self-luminous objects like displays.
|
|
27
|
+
*/
|
|
28
|
+
static make(whitePoint = utils.whitePointD65(), adaptingLuminance = 200.0 / Math.PI * utils.yFromLstar(50.0) / 100.0, backgroundLstar = 50.0, surround = 2.0, discountingIlluminant = false) {
|
|
29
|
+
const xyz = whitePoint;
|
|
30
|
+
const rW = xyz[0] * 0.401288 + xyz[1] * 0.650173 + xyz[2] * -0.051461;
|
|
31
|
+
const gW = xyz[0] * -0.250268 + xyz[1] * 1.204414 + xyz[2] * 0.045854;
|
|
32
|
+
const bW = xyz[0] * -0.002079 + xyz[1] * 0.048952 + xyz[2] * 0.953127;
|
|
33
|
+
const f = 0.8 + surround / 10.0;
|
|
34
|
+
const c = f >= 0.9 ? math.lerp(0.59, 0.69, (f - 0.9) * 10.0) : math.lerp(0.525, 0.59, (f - 0.8) * 10.0);
|
|
35
|
+
let d = discountingIlluminant ? 1.0 : f * (1.0 - 1.0 / 3.6 * Math.exp((-adaptingLuminance - 42.0) / 92.0));
|
|
36
|
+
d = d > 1.0 ? 1.0 : d < 0.0 ? 0.0 : d;
|
|
37
|
+
const nc = f;
|
|
38
|
+
const rgbD = [d * (100.0 / rW) + 1.0 - d, d * (100.0 / gW) + 1.0 - d, d * (100.0 / bW) + 1.0 - d];
|
|
39
|
+
const k = 1.0 / (5.0 * adaptingLuminance + 1.0);
|
|
40
|
+
const k4 = k * k * k * k;
|
|
41
|
+
const k4F = 1.0 - k4;
|
|
42
|
+
const fl = k4 * adaptingLuminance + 0.1 * k4F * k4F * Math.cbrt(5.0 * adaptingLuminance);
|
|
43
|
+
const n = utils.yFromLstar(backgroundLstar) / whitePoint[1];
|
|
44
|
+
const z = 1.48 + Math.sqrt(n);
|
|
45
|
+
const nbb = 0.725 / Math.pow(n, 0.2);
|
|
46
|
+
const ncb = nbb;
|
|
47
|
+
const rgbAFactors = [Math.pow(fl * rgbD[0] * rW / 100.0, 0.42), Math.pow(fl * rgbD[1] * gW / 100.0, 0.42), Math.pow(fl * rgbD[2] * bW / 100.0, 0.42)];
|
|
48
|
+
const rgbA = [400.0 * rgbAFactors[0] / (rgbAFactors[0] + 27.13), 400.0 * rgbAFactors[1] / (rgbAFactors[1] + 27.13), 400.0 * rgbAFactors[2] / (rgbAFactors[2] + 27.13)];
|
|
49
|
+
const aw = (2.0 * rgbA[0] + rgbA[1] + 0.05 * rgbA[2]) * nbb;
|
|
50
|
+
return new ViewingConditions(n, aw, nbb, ncb, c, nc, rgbD, fl, Math.pow(fl, 0.25), z);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Parameters are intermediate values of the CAM16 conversion process. Their
|
|
55
|
+
* names are shorthand for technical color science terminology, this class
|
|
56
|
+
* would not benefit from documenting them individually. A brief overview
|
|
57
|
+
* is available in the CAM16 specification, and a complete overview requires
|
|
58
|
+
* a color science textbook, such as Fairchild's Color Appearance Models.
|
|
59
|
+
*/
|
|
60
|
+
|
|
61
|
+
constructor(n, aw, nbb, ncb, c, nc, rgbD, fl, fLRoot, z) {
|
|
62
|
+
this.n = n;
|
|
63
|
+
this.aw = aw;
|
|
64
|
+
this.nbb = nbb;
|
|
65
|
+
this.ncb = ncb;
|
|
66
|
+
this.c = c;
|
|
67
|
+
this.nc = nc;
|
|
68
|
+
this.rgbD = rgbD;
|
|
69
|
+
this.fl = fl;
|
|
70
|
+
this.fLRoot = fLRoot;
|
|
71
|
+
this.z = z;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
_ViewingConditions = ViewingConditions;
|
|
75
|
+
/**
|
|
76
|
+
* sRGB-like viewing conditions.
|
|
77
|
+
*/
|
|
78
|
+
_defineProperty(ViewingConditions, "DEFAULT", _ViewingConditions.make());
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const hexToRGBAValues = hex => {
|
|
2
|
+
const hexColor = hex.replace('#', '');
|
|
3
|
+
return {
|
|
4
|
+
r: parseInt(hexColor.slice(0, 2), 16),
|
|
5
|
+
g: parseInt(hexColor.slice(2, 4), 16),
|
|
6
|
+
b: parseInt(hexColor.slice(4, 6), 16),
|
|
7
|
+
a: parseFloat((parseInt(hexColor.slice(6, 8), 16) / 255).toFixed(2))
|
|
8
|
+
};
|
|
9
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const isValidBrandHex = hex => /^#[0-9A-F]{6}$/i.test(hex);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CUSTOM_THEME_ATTRIBUTE, THEME_DATA_ATTRIBUTE } from '../constants';
|
|
2
|
+
export function limitSizeOfCustomStyleElements(sizeThreshold) {
|
|
3
|
+
const styleTags = Array.from(document.head.querySelectorAll(`style[${CUSTOM_THEME_ATTRIBUTE}][${THEME_DATA_ATTRIBUTE}]`));
|
|
4
|
+
if (styleTags.length < sizeThreshold) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
styleTags.slice(0, styleTags.length - (sizeThreshold - 1)).forEach(element => element.remove());
|
|
8
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export function relativeLuminanceW3C(r, g, b) {
|
|
2
|
+
const RsRGB = r / 255;
|
|
3
|
+
const GsRGB = g / 255;
|
|
4
|
+
const BsRGB = b / 255;
|
|
5
|
+
const R = RsRGB <= 0.03928 ? RsRGB / 12.92 : Math.pow((RsRGB + 0.055) / 1.055, 2.4);
|
|
6
|
+
const G = GsRGB <= 0.03928 ? GsRGB / 12.92 : Math.pow((GsRGB + 0.055) / 1.055, 2.4);
|
|
7
|
+
const B = BsRGB <= 0.03928 ? BsRGB / 12.92 : Math.pow((BsRGB + 0.055) / 1.055, 2.4);
|
|
8
|
+
|
|
9
|
+
// For the sRGB colorspace, the relative luminance of a color is defined as:
|
|
10
|
+
const L = 0.2126 * R + 0.7152 * G + 0.0722 * B;
|
|
11
|
+
return L;
|
|
12
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import themeImportMap from '../artifacts/theme-import-map';
|
|
2
1
|
import { CUSTOM_THEME_ATTRIBUTE, THEME_DATA_ATTRIBUTE } from '../constants';
|
|
2
|
+
import { loadThemeCss } from './load-theme-css';
|
|
3
3
|
export const loadAndAppendThemeCss = async themeId => {
|
|
4
4
|
if (document.head.querySelector(`style[${THEME_DATA_ATTRIBUTE}="${themeId}"]:not([${CUSTOM_THEME_ATTRIBUTE}])`)) {
|
|
5
5
|
return;
|
|
@@ -16,11 +16,6 @@ export const loadAndAppendThemeCss = async themeId => {
|
|
|
16
16
|
style.dataset.theme = themeId;
|
|
17
17
|
document.head.appendChild(style);
|
|
18
18
|
};
|
|
19
|
-
export const loadThemeCss = async themeId => {
|
|
20
|
-
const {
|
|
21
|
-
default: themeCss
|
|
22
|
-
} = await themeImportMap[themeId]();
|
|
23
|
-
return themeCss;
|
|
24
|
-
};
|
|
25
19
|
export const darkModeMediaQuery = '(prefers-color-scheme: dark)';
|
|
26
|
-
export const moreContrastMediaQuery = '(prefers-contrast: more)';
|
|
20
|
+
export const moreContrastMediaQuery = '(prefers-contrast: more)';
|
|
21
|
+
export { loadThemeCss } from './load-theme-css';
|
|
@@ -1,54 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* Transforms a style dictionary token path to a CSS custom property.
|
|
5
|
-
*
|
|
6
|
-
* A css prefix will be prepended and all [default] key words will be omitted
|
|
7
|
-
* from the path
|
|
8
|
-
*
|
|
9
|
-
* @example <caption>Passing a path as an array</caption>
|
|
10
|
-
* // Returns ds-background-bold
|
|
11
|
-
* getCSSCustomProperty(['color', 'background', 'bold', '[default]'])
|
|
12
|
-
*
|
|
13
|
-
* @example <caption>Passing a path as a string</caption>
|
|
14
|
-
* // Returns ds-background-bold
|
|
15
|
-
* getCSSCustomProperty('color.background.bold.[default]')
|
|
16
|
-
*/
|
|
17
|
-
export const getCSSCustomProperty = path => {
|
|
18
|
-
const normalizedPath = typeof path === 'string' ? path.split('.') : path;
|
|
19
|
-
|
|
20
|
-
// Opacity and other 'shallow' groups are more readable when not trimmed
|
|
21
|
-
const slice = CSS_VAR_FULL.includes(normalizedPath[0]) ? 0 : 1;
|
|
22
|
-
return `--${[CSS_PREFIX, ...normalizedPath.slice(slice)].filter(el => el !== '[default]').join('-')}`;
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Transforms a style dictionary token path to a shorthand token id
|
|
27
|
-
* These ids will be typically be how tokens are interacted with via typescript and css
|
|
28
|
-
*
|
|
29
|
-
* All [default] key words will be omitted from the path
|
|
30
|
-
*
|
|
31
|
-
* @example <caption>Passing a path as an array</caption>
|
|
32
|
-
* // Returns color.background.bold
|
|
33
|
-
* getTokenId(['color', 'background', 'bold', '[default]'])
|
|
34
|
-
*
|
|
35
|
-
* @example <caption>Passing a path as a string</caption>
|
|
36
|
-
* // Returns color.background.bold
|
|
37
|
-
* getTokenId('color.background.bold.[default]')
|
|
38
|
-
*/
|
|
39
|
-
export const getTokenId = path => {
|
|
40
|
-
const normalizedPath = typeof path === 'string' ? path.split('.') : path;
|
|
41
|
-
return normalizedPath.filter(el => el !== '[default]').join('.');
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Transforms a style dictionary token path to a fully qualified token id
|
|
46
|
-
* These Ids are intended to be used internal to this package by style-dictionary
|
|
47
|
-
*
|
|
48
|
-
* [default] key words will NOT be omitted from the path
|
|
49
|
-
*
|
|
50
|
-
* @example <caption>Passing a path as a string</caption>
|
|
51
|
-
* // Returns color.background.bold.[default]
|
|
52
|
-
* getFullyQualifiedTokenId(['color', 'background', 'bold', '[default]'])
|
|
53
|
-
*/
|
|
54
|
-
export const getFullyQualifiedTokenId = path => path.join('.');
|
|
1
|
+
export { getCSSCustomProperty } from './get-css-custom-property';
|
|
2
|
+
export { getTokenId } from './get-token-id';
|
|
3
|
+
export { getFullyQualifiedTokenId } from './get-fully-qualified-token-id';
|
|
@@ -12,9 +12,12 @@
|
|
|
12
12
|
* These changes will then be picked up by our tooling which will attempt to
|
|
13
13
|
* migrate as many of these renames as possible.
|
|
14
14
|
*
|
|
15
|
-
* @codegen <<SignedSource::
|
|
15
|
+
* @codegen <<SignedSource::047b57f2d22a7675431a9f6acb147bf6>>
|
|
16
16
|
* @codegenCommand yarn build tokens
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
|
-
var replacementMapper = [
|
|
19
|
+
var replacementMapper = [{
|
|
20
|
+
"path": "motion.easing.spring",
|
|
21
|
+
"state": "experimental"
|
|
22
|
+
}];
|
|
20
23
|
export default replacementMapper;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::33ce7f44e704e6b32332ffdfac5776e4>>
|
|
4
4
|
* @codegenCommand yarn build tokens
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -421,7 +421,7 @@ var tokens = [{
|
|
|
421
421
|
}, {
|
|
422
422
|
"attributes": {
|
|
423
423
|
"group": "motionEasing",
|
|
424
|
-
"state": "
|
|
424
|
+
"state": "experimental",
|
|
425
425
|
"introduced": "11.5.0",
|
|
426
426
|
"description": "A spring curve that overshoots slightly before settling. Use for playful, tactile feedback on small branded elements such as avatar hover, where the slight overshoot reinforces a sense of life."
|
|
427
427
|
},
|
|
@@ -431,7 +431,7 @@ var tokens = [{
|
|
|
431
431
|
"original": {
|
|
432
432
|
"attributes": {
|
|
433
433
|
"group": "motionEasing",
|
|
434
|
-
"state": "
|
|
434
|
+
"state": "experimental",
|
|
435
435
|
"introduced": "11.5.0",
|
|
436
436
|
"description": "A spring curve that overshoots slightly before settling. Use for playful, tactile feedback on small branded elements such as avatar hover, where the slight overshoot reinforces a sense of life."
|
|
437
437
|
},
|
package/dist/esm/custom-theme.js
CHANGED
|
@@ -1,61 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { limitSizeOfCustomStyleElements, reduceTokenMap } from './utils/custom-theme-loading-utils';
|
|
4
|
-
import { generateColors, generateTokenMapWithContrastCheck } from './utils/generate-custom-color-ramp';
|
|
5
|
-
import { hash } from './utils/hash';
|
|
1
|
+
import { getCustomThemeStyles } from './get-custom-theme-styles';
|
|
2
|
+
import { limitSizeOfCustomStyleElements } from './utils/limit-size-of-custom-style-elements';
|
|
6
3
|
export var CUSTOM_STYLE_ELEMENTS_SIZE_THRESHOLD = 10;
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
*
|
|
10
|
-
* @param themeSchema The schema of available themes
|
|
11
|
-
* @returns a string with the CSS for the custom theme
|
|
12
|
-
*/
|
|
13
|
-
/**
|
|
14
|
-
* Takes a color mode and custom branding options, and returns an array of objects for use in applying custom styles to the document head.
|
|
15
|
-
* Only supplies the color themes necessary for initial render, based on the current themeState. I.e. if in light mode, dark mode themes are not returned.
|
|
16
|
-
*
|
|
17
|
-
* @param {Object<string, string>} themeState The themes and color mode that should be applied.
|
|
18
|
-
* @param {string} themeState.colorMode Determines which color theme is applied
|
|
19
|
-
* @param {Object} themeState.UNSAFE_themeOptions The custom branding options to be used for custom theme generation
|
|
20
|
-
*
|
|
21
|
-
* @returns An object array, containing theme IDs, data-attributes to attach to the theme, and the theme CSS.
|
|
22
|
-
* If an error is encountered while loading themes, the themes array will be empty.
|
|
23
|
-
*/
|
|
24
|
-
export function getCustomThemeStyles(themeState) {
|
|
25
|
-
var _themeState$UNSAFE_th;
|
|
26
|
-
var brandColor = themeState === null || themeState === void 0 || (_themeState$UNSAFE_th = themeState.UNSAFE_themeOptions) === null || _themeState$UNSAFE_th === void 0 ? void 0 : _themeState$UNSAFE_th.brandColor;
|
|
27
|
-
var mode = (themeState === null || themeState === void 0 ? void 0 : themeState.colorMode) || themeStateDefaults['colorMode'];
|
|
28
|
-
var optionString = JSON.stringify(themeState === null || themeState === void 0 ? void 0 : themeState.UNSAFE_themeOptions);
|
|
29
|
-
var uniqueId = hash(optionString);
|
|
30
|
-
var themeRamp = generateColors(brandColor).ramp;
|
|
31
|
-
|
|
32
|
-
// outputs object to generate to CSS from
|
|
33
|
-
var themes = [];
|
|
34
|
-
var tokenMaps = generateTokenMapWithContrastCheck(brandColor, mode, themeRamp);
|
|
35
|
-
if ((mode === 'light' || mode === 'auto') && tokenMaps.light) {
|
|
36
|
-
// Light mode theming
|
|
37
|
-
themes.push({
|
|
38
|
-
id: 'light',
|
|
39
|
-
attrs: {
|
|
40
|
-
'data-theme': 'light',
|
|
41
|
-
'data-custom-theme': uniqueId
|
|
42
|
-
},
|
|
43
|
-
css: "\nhtml[".concat(CUSTOM_THEME_ATTRIBUTE, "=\"").concat(uniqueId, "\"][").concat(COLOR_MODE_ATTRIBUTE, "=\"light\"][data-theme~=\"light:light\"] {\n /* Branded tokens */\n ").concat(reduceTokenMap(tokenMaps.light, themeRamp), "\n}")
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
if ((mode === 'dark' || mode === 'auto') && tokenMaps.dark) {
|
|
47
|
-
// Dark mode theming
|
|
48
|
-
themes.push({
|
|
49
|
-
id: 'dark',
|
|
50
|
-
attrs: {
|
|
51
|
-
'data-theme': 'dark',
|
|
52
|
-
'data-custom-theme': uniqueId
|
|
53
|
-
},
|
|
54
|
-
css: "\nhtml[".concat(CUSTOM_THEME_ATTRIBUTE, "=\"").concat(uniqueId, "\"][").concat(COLOR_MODE_ATTRIBUTE, "=\"dark\"][data-theme~=\"dark:dark\"] {\n /* Branded tokens */\n ").concat(reduceTokenMap(tokenMaps.dark, themeRamp), "\n}")
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
return themes;
|
|
58
|
-
}
|
|
59
4
|
export function loadAndAppendCustomThemeCss(themeState) {
|
|
60
5
|
var themes = getCustomThemeStyles(themeState);
|
|
61
6
|
limitSizeOfCustomStyleElements(CUSTOM_STYLE_ELEMENTS_SIZE_THRESHOLD);
|
|
@@ -66,4 +11,5 @@ export function loadAndAppendCustomThemeCss(themeState) {
|
|
|
66
11
|
styleTag.dataset.customTheme = theme.attrs['data-custom-theme'];
|
|
67
12
|
styleTag.textContent = theme.css;
|
|
68
13
|
});
|
|
69
|
-
}
|
|
14
|
+
}
|
|
15
|
+
export { getCustomThemeStyles } from './get-custom-theme-styles';
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Metadata for generation of `@atlaskit/ads-mcp` and https://atlassian.design/llms-tokens.txt.
|
|
5
5
|
*
|
|
6
|
-
* @codegen <<SignedSource::
|
|
6
|
+
* @codegen <<SignedSource::8a97395137b2eee0fedb0ac95a7a2528>>
|
|
7
7
|
* @codegenCommand yarn build tokens
|
|
8
8
|
*/
|
|
9
9
|
|
|
@@ -160,15 +160,6 @@ export var tokens = [{
|
|
|
160
160
|
usage: '',
|
|
161
161
|
cssProperties: []
|
|
162
162
|
}
|
|
163
|
-
}, {
|
|
164
|
-
name: 'motion.easing.spring',
|
|
165
|
-
path: ['motion', 'easing', 'spring'],
|
|
166
|
-
description: 'A spring curve that overshoots slightly before settling. Use for playful, tactile feedback on small branded elements such as avatar hover, where the slight overshoot reinforces a sense of life.',
|
|
167
|
-
exampleValue: 'linear(0, 0.021, 0.058, 0.107, 0.164, 0.227, 0.292, 0.359, 0.425, 0.49, 0.552, 0.61, 0.664, 0.714, 0.759, 0.8, 0.837, 0.869, 0.898, 0.922, 0.943, 0.961, 0.976, 0.988, 0.998, 1.006, 1.013, 1.017, 1.02, 1.023, 1.024, 1.024, 1.024, 1.024, 1.023, 1.022, 1.02, 1.019, 1.017, 1.015, 1.014, 1.012, 1.011, 1.009, 1.008, 1.007, 1.006, 1.005, 1.004, 1.003, 1.002, 1.002, 1.001, 1.001, 1.001, 1, 1, 1, 1, 1, 0.999, 0.999, 0.999, 0.999, 1)',
|
|
168
|
-
usageGuidelines: {
|
|
169
|
-
usage: '',
|
|
170
|
-
cssProperties: []
|
|
171
|
-
}
|
|
172
163
|
}, {
|
|
173
164
|
name: 'motion.flag.enter',
|
|
174
165
|
path: ['motion', 'flag', 'enter'],
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { COLOR_MODE_ATTRIBUTE, CUSTOM_THEME_ATTRIBUTE } from './constants';
|
|
2
|
+
import { themeStateDefaults } from './theme-config';
|
|
3
|
+
import { reduceTokenMap } from './utils/custom-theme-loading-utils';
|
|
4
|
+
import { generateColors, generateTokenMapWithContrastCheck } from './utils/generate-custom-color-ramp';
|
|
5
|
+
import { hash } from './utils/hash';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Takes a color mode and custom branding options, and returns an array of objects for use in applying custom styles to the document head.
|
|
9
|
+
* Only supplies the color themes necessary for initial render, based on the current themeState. I.e. if in light mode, dark mode themes are not returned.
|
|
10
|
+
*
|
|
11
|
+
* @param {Object<string, string>} themeState The themes and color mode that should be applied.
|
|
12
|
+
* @param {string} themeState.colorMode Determines which color theme is applied
|
|
13
|
+
* @param {Object} themeState.UNSAFE_themeOptions The custom branding options to be used for custom theme generation
|
|
14
|
+
*
|
|
15
|
+
* @returns An object array, containing theme IDs, data-attributes to attach to the theme, and the theme CSS.
|
|
16
|
+
* If an error is encountered while loading themes, the themes array will be empty.
|
|
17
|
+
*/
|
|
18
|
+
export function getCustomThemeStyles(themeState) {
|
|
19
|
+
var _themeState$UNSAFE_th;
|
|
20
|
+
var brandColor = themeState === null || themeState === void 0 || (_themeState$UNSAFE_th = themeState.UNSAFE_themeOptions) === null || _themeState$UNSAFE_th === void 0 ? void 0 : _themeState$UNSAFE_th.brandColor;
|
|
21
|
+
var mode = (themeState === null || themeState === void 0 ? void 0 : themeState.colorMode) || themeStateDefaults['colorMode'];
|
|
22
|
+
var optionString = JSON.stringify(themeState === null || themeState === void 0 ? void 0 : themeState.UNSAFE_themeOptions);
|
|
23
|
+
var uniqueId = hash(optionString);
|
|
24
|
+
var themeRamp = generateColors(brandColor).ramp;
|
|
25
|
+
|
|
26
|
+
// outputs object to generate to CSS from
|
|
27
|
+
var themes = [];
|
|
28
|
+
var tokenMaps = generateTokenMapWithContrastCheck(brandColor, mode, themeRamp);
|
|
29
|
+
if ((mode === 'light' || mode === 'auto') && tokenMaps.light) {
|
|
30
|
+
// Light mode theming
|
|
31
|
+
themes.push({
|
|
32
|
+
id: 'light',
|
|
33
|
+
attrs: {
|
|
34
|
+
'data-theme': 'light',
|
|
35
|
+
'data-custom-theme': uniqueId
|
|
36
|
+
},
|
|
37
|
+
css: "\nhtml[".concat(CUSTOM_THEME_ATTRIBUTE, "=\"").concat(uniqueId, "\"][").concat(COLOR_MODE_ATTRIBUTE, "=\"light\"][data-theme~=\"light:light\"] {\n /* Branded tokens */\n ").concat(reduceTokenMap(tokenMaps.light, themeRamp), "\n}")
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
if ((mode === 'dark' || mode === 'auto') && tokenMaps.dark) {
|
|
41
|
+
// Dark mode theming
|
|
42
|
+
themes.push({
|
|
43
|
+
id: 'dark',
|
|
44
|
+
attrs: {
|
|
45
|
+
'data-theme': 'dark',
|
|
46
|
+
'data-custom-theme': uniqueId
|
|
47
|
+
},
|
|
48
|
+
css: "\nhtml[".concat(CUSTOM_THEME_ATTRIBUTE, "=\"").concat(uniqueId, "\"][").concat(COLOR_MODE_ATTRIBUTE, "=\"dark\"][data-theme~=\"dark:dark\"] {\n /* Branded tokens */\n ").concat(reduceTokenMap(tokenMaps.dark, themeRamp), "\n}")
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
return themes;
|
|
52
|
+
}
|
|
@@ -2,7 +2,7 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
2
2
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
4
|
import { COLOR_MODE_ATTRIBUTE, THEME_DATA_ATTRIBUTE } from './constants';
|
|
5
|
-
import { themeColorModes } from './theme-
|
|
5
|
+
import { themeColorModes } from './theme-color-modes';
|
|
6
6
|
import { themeStringToObject } from './theme-state-transformer';
|
|
7
7
|
var isThemeColorMode = function isThemeColorMode(colorMode) {
|
|
8
8
|
return themeColorModes.find(function (mode) {
|
|
@@ -5,8 +5,8 @@ import { fg } from '@atlaskit/platform-feature-flags';
|
|
|
5
5
|
import { COLOR_MODE_ATTRIBUTE, CONTRAST_MODE_ATTRIBUTE, CUSTOM_THEME_ATTRIBUTE, THEME_DATA_ATTRIBUTE } from './constants';
|
|
6
6
|
import { themeStateDefaults } from './theme-config';
|
|
7
7
|
import { themeObjectToString } from './theme-state-transformer';
|
|
8
|
-
import { isValidBrandHex } from './utils/color-utils';
|
|
9
8
|
import { hash } from './utils/hash';
|
|
9
|
+
import { isValidBrandHex } from './utils/is-valid-brand-hex';
|
|
10
10
|
var defaultColorMode = 'light';
|
|
11
11
|
var defaultContrastMode = 'no-preference';
|
|
12
12
|
|
|
@@ -3,9 +3,10 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
|
3
3
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
4
4
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
5
5
|
import { themeIdsWithOverrides, themeStateDefaults } from './theme-config';
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
6
|
+
import { getThemeOverridePreferences } from './utils/get-theme-override-preferences';
|
|
7
|
+
import { getThemePreferences } from './utils/get-theme-preferences';
|
|
8
|
+
import { isValidBrandHex } from './utils/is-valid-brand-hex';
|
|
9
|
+
import { loadThemeCss } from './utils/load-theme-css';
|
|
9
10
|
/**
|
|
10
11
|
* Takes an object containing theme preferences, and returns an array of objects for use in applying styles to the document head.
|
|
11
12
|
* Only supplies the color themes necessary for initial render, based on the current themeState. I.e. if in light mode, dark mode themes are not returned.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { loadAndAppendCustomThemeCss } from './custom-theme';
|
|
2
2
|
import { themeStateDefaults } from './theme-config';
|
|
3
|
-
import { isValidBrandHex } from './utils/color-utils';
|
|
4
3
|
import { findMissingCustomStyleElements } from './utils/custom-theme-loading-utils';
|
|
4
|
+
import { isValidBrandHex } from './utils/is-valid-brand-hex';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Synchronously generates and applies custom theme styles to the page.
|
|
@@ -9,10 +9,11 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
9
9
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
10
10
|
import getGlobalTheme from './get-global-theme';
|
|
11
11
|
import { themeStateDefaults } from './theme-config';
|
|
12
|
-
import { isValidBrandHex } from './utils/color-utils';
|
|
13
12
|
import configurePage from './utils/configure-page';
|
|
14
13
|
import { findMissingCustomStyleElements } from './utils/custom-theme-loading-utils';
|
|
15
|
-
import { getThemeOverridePreferences
|
|
14
|
+
import { getThemeOverridePreferences } from './utils/get-theme-override-preferences';
|
|
15
|
+
import { getThemePreferences } from './utils/get-theme-preferences';
|
|
16
|
+
import { isValidBrandHex } from './utils/is-valid-brand-hex';
|
|
16
17
|
import { loadAndAppendThemeCss } from './utils/theme-loading';
|
|
17
18
|
|
|
18
19
|
/**
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme modes: The general purpose of a theme.
|
|
3
|
+
* This attr is used to apply the appropriate system-preference option
|
|
4
|
+
* It may also be used as a selector for mode-specific overrides such as light/dark images.
|
|
5
|
+
* The idea is there may exist many color themes, but every theme must either fit into light or dark.
|
|
6
|
+
*/
|
|
7
|
+
export var themeColorModes = ['light', 'dark', 'auto'];
|