@atlaskit/tokens 13.0.3 → 13.1.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 +15 -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/themes/atlassian-dark-increased-contrast.js +2 -2
- package/dist/cjs/artifacts/themes/atlassian-dark.js +2 -2
- package/dist/cjs/artifacts/themes/atlassian-light-increased-contrast.js +2 -2
- package/dist/cjs/artifacts/themes/atlassian-light.js +2 -2
- package/dist/cjs/artifacts/token-default-values.js +2 -2
- package/dist/cjs/artifacts/tokens-raw/atlassian-dark-increased-contrast.js +3 -3
- package/dist/cjs/artifacts/tokens-raw/atlassian-dark.js +3 -3
- package/dist/cjs/artifacts/tokens-raw/atlassian-light-increased-contrast.js +3 -3
- package/dist/cjs/artifacts/tokens-raw/atlassian-light.js +3 -3
- package/dist/cjs/artifacts/tokens-raw/atlassian-motion.js +3 -3
- package/dist/cjs/constants.js +1 -0
- package/dist/cjs/custom-theme.js +10 -60
- package/dist/cjs/entry-points/token-metadata.codegen.js +2 -11
- 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 +33 -32
- package/dist/cjs/load-custom-theme-styles.js +2 -2
- package/dist/cjs/set-global-theme.js +36 -34
- package/dist/cjs/theme-color-modes.js +13 -0
- package/dist/cjs/theme-config.js +21 -16
- package/dist/cjs/theme-ids.js +13 -0
- package/dist/cjs/theme-state-transformer.js +3 -2
- package/dist/cjs/utils/color-detection.js +9 -12
- package/dist/cjs/utils/color-utils.js +45 -46
- package/dist/cjs/utils/custom-theme-loading-utils.js +9 -11
- package/dist/cjs/utils/custom-theme-token-contrast-check.js +2 -0
- package/dist/cjs/utils/generate-custom-color-ramp.js +20 -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 +42 -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 +18 -33
- package/dist/cjs/utils/token-ids.js +21 -62
- package/dist/es2019/artifacts/replacement-mapping.js +5 -2
- package/dist/es2019/artifacts/themes/atlassian-dark-increased-contrast.js +2 -2
- package/dist/es2019/artifacts/themes/atlassian-dark.js +2 -2
- package/dist/es2019/artifacts/themes/atlassian-light-increased-contrast.js +2 -2
- package/dist/es2019/artifacts/themes/atlassian-light.js +2 -2
- package/dist/es2019/artifacts/token-default-values.js +2 -2
- package/dist/es2019/artifacts/tokens-raw/atlassian-dark-increased-contrast.js +3 -3
- package/dist/es2019/artifacts/tokens-raw/atlassian-dark.js +3 -3
- package/dist/es2019/artifacts/tokens-raw/atlassian-light-increased-contrast.js +3 -3
- package/dist/es2019/artifacts/tokens-raw/atlassian-light.js +3 -3
- package/dist/es2019/artifacts/tokens-raw/atlassian-motion.js +3 -3
- package/dist/es2019/constants.js +1 -0
- package/dist/es2019/custom-theme.js +4 -66
- package/dist/es2019/entry-points/token-metadata.codegen.js +2 -11
- 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 +6 -16
- package/dist/es2019/theme-ids.js +7 -0
- package/dist/es2019/theme-state-transformer.js +2 -1
- package/dist/es2019/utils/color-detection.js +3 -11
- package/dist/es2019/utils/color-utils.js +15 -33
- package/dist/es2019/utils/custom-theme-loading-utils.js +4 -8
- package/dist/es2019/utils/custom-theme-token-contrast-check.js +2 -0
- package/dist/es2019/utils/generate-custom-color-ramp.js +11 -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 +15 -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/themes/atlassian-dark-increased-contrast.js +2 -2
- package/dist/esm/artifacts/themes/atlassian-dark.js +2 -2
- package/dist/esm/artifacts/themes/atlassian-light-increased-contrast.js +2 -2
- package/dist/esm/artifacts/themes/atlassian-light.js +2 -2
- package/dist/esm/artifacts/token-default-values.js +2 -2
- package/dist/esm/artifacts/tokens-raw/atlassian-dark-increased-contrast.js +3 -3
- package/dist/esm/artifacts/tokens-raw/atlassian-dark.js +3 -3
- package/dist/esm/artifacts/tokens-raw/atlassian-light-increased-contrast.js +3 -3
- package/dist/esm/artifacts/tokens-raw/atlassian-light.js +3 -3
- package/dist/esm/artifacts/tokens-raw/atlassian-motion.js +3 -3
- package/dist/esm/constants.js +1 -0
- package/dist/esm/custom-theme.js +4 -58
- package/dist/esm/entry-points/token-metadata.codegen.js +2 -11
- 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 +30 -29
- package/dist/esm/load-custom-theme-styles.js +1 -1
- package/dist/esm/set-global-theme.js +34 -32
- package/dist/esm/theme-color-modes.js +7 -0
- package/dist/esm/theme-config.js +8 -17
- package/dist/esm/theme-ids.js +7 -0
- package/dist/esm/theme-state-transformer.js +2 -1
- package/dist/esm/utils/color-detection.js +3 -11
- package/dist/esm/utils/color-utils.js +15 -39
- package/dist/esm/utils/custom-theme-loading-utils.js +4 -11
- package/dist/esm/utils/custom-theme-token-contrast-check.js +2 -0
- package/dist/esm/utils/generate-custom-color-ramp.js +11 -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 +15 -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 +11 -32
- package/dist/esm/utils/token-ids.js +3 -61
- package/dist/types/artifacts/replacement-mapping.d.ts +1 -1
- package/dist/types/artifacts/themes/atlassian-dark-increased-contrast.d.ts +2 -2
- package/dist/types/artifacts/themes/atlassian-dark.d.ts +2 -2
- package/dist/types/artifacts/themes/atlassian-light-increased-contrast.d.ts +2 -2
- package/dist/types/artifacts/themes/atlassian-light.d.ts +2 -2
- package/dist/types/artifacts/token-default-values.d.ts +2 -2
- package/dist/types/artifacts/tokens-raw/atlassian-dark-increased-contrast.d.ts +1 -1
- package/dist/types/artifacts/tokens-raw/atlassian-dark.d.ts +1 -1
- package/dist/types/artifacts/tokens-raw/atlassian-light-increased-contrast.d.ts +1 -1
- package/dist/types/artifacts/tokens-raw/atlassian-light.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/themes/atlassian-dark-increased-contrast.d.ts +2 -2
- package/dist/types-ts4.5/artifacts/themes/atlassian-dark.d.ts +2 -2
- package/dist/types-ts4.5/artifacts/themes/atlassian-light-increased-contrast.d.ts +2 -2
- package/dist/types-ts4.5/artifacts/themes/atlassian-light.d.ts +2 -2
- package/dist/types-ts4.5/artifacts/token-default-values.d.ts +2 -2
- package/dist/types-ts4.5/artifacts/tokens-raw/atlassian-dark-increased-contrast.d.ts +1 -1
- package/dist/types-ts4.5/artifacts/tokens-raw/atlassian-dark.d.ts +1 -1
- package/dist/types-ts4.5/artifacts/tokens-raw/atlassian-light-increased-contrast.d.ts +1 -1
- package/dist/types-ts4.5/artifacts/tokens-raw/atlassian-light.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/figma/atlassian-dark-increased-contrast.json +1 -1
- package/figma/atlassian-dark.json +1 -1
- package/figma/atlassian-light-increased-contrast.json +1 -1
- package/figma/atlassian-light.json +1 -1
- package/package.json +12 -12
- package/tokens.docs.tsx +48 -46
|
@@ -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 @@ const 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 @@ const 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/es2019/constants.js
CHANGED
|
@@ -6,4 +6,5 @@ export const CUSTOM_THEME_ATTRIBUTE = 'data-custom-theme';
|
|
|
6
6
|
export const CSS_PREFIX = 'ds';
|
|
7
7
|
export const CSS_VAR_FULL = ['opacity', 'font', 'space', 'border', 'radius'];
|
|
8
8
|
export const TOKEN_NOT_FOUND_CSS_VAR = `--${CSS_PREFIX}-token-not-found`;
|
|
9
|
+
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
9
10
|
export const CURRENT_SURFACE_CSS_VAR = `--${CSS_PREFIX}-elevation-surface-current`;
|
|
@@ -1,69 +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 const 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
|
-
const brandColor = themeState === null || themeState === void 0 ? void 0 : (_themeState$UNSAFE_th = themeState.UNSAFE_themeOptions) === null || _themeState$UNSAFE_th === void 0 ? void 0 : _themeState$UNSAFE_th.brandColor;
|
|
27
|
-
const mode = (themeState === null || themeState === void 0 ? void 0 : themeState.colorMode) || themeStateDefaults['colorMode'];
|
|
28
|
-
const optionString = JSON.stringify(themeState === null || themeState === void 0 ? void 0 : themeState.UNSAFE_themeOptions);
|
|
29
|
-
const uniqueId = hash(optionString);
|
|
30
|
-
const themeRamp = generateColors(brandColor).ramp;
|
|
31
|
-
|
|
32
|
-
// outputs object to generate to CSS from
|
|
33
|
-
const themes = [];
|
|
34
|
-
const 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: `
|
|
44
|
-
html[${CUSTOM_THEME_ATTRIBUTE}="${uniqueId}"][${COLOR_MODE_ATTRIBUTE}="light"][data-theme~="light:light"] {
|
|
45
|
-
/* Branded tokens */
|
|
46
|
-
${reduceTokenMap(tokenMaps.light, themeRamp)}
|
|
47
|
-
}`
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
if ((mode === 'dark' || mode === 'auto') && tokenMaps.dark) {
|
|
51
|
-
// Dark mode theming
|
|
52
|
-
themes.push({
|
|
53
|
-
id: 'dark',
|
|
54
|
-
attrs: {
|
|
55
|
-
'data-theme': 'dark',
|
|
56
|
-
'data-custom-theme': uniqueId
|
|
57
|
-
},
|
|
58
|
-
css: `
|
|
59
|
-
html[${CUSTOM_THEME_ATTRIBUTE}="${uniqueId}"][${COLOR_MODE_ATTRIBUTE}="dark"][data-theme~="dark:dark"] {
|
|
60
|
-
/* Branded tokens */
|
|
61
|
-
${reduceTokenMap(tokenMaps.dark, themeRamp)}
|
|
62
|
-
}`
|
|
63
|
-
});
|
|
64
|
-
}
|
|
65
|
-
return themes;
|
|
66
|
-
}
|
|
67
4
|
export function loadAndAppendCustomThemeCss(themeState) {
|
|
68
5
|
const themes = getCustomThemeStyles(themeState);
|
|
69
6
|
limitSizeOfCustomStyleElements(CUSTOM_STYLE_ELEMENTS_SIZE_THRESHOLD);
|
|
@@ -74,4 +11,5 @@ export function loadAndAppendCustomThemeCss(themeState) {
|
|
|
74
11
|
styleTag.dataset.customTheme = theme.attrs['data-custom-theme'];
|
|
75
12
|
styleTag.textContent = theme.css;
|
|
76
13
|
});
|
|
77
|
-
}
|
|
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::ecdf4f84ae7b36849943b200af52ee54>>
|
|
7
7
|
* @codegenCommand yarn build tokens
|
|
8
8
|
*/
|
|
9
9
|
|
|
@@ -160,15 +160,6 @@ export const 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'],
|
|
@@ -2324,7 +2315,7 @@ export const tokens = [{
|
|
|
2324
2315
|
name: 'color.background.disabled',
|
|
2325
2316
|
path: ['color', 'background', 'disabled'],
|
|
2326
2317
|
description: 'Use for backgrounds of elements in a disabled state.',
|
|
2327
|
-
exampleValue: '#
|
|
2318
|
+
exampleValue: '#0515240F',
|
|
2328
2319
|
usageGuidelines: {
|
|
2329
2320
|
usage: 'The color for backgrounds. Use for areas behind content (e.g. color.background.neutral, color.background.selected)',
|
|
2330
2321
|
cssProperties: ['background-color']
|
|
@@ -0,0 +1,60 @@
|
|
|
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
|
+
const brandColor = themeState === null || themeState === void 0 ? void 0 : (_themeState$UNSAFE_th = themeState.UNSAFE_themeOptions) === null || _themeState$UNSAFE_th === void 0 ? void 0 : _themeState$UNSAFE_th.brandColor;
|
|
21
|
+
const mode = (themeState === null || themeState === void 0 ? void 0 : themeState.colorMode) || themeStateDefaults['colorMode'];
|
|
22
|
+
const optionString = JSON.stringify(themeState === null || themeState === void 0 ? void 0 : themeState.UNSAFE_themeOptions);
|
|
23
|
+
const uniqueId = hash(optionString);
|
|
24
|
+
const themeRamp = generateColors(brandColor).ramp;
|
|
25
|
+
|
|
26
|
+
// outputs object to generate to CSS from
|
|
27
|
+
const themes = [];
|
|
28
|
+
const 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: `
|
|
38
|
+
html[${CUSTOM_THEME_ATTRIBUTE}="${uniqueId}"][${COLOR_MODE_ATTRIBUTE}="light"][data-theme~="light:light"] {
|
|
39
|
+
/* Branded tokens */
|
|
40
|
+
${reduceTokenMap(tokenMaps.light, themeRamp)}
|
|
41
|
+
}`
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
if ((mode === 'dark' || mode === 'auto') && tokenMaps.dark) {
|
|
45
|
+
// Dark mode theming
|
|
46
|
+
themes.push({
|
|
47
|
+
id: 'dark',
|
|
48
|
+
attrs: {
|
|
49
|
+
'data-theme': 'dark',
|
|
50
|
+
'data-custom-theme': uniqueId
|
|
51
|
+
},
|
|
52
|
+
css: `
|
|
53
|
+
html[${CUSTOM_THEME_ATTRIBUTE}="${uniqueId}"][${COLOR_MODE_ATTRIBUTE}="dark"][data-theme~="dark:dark"] {
|
|
54
|
+
/* Branded tokens */
|
|
55
|
+
${reduceTokenMap(tokenMaps.dark, themeRamp)}
|
|
56
|
+
}`
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return themes;
|
|
60
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { COLOR_MODE_ATTRIBUTE, THEME_DATA_ATTRIBUTE } from './constants';
|
|
2
|
-
import { themeColorModes } from './theme-
|
|
2
|
+
import { themeColorModes } from './theme-color-modes';
|
|
3
3
|
import { themeStringToObject } from './theme-state-transformer';
|
|
4
4
|
const isThemeColorMode = colorMode => {
|
|
5
5
|
return themeColorModes.find(mode => mode === colorMode) !== undefined;
|
|
@@ -2,8 +2,8 @@ import { fg } from '@atlaskit/platform-feature-flags';
|
|
|
2
2
|
import { COLOR_MODE_ATTRIBUTE, CONTRAST_MODE_ATTRIBUTE, CUSTOM_THEME_ATTRIBUTE, THEME_DATA_ATTRIBUTE } from './constants';
|
|
3
3
|
import { themeStateDefaults } from './theme-config';
|
|
4
4
|
import { themeObjectToString } from './theme-state-transformer';
|
|
5
|
-
import { isValidBrandHex } from './utils/color-utils';
|
|
6
5
|
import { hash } from './utils/hash';
|
|
6
|
+
import { isValidBrandHex } from './utils/is-valid-brand-hex';
|
|
7
7
|
const defaultColorMode = 'light';
|
|
8
8
|
const defaultContrastMode = 'no-preference';
|
|
9
9
|
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
2
|
import { themeIdsWithOverrides, themeStateDefaults } from './theme-config';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
3
|
+
import { getThemeOverridePreferences } from './utils/get-theme-override-preferences';
|
|
4
|
+
import { getThemePreferences } from './utils/get-theme-preferences';
|
|
5
|
+
import { isValidBrandHex } from './utils/is-valid-brand-hex';
|
|
6
|
+
import { loadThemeCss } from './utils/load-theme-css';
|
|
6
7
|
/**
|
|
7
8
|
* Takes an object containing theme preferences, and returns an array of objects for use in applying styles to the document head.
|
|
8
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.
|
|
@@ -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.
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
2
|
import getGlobalTheme from './get-global-theme';
|
|
3
3
|
import { themeStateDefaults } from './theme-config';
|
|
4
|
-
import { isValidBrandHex } from './utils/color-utils';
|
|
5
4
|
import configurePage from './utils/configure-page';
|
|
6
5
|
import { findMissingCustomStyleElements } from './utils/custom-theme-loading-utils';
|
|
7
|
-
import { getThemeOverridePreferences
|
|
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';
|
|
8
9
|
import { loadAndAppendThemeCss } from './utils/theme-loading';
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -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 const themeColorModes = ['light', 'dark', 'auto'];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
|
-
|
|
2
|
+
import { themeIds } from './theme-ids';
|
|
3
3
|
/**
|
|
4
4
|
* This file contains the source of truth for themes and all associated meta data.
|
|
5
5
|
*/
|
|
@@ -23,24 +23,10 @@ import { fg } from '@atlaskit/platform-feature-flags';
|
|
|
23
23
|
* In the future other types may be introduced such as typography.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
/**
|
|
27
|
-
* Theme modes: The general purpose of a theme.
|
|
28
|
-
* This attr is used to apply the appropriate system-preference option
|
|
29
|
-
* It may also be used as a selector for mode-specific overrides such as light/dark images.
|
|
30
|
-
* The idea is there may exist many color themes, but every theme must either fit into light or dark.
|
|
31
|
-
*/
|
|
32
|
-
export const themeColorModes = ['light', 'dark', 'auto'];
|
|
33
26
|
/**
|
|
34
27
|
* Contrast preferences: The system contrast preference
|
|
35
28
|
*/
|
|
36
29
|
const themeContrastModes = ['more', 'no-preference', 'auto'];
|
|
37
|
-
/**
|
|
38
|
-
* Theme ids: The value that will be mounted to the DOM as a data attr
|
|
39
|
-
* For example: `data-theme="light:light dark:dark spacing:spacing"
|
|
40
|
-
*
|
|
41
|
-
* These ids must be kebab case
|
|
42
|
-
*/
|
|
43
|
-
export const themeIds = ['light-increased-contrast', 'light', 'light-future', 'dark', 'dark-future', 'dark-increased-contrast', 'spacing', 'shape', 'typography', 'motion'];
|
|
44
30
|
/**
|
|
45
31
|
* Theme override ids: the equivalent of themeIds for theme overrides.
|
|
46
32
|
* Theme overrides are temporary and there may not be any defined at times.
|
|
@@ -189,6 +175,7 @@ function getMotionDefault() {
|
|
|
189
175
|
/**
|
|
190
176
|
* themeStateDefaults: the default values for ThemeState used by theming utilities
|
|
191
177
|
*/
|
|
178
|
+
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
192
179
|
export const themeStateDefaults = {
|
|
193
180
|
colorMode: 'auto',
|
|
194
181
|
contrastMode: 'auto',
|
|
@@ -206,4 +193,7 @@ export const themeStateDefaults = {
|
|
|
206
193
|
* (the page doesn't have an "auto" color mode, it's either light or dark)
|
|
207
194
|
*/
|
|
208
195
|
|
|
209
|
-
|
|
196
|
+
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
197
|
+
export default themeConfig;
|
|
198
|
+
export { themeColorModes } from './theme-color-modes';
|
|
199
|
+
export { themeIds } from './theme-ids';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Theme ids: The value that will be mounted to the DOM as a data attr
|
|
3
|
+
* For example: `data-theme="light:light dark:dark spacing:spacing"
|
|
4
|
+
*
|
|
5
|
+
* These ids must be kebab case
|
|
6
|
+
*/
|
|
7
|
+
export const themeIds = ['light-increased-contrast', 'light', 'light-future', 'dark', 'dark-future', 'dark-increased-contrast', 'spacing', 'shape', 'typography', 'motion'];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { themeIds } from './theme-
|
|
1
|
+
import { themeIds } from './theme-ids';
|
|
2
2
|
const themeKinds = ['light', 'dark', 'spacing', 'typography', 'shape', 'motion'];
|
|
3
3
|
const customThemeOptions = 'UNSAFE_themeOptions';
|
|
4
4
|
const isThemeKind = themeKind => {
|
|
@@ -55,6 +55,7 @@ export const themeStringToObject = themeState => {
|
|
|
55
55
|
* // returns 'dark:dark light:light spacing:spacing'
|
|
56
56
|
* ```
|
|
57
57
|
*/
|
|
58
|
+
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
58
59
|
export const themeObjectToString = themeState => Object.entries(themeState).reduce((themeString, [kind, id]) => {
|
|
59
60
|
if (
|
|
60
61
|
// colorMode theme state
|
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
|
|
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
|
-
};
|
|
10
|
-
|
|
1
|
+
import { hexToRGBAValues } from './hex-to-rgba-values';
|
|
11
2
|
/**
|
|
12
3
|
* Returns a box shadow formatted for CSS from a ShadowToken raw value.
|
|
13
4
|
*
|
|
@@ -25,4 +16,5 @@ export const getBoxShadow = rawShadow => rawShadow.map(({
|
|
|
25
16
|
b
|
|
26
17
|
} = hexToRGBAValues(color);
|
|
27
18
|
return `${offset.x}px ${offset.y}px ${radius}px rgba(${r}, ${g}, ${b}, ${opacity})`;
|
|
28
|
-
}).join(',');
|
|
19
|
+
}).join(',');
|
|
20
|
+
export { hexToRGBAValues } from './hex-to-rgba-values';
|
|
@@ -1,18 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { getAlpha } from './get-alpha';
|
|
2
|
+
import { relativeLuminanceW3C } from './relative-luminance-w3-c';
|
|
4
3
|
// valid hex color with 4, 6 or 8 digits
|
|
5
4
|
const isValidHex = hex => /^#([A-Fa-f0-9]{3,4}){1,2}$/.test(hex);
|
|
6
|
-
export function rgbToHex(r, g, b) {
|
|
7
|
-
return '#' + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
|
|
8
|
-
}
|
|
9
|
-
export function getAlpha(hex) {
|
|
10
|
-
if (hex.length === 9) {
|
|
11
|
-
const int = parseInt(hex.slice(7, 9), 16) / 255;
|
|
12
|
-
return Number(parseFloat(int.toString()).toFixed(2));
|
|
13
|
-
}
|
|
14
|
-
return 1;
|
|
15
|
-
}
|
|
16
5
|
export function hexToRgbA(hex) {
|
|
17
6
|
if (!isValidHex(hex)) {
|
|
18
7
|
throw new Error('Invalid HEX');
|
|
@@ -25,6 +14,8 @@ export function hexToRgbA(hex) {
|
|
|
25
14
|
c = '0x' + c.join('');
|
|
26
15
|
return [c >> 16 & 255, c >> 8 & 255, c & 255, getAlpha(hex)];
|
|
27
16
|
}
|
|
17
|
+
|
|
18
|
+
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
28
19
|
export function hexToRgb(hex) {
|
|
29
20
|
if (!isValidHex(hex)) {
|
|
30
21
|
throw new Error('Invalid HEX');
|
|
@@ -37,6 +28,8 @@ export function hexToRgb(hex) {
|
|
|
37
28
|
c = '0x' + c.join('');
|
|
38
29
|
return [c >> 16 & 255, c >> 8 & 255, c & 255];
|
|
39
30
|
}
|
|
31
|
+
|
|
32
|
+
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
40
33
|
export function hexToHSL(hex) {
|
|
41
34
|
if (!isValidHex(hex)) {
|
|
42
35
|
throw new Error('Invalid HEX');
|
|
@@ -82,26 +75,8 @@ export function hexToHSL(hex) {
|
|
|
82
75
|
l = +(l * 100).toFixed(1);
|
|
83
76
|
return [h, s, l];
|
|
84
77
|
}
|
|
85
|
-
export function HSLToRGB(h, s, l) {
|
|
86
|
-
s /= 100;
|
|
87
|
-
l /= 100;
|
|
88
|
-
const k = n => (n + h / 30) % 12;
|
|
89
|
-
const a = s * Math.min(l, 1 - l);
|
|
90
|
-
const f = n => l - a * Math.max(-1, Math.min(k(n) - 3, Math.min(9 - k(n), 1)));
|
|
91
|
-
return [255 * f(0), 255 * f(8), 255 * f(4)];
|
|
92
|
-
}
|
|
93
|
-
export function relativeLuminanceW3C(r, g, b) {
|
|
94
|
-
const RsRGB = r / 255;
|
|
95
|
-
const GsRGB = g / 255;
|
|
96
|
-
const BsRGB = b / 255;
|
|
97
|
-
const R = RsRGB <= 0.03928 ? RsRGB / 12.92 : Math.pow((RsRGB + 0.055) / 1.055, 2.4);
|
|
98
|
-
const G = GsRGB <= 0.03928 ? GsRGB / 12.92 : Math.pow((GsRGB + 0.055) / 1.055, 2.4);
|
|
99
|
-
const B = BsRGB <= 0.03928 ? BsRGB / 12.92 : Math.pow((BsRGB + 0.055) / 1.055, 2.4);
|
|
100
78
|
|
|
101
|
-
|
|
102
|
-
const L = 0.2126 * R + 0.7152 * G + 0.0722 * B;
|
|
103
|
-
return L;
|
|
104
|
-
}
|
|
79
|
+
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
105
80
|
export function getContrastRatio(foreground, background) {
|
|
106
81
|
if (!isValidHex(foreground) || !isValidHex(background)) {
|
|
107
82
|
throw new Error('Invalid HEX');
|
|
@@ -115,6 +90,8 @@ export function getContrastRatio(foreground, background) {
|
|
|
115
90
|
var darkest = Math.min(foregroundLuminance, backgroundLuminance);
|
|
116
91
|
return (brightest + 0.05) / (darkest + 0.05);
|
|
117
92
|
}
|
|
93
|
+
|
|
94
|
+
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
118
95
|
export function deltaE(rgbA, rgbB) {
|
|
119
96
|
let labA = rgbToLab(rgbA);
|
|
120
97
|
let labB = rgbToLab(rgbB);
|
|
@@ -151,4 +128,9 @@ function rgbToLab(rgb) {
|
|
|
151
128
|
y = y > 0.008856 ? Math.pow(y, 1 / 3) : 7.787 * y + 16 / 116;
|
|
152
129
|
z = z > 0.008856 ? Math.pow(z, 1 / 3) : 7.787 * z + 16 / 116;
|
|
153
130
|
return [116 * y - 16, 500 * (x - y), 200 * (y - z)];
|
|
154
|
-
}
|
|
131
|
+
}
|
|
132
|
+
export { isValidBrandHex } from './is-valid-brand-hex';
|
|
133
|
+
export { rgbToHex } from './rgb-to-hex';
|
|
134
|
+
export { getAlpha } from './get-alpha';
|
|
135
|
+
export { HSLToRGB } from './hsl-to-rgb';
|
|
136
|
+
export { relativeLuminanceW3C } from './relative-luminance-w3-c';
|
|
@@ -16,16 +16,12 @@ export function findMissingCustomStyleElements(UNSAFE_themeOptions, mode) {
|
|
|
16
16
|
});
|
|
17
17
|
return attrOfMissingCustomStyles;
|
|
18
18
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (styleTags.length < sizeThreshold) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
styleTags.slice(0, styleTags.length - (sizeThreshold - 1)).forEach(element => element.remove());
|
|
25
|
-
}
|
|
19
|
+
|
|
20
|
+
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
26
21
|
export function reduceTokenMap(tokenMap, themeRamp) {
|
|
27
22
|
return Object.entries(tokenMap).reduce((acc, [key, value]) => {
|
|
28
23
|
const cssVar = tokens[key];
|
|
29
24
|
return cssVar ? `${acc}\n ${cssVar}: ${typeof value === 'string' ? value : themeRamp[value]};` : acc;
|
|
30
25
|
}, '');
|
|
31
|
-
}
|
|
26
|
+
}
|
|
27
|
+
export { limitSizeOfCustomStyleElements } from './limit-size-of-custom-style-elements';
|
|
@@ -46,6 +46,8 @@ export const additionalChecks = [{
|
|
|
46
46
|
const getColorFromTokenRaw = (tokenName, mode) => {
|
|
47
47
|
return mode === 'light' ? tokenValuesLight[tokenName] : tokenValuesDark[tokenName];
|
|
48
48
|
};
|
|
49
|
+
|
|
50
|
+
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
49
51
|
export const additionalContrastChecker = ({
|
|
50
52
|
customThemeTokenMap,
|
|
51
53
|
mode,
|
|
@@ -1,22 +1,13 @@
|
|
|
1
1
|
import rawTokensDark from '../artifacts/atlassian-dark-token-value-for-contrast-check';
|
|
2
|
-
import {
|
|
2
|
+
import { getContrastRatio, hexToHSL, hexToRgbA } from './color-utils';
|
|
3
3
|
import { additionalContrastChecker } from './custom-theme-token-contrast-check';
|
|
4
|
+
import { getClosestColorIndex } from './get-closest-color-index';
|
|
4
5
|
import { argbFromRgba, Contrast, Hct, rgbaFromArgb } from './hct-color-utils';
|
|
6
|
+
import { HSLToRGB } from './hsl-to-rgb';
|
|
7
|
+
import { relativeLuminanceW3C } from './relative-luminance-w3-c';
|
|
8
|
+
import { rgbToHex } from './rgb-to-hex';
|
|
5
9
|
const lowLuminanceContrastRatios = [1.12, 1.33, 2.03, 2.73, 3.33, 4.27, 5.2, 6.62, 12.46, 14.25];
|
|
6
10
|
const highLuminanceContrastRatios = [1.08, 1.24, 1.55, 1.99, 2.45, 3.34, 4.64, 6.1, 10.19, 12.6];
|
|
7
|
-
export const getClosestColorIndex = (themeRamp, brandColor) => {
|
|
8
|
-
// Iterate over themeRamp and find whichever color is closest to brandColor
|
|
9
|
-
let closestColorIndex = 0;
|
|
10
|
-
let closestColorDistance = null;
|
|
11
|
-
themeRamp.forEach((value, index) => {
|
|
12
|
-
const distance = deltaE(hexToRgb(value), hexToRgb(brandColor));
|
|
13
|
-
if (closestColorDistance === null || distance < closestColorDistance) {
|
|
14
|
-
closestColorIndex = index;
|
|
15
|
-
closestColorDistance = distance;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
return closestColorIndex;
|
|
19
|
-
};
|
|
20
11
|
export const generateColors = brandColor => {
|
|
21
12
|
// Determine luminance
|
|
22
13
|
const HSLBrandColorHue = hexToHSL(brandColor)[0];
|
|
@@ -67,6 +58,8 @@ function getInteractionStates(rampPosition, number, colors) {
|
|
|
67
58
|
}
|
|
68
59
|
return result;
|
|
69
60
|
}
|
|
61
|
+
|
|
62
|
+
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
70
63
|
export const generateTokenMap = (brandColor, mode, themeRamp) => {
|
|
71
64
|
const {
|
|
72
65
|
ramp,
|
|
@@ -199,6 +192,8 @@ export const generateTokenMap = (brandColor, mode, themeRamp) => {
|
|
|
199
192
|
dark: customThemeTokenMapDark
|
|
200
193
|
};
|
|
201
194
|
};
|
|
195
|
+
|
|
196
|
+
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
202
197
|
export const generateTokenMapWithContrastCheck = (brandColor, mode, themeRamp) => {
|
|
203
198
|
const colors = themeRamp || generateColors(brandColor).ramp;
|
|
204
199
|
const tokenMaps = generateTokenMap(brandColor, mode, colors);
|
|
@@ -216,4 +211,5 @@ export const generateTokenMapWithContrastCheck = (brandColor, mode, themeRamp) =
|
|
|
216
211
|
}
|
|
217
212
|
});
|
|
218
213
|
return result;
|
|
219
|
-
};
|
|
214
|
+
};
|
|
215
|
+
export { getClosestColorIndex } from './get-closest-color-index';
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { deltaE, hexToRgb } from './color-utils';
|
|
2
|
+
export const getClosestColorIndex = (themeRamp, brandColor) => {
|
|
3
|
+
// Iterate over themeRamp and find whichever color is closest to brandColor
|
|
4
|
+
let closestColorIndex = 0;
|
|
5
|
+
let closestColorDistance = null;
|
|
6
|
+
themeRamp.forEach((value, index) => {
|
|
7
|
+
const distance = deltaE(hexToRgb(value), hexToRgb(brandColor));
|
|
8
|
+
if (closestColorDistance === null || distance < closestColorDistance) {
|
|
9
|
+
closestColorIndex = index;
|
|
10
|
+
closestColorDistance = distance;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
return closestColorIndex;
|
|
14
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { CSS_PREFIX, CSS_VAR_FULL } from '../constants';
|
|
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
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transforms a style dictionary token path to a fully qualified token id
|
|
3
|
+
* These Ids are intended to be used internal to this package by style-dictionary
|
|
4
|
+
*
|
|
5
|
+
* [default] key words will NOT be omitted from the path
|
|
6
|
+
*
|
|
7
|
+
* @example <caption>Passing a path as a string</caption>
|
|
8
|
+
* // Returns color.background.bold.[default]
|
|
9
|
+
* getFullyQualifiedTokenId(['color', 'background', 'bold', '[default]'])
|
|
10
|
+
*/
|
|
11
|
+
export const getFullyQualifiedTokenId = path => path.join('.');
|
|
@@ -39,7 +39,4 @@ export const getThemePreferences = themeState => {
|
|
|
39
39
|
});
|
|
40
40
|
return [...new Set(themePreferences)];
|
|
41
41
|
};
|
|
42
|
-
export
|
|
43
|
-
const themeOverridePreferences = [];
|
|
44
|
-
return [...new Set(themeOverridePreferences)];
|
|
45
|
-
};
|
|
42
|
+
export { getThemeOverridePreferences } from './get-theme-override-preferences';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transforms a style dictionary token path to a shorthand token id
|
|
3
|
+
* These ids will be typically be how tokens are interacted with via typescript and css
|
|
4
|
+
*
|
|
5
|
+
* All [default] key words will be omitted from the path
|
|
6
|
+
*
|
|
7
|
+
* @example <caption>Passing a path as an array</caption>
|
|
8
|
+
* // Returns color.background.bold
|
|
9
|
+
* getTokenId(['color', 'background', 'bold', '[default]'])
|
|
10
|
+
*
|
|
11
|
+
* @example <caption>Passing a path as a string</caption>
|
|
12
|
+
* // Returns color.background.bold
|
|
13
|
+
* getTokenId('color.background.bold.[default]')
|
|
14
|
+
*/
|
|
15
|
+
export const getTokenId = path => {
|
|
16
|
+
const normalizedPath = typeof path === 'string' ? path.split('.') : path;
|
|
17
|
+
return normalizedPath.filter(el => el !== '[default]').join('.');
|
|
18
|
+
};
|