@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
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::ecdf4f84ae7b36849943b200af52ee54>>
|
|
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'],
|
|
@@ -2324,7 +2315,7 @@ export var 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,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.
|
|
@@ -26,7 +27,7 @@ import { loadThemeCss } from './utils/theme-loading';
|
|
|
26
27
|
var getThemeStyles = /*#__PURE__*/function () {
|
|
27
28
|
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(preferences) {
|
|
28
29
|
var themePreferences, themeOverridePreferences, themeState, results;
|
|
29
|
-
return _regeneratorRuntime.wrap(function
|
|
30
|
+
return _regeneratorRuntime.wrap(function (_context3) {
|
|
30
31
|
while (1) switch (_context3.prev = _context3.next) {
|
|
31
32
|
case 0:
|
|
32
33
|
themeOverridePreferences = [];
|
|
@@ -53,17 +54,17 @@ var getThemeStyles = /*#__PURE__*/function () {
|
|
|
53
54
|
themePreferences = getThemePreferences(themeState);
|
|
54
55
|
themeOverridePreferences = getThemeOverridePreferences(themeState);
|
|
55
56
|
}
|
|
56
|
-
_context3.next =
|
|
57
|
+
_context3.next = 1;
|
|
57
58
|
return Promise.all([].concat(_toConsumableArray([].concat(_toConsumableArray(themePreferences), _toConsumableArray(themeOverridePreferences)).map( /*#__PURE__*/function () {
|
|
58
59
|
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(themeId) {
|
|
59
|
-
var css;
|
|
60
|
-
return _regeneratorRuntime.wrap(function
|
|
60
|
+
var css, _t;
|
|
61
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
61
62
|
while (1) switch (_context.prev = _context.next) {
|
|
62
63
|
case 0:
|
|
63
64
|
_context.prev = 0;
|
|
64
|
-
_context.next =
|
|
65
|
+
_context.next = 1;
|
|
65
66
|
return loadThemeCss(themeId);
|
|
66
|
-
case
|
|
67
|
+
case 1:
|
|
67
68
|
css = _context.sent;
|
|
68
69
|
return _context.abrupt("return", {
|
|
69
70
|
id: themeId,
|
|
@@ -72,15 +73,15 @@ var getThemeStyles = /*#__PURE__*/function () {
|
|
|
72
73
|
},
|
|
73
74
|
css: css
|
|
74
75
|
});
|
|
75
|
-
case
|
|
76
|
-
_context.prev =
|
|
77
|
-
|
|
76
|
+
case 2:
|
|
77
|
+
_context.prev = 2;
|
|
78
|
+
_t = _context["catch"](0);
|
|
78
79
|
return _context.abrupt("return", undefined);
|
|
79
|
-
case
|
|
80
|
+
case 3:
|
|
80
81
|
case "end":
|
|
81
82
|
return _context.stop();
|
|
82
83
|
}
|
|
83
|
-
}, _callee, null, [[0,
|
|
84
|
+
}, _callee, null, [[0, 2]]);
|
|
84
85
|
}));
|
|
85
86
|
return function (_x2) {
|
|
86
87
|
return _ref2.apply(this, arguments);
|
|
@@ -89,47 +90,47 @@ var getThemeStyles = /*#__PURE__*/function () {
|
|
|
89
90
|
// Add custom themes if they're present
|
|
90
91
|
_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
91
92
|
var _preferences$UNSAFE_t;
|
|
92
|
-
var _yield$import, getCustomThemeStyles, customThemeStyles;
|
|
93
|
-
return _regeneratorRuntime.wrap(function
|
|
93
|
+
var _yield$import, getCustomThemeStyles, customThemeStyles, _t2;
|
|
94
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
94
95
|
while (1) switch (_context2.prev = _context2.next) {
|
|
95
96
|
case 0:
|
|
96
97
|
if (!(preferences !== 'all' && preferences !== null && preferences !== void 0 && preferences.UNSAFE_themeOptions && isValidBrandHex(preferences === null || preferences === void 0 || (_preferences$UNSAFE_t = preferences.UNSAFE_themeOptions) === null || _preferences$UNSAFE_t === void 0 ? void 0 : _preferences$UNSAFE_t.brandColor))) {
|
|
97
|
-
_context2.next =
|
|
98
|
+
_context2.next = 5;
|
|
98
99
|
break;
|
|
99
100
|
}
|
|
100
101
|
_context2.prev = 1;
|
|
101
|
-
_context2.next =
|
|
102
|
+
_context2.next = 2;
|
|
102
103
|
return import( /* webpackChunkName: "@atlaskit-internal_atlassian-custom-theme" */
|
|
103
104
|
'./custom-theme');
|
|
104
|
-
case
|
|
105
|
+
case 2:
|
|
105
106
|
_yield$import = _context2.sent;
|
|
106
107
|
getCustomThemeStyles = _yield$import.getCustomThemeStyles;
|
|
107
|
-
_context2.next =
|
|
108
|
+
_context2.next = 3;
|
|
108
109
|
return getCustomThemeStyles({
|
|
109
110
|
colorMode: (preferences === null || preferences === void 0 ? void 0 : preferences.colorMode) || themeStateDefaults['colorMode'],
|
|
110
111
|
UNSAFE_themeOptions: preferences === null || preferences === void 0 ? void 0 : preferences.UNSAFE_themeOptions
|
|
111
112
|
});
|
|
112
|
-
case
|
|
113
|
+
case 3:
|
|
113
114
|
customThemeStyles = _context2.sent;
|
|
114
115
|
return _context2.abrupt("return", customThemeStyles);
|
|
115
|
-
case
|
|
116
|
-
_context2.prev =
|
|
117
|
-
|
|
116
|
+
case 4:
|
|
117
|
+
_context2.prev = 4;
|
|
118
|
+
_t2 = _context2["catch"](1);
|
|
118
119
|
return _context2.abrupt("return", undefined);
|
|
119
|
-
case
|
|
120
|
+
case 5:
|
|
120
121
|
return _context2.abrupt("return", undefined);
|
|
121
|
-
case
|
|
122
|
+
case 6:
|
|
122
123
|
case "end":
|
|
123
124
|
return _context2.stop();
|
|
124
125
|
}
|
|
125
|
-
}, _callee2, null, [[1,
|
|
126
|
+
}, _callee2, null, [[1, 4]]);
|
|
126
127
|
}))()]));
|
|
127
|
-
case
|
|
128
|
+
case 1:
|
|
128
129
|
results = _context3.sent;
|
|
129
130
|
return _context3.abrupt("return", results.flat().filter(function (theme) {
|
|
130
131
|
return theme !== undefined;
|
|
131
132
|
}));
|
|
132
|
-
case
|
|
133
|
+
case 2:
|
|
133
134
|
case "end":
|
|
134
135
|
return _context3.stop();
|
|
135
136
|
}
|
|
@@ -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
|
/**
|
|
@@ -71,8 +72,9 @@ var setGlobalTheme = /*#__PURE__*/function () {
|
|
|
71
72
|
_step,
|
|
72
73
|
themeId,
|
|
73
74
|
autoUnbind,
|
|
74
|
-
_args3 = arguments
|
|
75
|
-
|
|
75
|
+
_args3 = arguments,
|
|
76
|
+
_t;
|
|
77
|
+
return _regeneratorRuntime.wrap(function (_context3) {
|
|
76
78
|
while (1) switch (_context3.prev = _context3.next) {
|
|
77
79
|
case 0:
|
|
78
80
|
nextThemeState = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : {};
|
|
@@ -106,14 +108,14 @@ var setGlobalTheme = /*#__PURE__*/function () {
|
|
|
106
108
|
loadingStrategy = themeLoader ? themeLoader : loadAndAppendThemeCss; // Load standard themes
|
|
107
109
|
loadingTasks = themePreferences.map( /*#__PURE__*/function () {
|
|
108
110
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(themeId) {
|
|
109
|
-
return _regeneratorRuntime.wrap(function
|
|
111
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
110
112
|
while (1) switch (_context.prev = _context.next) {
|
|
111
113
|
case 0:
|
|
112
|
-
_context.next =
|
|
114
|
+
_context.next = 1;
|
|
113
115
|
return loadingStrategy(themeId);
|
|
114
|
-
case
|
|
116
|
+
case 1:
|
|
115
117
|
return _context.abrupt("return", _context.sent);
|
|
116
|
-
case
|
|
118
|
+
case 2:
|
|
117
119
|
case "end":
|
|
118
120
|
return _context.stop();
|
|
119
121
|
}
|
|
@@ -130,13 +132,13 @@ var setGlobalTheme = /*#__PURE__*/function () {
|
|
|
130
132
|
// Load custom theme styles
|
|
131
133
|
loadingTasks.push(_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
132
134
|
var _yield$import, loadAndAppendCustomThemeCss;
|
|
133
|
-
return _regeneratorRuntime.wrap(function
|
|
135
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
134
136
|
while (1) switch (_context2.prev = _context2.next) {
|
|
135
137
|
case 0:
|
|
136
|
-
_context2.next =
|
|
138
|
+
_context2.next = 1;
|
|
137
139
|
return import( /* webpackChunkName: "@atlaskit-internal_atlassian-custom-theme" */
|
|
138
140
|
'./custom-theme');
|
|
139
|
-
case
|
|
141
|
+
case 1:
|
|
140
142
|
_yield$import = _context2.sent;
|
|
141
143
|
loadAndAppendCustomThemeCss = _yield$import.loadAndAppendCustomThemeCss;
|
|
142
144
|
loadAndAppendCustomThemeCss({
|
|
@@ -145,7 +147,7 @@ var setGlobalTheme = /*#__PURE__*/function () {
|
|
|
145
147
|
attrOfMissingCustomStyles[0],
|
|
146
148
|
UNSAFE_themeOptions: UNSAFE_themeOptions
|
|
147
149
|
});
|
|
148
|
-
case
|
|
150
|
+
case 2:
|
|
149
151
|
case "end":
|
|
150
152
|
return _context2.stop();
|
|
151
153
|
}
|
|
@@ -153,44 +155,44 @@ var setGlobalTheme = /*#__PURE__*/function () {
|
|
|
153
155
|
}))());
|
|
154
156
|
}
|
|
155
157
|
}
|
|
156
|
-
_context3.next =
|
|
158
|
+
_context3.next = 1;
|
|
157
159
|
return Promise.all(loadingTasks);
|
|
158
|
-
case
|
|
160
|
+
case 1:
|
|
159
161
|
// Load override themes after standard themes
|
|
160
162
|
themeOverridePreferences = getThemeOverridePreferences(themeState);
|
|
161
163
|
_iterator = _createForOfIteratorHelper(themeOverridePreferences);
|
|
162
|
-
_context3.prev =
|
|
164
|
+
_context3.prev = 2;
|
|
163
165
|
_iterator.s();
|
|
164
|
-
case
|
|
166
|
+
case 3:
|
|
165
167
|
if ((_step = _iterator.n()).done) {
|
|
166
|
-
_context3.next =
|
|
168
|
+
_context3.next = 5;
|
|
167
169
|
break;
|
|
168
170
|
}
|
|
169
171
|
themeId = _step.value;
|
|
170
|
-
_context3.next =
|
|
172
|
+
_context3.next = 4;
|
|
171
173
|
return loadingStrategy(themeId);
|
|
172
|
-
case
|
|
173
|
-
_context3.next =
|
|
174
|
+
case 4:
|
|
175
|
+
_context3.next = 3;
|
|
174
176
|
break;
|
|
175
|
-
case
|
|
176
|
-
_context3.next =
|
|
177
|
+
case 5:
|
|
178
|
+
_context3.next = 7;
|
|
177
179
|
break;
|
|
178
|
-
case
|
|
179
|
-
_context3.prev =
|
|
180
|
-
|
|
181
|
-
_iterator.e(
|
|
182
|
-
case
|
|
183
|
-
_context3.prev =
|
|
180
|
+
case 6:
|
|
181
|
+
_context3.prev = 6;
|
|
182
|
+
_t = _context3["catch"](2);
|
|
183
|
+
_iterator.e(_t);
|
|
184
|
+
case 7:
|
|
185
|
+
_context3.prev = 7;
|
|
184
186
|
_iterator.f();
|
|
185
|
-
return _context3.finish(
|
|
186
|
-
case
|
|
187
|
+
return _context3.finish(7);
|
|
188
|
+
case 8:
|
|
187
189
|
autoUnbind = configurePage(themeState);
|
|
188
190
|
return _context3.abrupt("return", autoUnbind);
|
|
189
|
-
case
|
|
191
|
+
case 9:
|
|
190
192
|
case "end":
|
|
191
193
|
return _context3.stop();
|
|
192
194
|
}
|
|
193
|
-
}, _callee3, null, [[
|
|
195
|
+
}, _callee3, null, [[2, 6, 7, 8]]);
|
|
194
196
|
}));
|
|
195
197
|
return function setGlobalTheme() {
|
|
196
198
|
return _ref.apply(this, arguments);
|
|
@@ -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'];
|
package/dist/esm/theme-config.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
1
2
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
|
-
|
|
3
|
+
import { themeIds } from './theme-ids';
|
|
3
4
|
/**
|
|
4
5
|
* This file contains the source of truth for themes and all associated meta data.
|
|
5
6
|
*/
|
|
@@ -23,30 +24,16 @@ import { fg } from '@atlaskit/platform-feature-flags';
|
|
|
23
24
|
* In the future other types may be introduced such as typography.
|
|
24
25
|
*/
|
|
25
26
|
|
|
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 var themeColorModes = ['light', 'dark', 'auto'];
|
|
33
27
|
/**
|
|
34
28
|
* Contrast preferences: The system contrast preference
|
|
35
29
|
*/
|
|
36
30
|
var 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 var themeIds = ['light-increased-contrast', 'light', 'light-future', 'dark', 'dark-future', 'dark-increased-contrast', 'spacing', 'shape', 'typography', 'motion'];
|
|
44
31
|
/**
|
|
45
32
|
* Theme override ids: the equivalent of themeIds for theme overrides.
|
|
46
33
|
* Theme overrides are temporary and there may not be any defined at times.
|
|
47
34
|
*/
|
|
48
35
|
var themeOverrideIds = [];
|
|
49
|
-
export var themeIdsWithOverrides = [].concat(themeIds, themeOverrideIds);
|
|
36
|
+
export var themeIdsWithOverrides = [].concat(_toConsumableArray(themeIds), themeOverrideIds);
|
|
50
37
|
|
|
51
38
|
/**
|
|
52
39
|
* Theme to use a base. This will create the theme as
|
|
@@ -189,6 +176,7 @@ function getMotionDefault() {
|
|
|
189
176
|
/**
|
|
190
177
|
* themeStateDefaults: the default values for ThemeState used by theming utilities
|
|
191
178
|
*/
|
|
179
|
+
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
192
180
|
export var themeStateDefaults = {
|
|
193
181
|
colorMode: 'auto',
|
|
194
182
|
contrastMode: 'auto',
|
|
@@ -206,4 +194,7 @@ export var themeStateDefaults = {
|
|
|
206
194
|
* (the page doesn't have an "auto" color mode, it's either light or dark)
|
|
207
195
|
*/
|
|
208
196
|
|
|
209
|
-
|
|
197
|
+
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
198
|
+
export default themeConfig;
|
|
199
|
+
export { themeColorModes } from './theme-color-modes';
|
|
200
|
+
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 var themeIds = ['light-increased-contrast', 'light', 'light-future', 'dark', 'dark-future', 'dark-increased-contrast', 'spacing', 'shape', 'typography', 'motion'];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _typeof from "@babel/runtime/helpers/typeof";
|
|
2
2
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
-
import { themeIds } from './theme-
|
|
3
|
+
import { themeIds } from './theme-ids';
|
|
4
4
|
var themeKinds = ['light', 'dark', 'spacing', 'typography', 'shape', 'motion'];
|
|
5
5
|
var customThemeOptions = 'UNSAFE_themeOptions';
|
|
6
6
|
var isThemeKind = function isThemeKind(themeKind) {
|
|
@@ -66,6 +66,7 @@ export var themeStringToObject = function themeStringToObject(themeState) {
|
|
|
66
66
|
* // returns 'dark:dark light:light spacing:spacing'
|
|
67
67
|
* ```
|
|
68
68
|
*/
|
|
69
|
+
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
69
70
|
export var themeObjectToString = function themeObjectToString(themeState) {
|
|
70
71
|
return Object.entries(themeState).reduce(function (themeString, _ref3) {
|
|
71
72
|
var _ref4 = _slicedToArray(_ref3, 2),
|
|
@@ -1,13 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
var 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 var getBoxShadow = function getBoxShadow(rawShadow) {
|
|
|
25
16
|
b = _hexToRGBAValues.b;
|
|
26
17
|
return "".concat(offset.x, "px ").concat(offset.y, "px ").concat(radius, "px rgba(").concat(r, ", ").concat(g, ", ").concat(b, ", ").concat(opacity, ")");
|
|
27
18
|
}).join(',');
|
|
28
|
-
};
|
|
19
|
+
};
|
|
20
|
+
export { hexToRGBAValues } from './hex-to-rgba-values';
|