@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
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getCustomThemeStyles = getCustomThemeStyles;
|
|
7
|
+
var _constants = require("./constants");
|
|
8
|
+
var _themeConfig = require("./theme-config");
|
|
9
|
+
var _customThemeLoadingUtils = require("./utils/custom-theme-loading-utils");
|
|
10
|
+
var _generateCustomColorRamp = require("./utils/generate-custom-color-ramp");
|
|
11
|
+
var _hash = require("./utils/hash");
|
|
12
|
+
/**
|
|
13
|
+
* Takes a color mode and custom branding options, and returns an array of objects for use in applying custom styles to the document head.
|
|
14
|
+
* 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.
|
|
15
|
+
*
|
|
16
|
+
* @param {Object<string, string>} themeState The themes and color mode that should be applied.
|
|
17
|
+
* @param {string} themeState.colorMode Determines which color theme is applied
|
|
18
|
+
* @param {Object} themeState.UNSAFE_themeOptions The custom branding options to be used for custom theme generation
|
|
19
|
+
*
|
|
20
|
+
* @returns An object array, containing theme IDs, data-attributes to attach to the theme, and the theme CSS.
|
|
21
|
+
* If an error is encountered while loading themes, the themes array will be empty.
|
|
22
|
+
*/
|
|
23
|
+
function getCustomThemeStyles(themeState) {
|
|
24
|
+
var _themeState$UNSAFE_th;
|
|
25
|
+
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;
|
|
26
|
+
var mode = (themeState === null || themeState === void 0 ? void 0 : themeState.colorMode) || _themeConfig.themeStateDefaults['colorMode'];
|
|
27
|
+
var optionString = JSON.stringify(themeState === null || themeState === void 0 ? void 0 : themeState.UNSAFE_themeOptions);
|
|
28
|
+
var uniqueId = (0, _hash.hash)(optionString);
|
|
29
|
+
var themeRamp = (0, _generateCustomColorRamp.generateColors)(brandColor).ramp;
|
|
30
|
+
|
|
31
|
+
// outputs object to generate to CSS from
|
|
32
|
+
var themes = [];
|
|
33
|
+
var tokenMaps = (0, _generateCustomColorRamp.generateTokenMapWithContrastCheck)(brandColor, mode, themeRamp);
|
|
34
|
+
if ((mode === 'light' || mode === 'auto') && tokenMaps.light) {
|
|
35
|
+
// Light mode theming
|
|
36
|
+
themes.push({
|
|
37
|
+
id: 'light',
|
|
38
|
+
attrs: {
|
|
39
|
+
'data-theme': 'light',
|
|
40
|
+
'data-custom-theme': uniqueId
|
|
41
|
+
},
|
|
42
|
+
css: "\nhtml[".concat(_constants.CUSTOM_THEME_ATTRIBUTE, "=\"").concat(uniqueId, "\"][").concat(_constants.COLOR_MODE_ATTRIBUTE, "=\"light\"][data-theme~=\"light:light\"] {\n /* Branded tokens */\n ").concat((0, _customThemeLoadingUtils.reduceTokenMap)(tokenMaps.light, themeRamp), "\n}")
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
if ((mode === 'dark' || mode === 'auto') && tokenMaps.dark) {
|
|
46
|
+
// Dark mode theming
|
|
47
|
+
themes.push({
|
|
48
|
+
id: 'dark',
|
|
49
|
+
attrs: {
|
|
50
|
+
'data-theme': 'dark',
|
|
51
|
+
'data-custom-theme': uniqueId
|
|
52
|
+
},
|
|
53
|
+
css: "\nhtml[".concat(_constants.CUSTOM_THEME_ATTRIBUTE, "=\"").concat(uniqueId, "\"][").concat(_constants.COLOR_MODE_ATTRIBUTE, "=\"dark\"][data-theme~=\"dark:dark\"] {\n /* Branded tokens */\n ").concat((0, _customThemeLoadingUtils.reduceTokenMap)(tokenMaps.dark, themeRamp), "\n}")
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return themes;
|
|
57
|
+
}
|
|
@@ -7,12 +7,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.default = void 0;
|
|
8
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
9
|
var _constants = require("./constants");
|
|
10
|
-
var
|
|
10
|
+
var _themeColorModes = require("./theme-color-modes");
|
|
11
11
|
var _themeStateTransformer = require("./theme-state-transformer");
|
|
12
12
|
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; }
|
|
13
13
|
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) { (0, _defineProperty2.default)(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; }
|
|
14
14
|
var isThemeColorMode = function isThemeColorMode(colorMode) {
|
|
15
|
-
return
|
|
15
|
+
return _themeColorModes.themeColorModes.find(function (mode) {
|
|
16
16
|
return mode === colorMode;
|
|
17
17
|
}) !== undefined;
|
|
18
18
|
};
|
|
@@ -10,8 +10,8 @@ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
|
10
10
|
var _constants = require("./constants");
|
|
11
11
|
var _themeConfig = require("./theme-config");
|
|
12
12
|
var _themeStateTransformer = require("./theme-state-transformer");
|
|
13
|
-
var _colorUtils = require("./utils/color-utils");
|
|
14
13
|
var _hash = require("./utils/hash");
|
|
14
|
+
var _isValidBrandHex = require("./utils/is-valid-brand-hex");
|
|
15
15
|
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; }
|
|
16
16
|
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) { (0, _defineProperty2.default)(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; }
|
|
17
17
|
var defaultColorMode = 'light';
|
|
@@ -64,7 +64,7 @@ var getThemeHtmlAttrs = function getThemeHtmlAttrs() {
|
|
|
64
64
|
if ((0, _platformFeatureFlags.fg)('platform_increased-contrast-themes')) {
|
|
65
65
|
result = _objectSpread(_objectSpread({}, result), {}, (0, _defineProperty2.default)({}, _constants.CONTRAST_MODE_ATTRIBUTE, contrastMode === 'auto' ? defaultContrastMode : contrastMode));
|
|
66
66
|
}
|
|
67
|
-
if (UNSAFE_themeOptions && (0,
|
|
67
|
+
if (UNSAFE_themeOptions && (0, _isValidBrandHex.isValidBrandHex)(UNSAFE_themeOptions.brandColor)) {
|
|
68
68
|
var optionString = JSON.stringify(UNSAFE_themeOptions);
|
|
69
69
|
var uniqueId = (0, _hash.hash)(optionString);
|
|
70
70
|
result[_constants.CUSTOM_THEME_ATTRIBUTE] = uniqueId;
|
|
@@ -11,10 +11,11 @@ var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers
|
|
|
11
11
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
12
12
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
13
|
var _themeConfig = require("./theme-config");
|
|
14
|
-
var
|
|
14
|
+
var _getThemeOverridePreferences = require("./utils/get-theme-override-preferences");
|
|
15
15
|
var _getThemePreferences = require("./utils/get-theme-preferences");
|
|
16
|
-
var
|
|
17
|
-
|
|
16
|
+
var _isValidBrandHex = require("./utils/is-valid-brand-hex");
|
|
17
|
+
var _loadThemeCss = require("./utils/load-theme-css");
|
|
18
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t3 in e) "default" !== _t3 && {}.hasOwnProperty.call(e, _t3) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t3)) && (i.get || i.set) ? o(f, _t3, i) : f[_t3] = e[_t3]); return f; })(e, t); }
|
|
18
19
|
/**
|
|
19
20
|
* Takes an object containing theme preferences, and returns an array of objects for use in applying styles to the document head.
|
|
20
21
|
* 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.
|
|
@@ -35,7 +36,7 @@ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r
|
|
|
35
36
|
var getThemeStyles = /*#__PURE__*/function () {
|
|
36
37
|
var _ref = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee3(preferences) {
|
|
37
38
|
var themePreferences, themeOverridePreferences, themeState, results;
|
|
38
|
-
return _regenerator.default.wrap(function
|
|
39
|
+
return _regenerator.default.wrap(function (_context3) {
|
|
39
40
|
while (1) switch (_context3.prev = _context3.next) {
|
|
40
41
|
case 0:
|
|
41
42
|
themeOverridePreferences = [];
|
|
@@ -60,19 +61,19 @@ var getThemeStyles = /*#__PURE__*/function () {
|
|
|
60
61
|
typography: (preferences === null || preferences === void 0 ? void 0 : preferences.typography) || _themeConfig.themeStateDefaults['typography']
|
|
61
62
|
};
|
|
62
63
|
themePreferences = (0, _getThemePreferences.getThemePreferences)(themeState);
|
|
63
|
-
themeOverridePreferences = (0,
|
|
64
|
+
themeOverridePreferences = (0, _getThemeOverridePreferences.getThemeOverridePreferences)(themeState);
|
|
64
65
|
}
|
|
65
|
-
_context3.next =
|
|
66
|
+
_context3.next = 1;
|
|
66
67
|
return Promise.all([].concat((0, _toConsumableArray2.default)([].concat((0, _toConsumableArray2.default)(themePreferences), (0, _toConsumableArray2.default)(themeOverridePreferences)).map( /*#__PURE__*/function () {
|
|
67
68
|
var _ref2 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(themeId) {
|
|
68
|
-
var css;
|
|
69
|
-
return _regenerator.default.wrap(function
|
|
69
|
+
var css, _t;
|
|
70
|
+
return _regenerator.default.wrap(function (_context) {
|
|
70
71
|
while (1) switch (_context.prev = _context.next) {
|
|
71
72
|
case 0:
|
|
72
73
|
_context.prev = 0;
|
|
73
|
-
_context.next =
|
|
74
|
-
return (0,
|
|
75
|
-
case
|
|
74
|
+
_context.next = 1;
|
|
75
|
+
return (0, _loadThemeCss.loadThemeCss)(themeId);
|
|
76
|
+
case 1:
|
|
76
77
|
css = _context.sent;
|
|
77
78
|
return _context.abrupt("return", {
|
|
78
79
|
id: themeId,
|
|
@@ -81,15 +82,15 @@ var getThemeStyles = /*#__PURE__*/function () {
|
|
|
81
82
|
},
|
|
82
83
|
css: css
|
|
83
84
|
});
|
|
84
|
-
case
|
|
85
|
-
_context.prev =
|
|
86
|
-
|
|
85
|
+
case 2:
|
|
86
|
+
_context.prev = 2;
|
|
87
|
+
_t = _context["catch"](0);
|
|
87
88
|
return _context.abrupt("return", undefined);
|
|
88
|
-
case
|
|
89
|
+
case 3:
|
|
89
90
|
case "end":
|
|
90
91
|
return _context.stop();
|
|
91
92
|
}
|
|
92
|
-
}, _callee, null, [[0,
|
|
93
|
+
}, _callee, null, [[0, 2]]);
|
|
93
94
|
}));
|
|
94
95
|
return function (_x2) {
|
|
95
96
|
return _ref2.apply(this, arguments);
|
|
@@ -98,49 +99,49 @@ var getThemeStyles = /*#__PURE__*/function () {
|
|
|
98
99
|
// Add custom themes if they're present
|
|
99
100
|
(0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
100
101
|
var _preferences$UNSAFE_t;
|
|
101
|
-
var _yield$import, getCustomThemeStyles, customThemeStyles;
|
|
102
|
-
return _regenerator.default.wrap(function
|
|
102
|
+
var _yield$import, getCustomThemeStyles, customThemeStyles, _t2;
|
|
103
|
+
return _regenerator.default.wrap(function (_context2) {
|
|
103
104
|
while (1) switch (_context2.prev = _context2.next) {
|
|
104
105
|
case 0:
|
|
105
|
-
if (!(preferences !== 'all' && preferences !== null && preferences !== void 0 && preferences.UNSAFE_themeOptions && (0,
|
|
106
|
-
_context2.next =
|
|
106
|
+
if (!(preferences !== 'all' && preferences !== null && preferences !== void 0 && preferences.UNSAFE_themeOptions && (0, _isValidBrandHex.isValidBrandHex)(preferences === null || preferences === void 0 || (_preferences$UNSAFE_t = preferences.UNSAFE_themeOptions) === null || _preferences$UNSAFE_t === void 0 ? void 0 : _preferences$UNSAFE_t.brandColor))) {
|
|
107
|
+
_context2.next = 5;
|
|
107
108
|
break;
|
|
108
109
|
}
|
|
109
110
|
_context2.prev = 1;
|
|
110
|
-
_context2.next =
|
|
111
|
+
_context2.next = 2;
|
|
111
112
|
return Promise.resolve().then(function () {
|
|
112
113
|
return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_atlassian-custom-theme" */
|
|
113
114
|
'./custom-theme'));
|
|
114
115
|
});
|
|
115
|
-
case
|
|
116
|
+
case 2:
|
|
116
117
|
_yield$import = _context2.sent;
|
|
117
118
|
getCustomThemeStyles = _yield$import.getCustomThemeStyles;
|
|
118
|
-
_context2.next =
|
|
119
|
+
_context2.next = 3;
|
|
119
120
|
return getCustomThemeStyles({
|
|
120
121
|
colorMode: (preferences === null || preferences === void 0 ? void 0 : preferences.colorMode) || _themeConfig.themeStateDefaults['colorMode'],
|
|
121
122
|
UNSAFE_themeOptions: preferences === null || preferences === void 0 ? void 0 : preferences.UNSAFE_themeOptions
|
|
122
123
|
});
|
|
123
|
-
case
|
|
124
|
+
case 3:
|
|
124
125
|
customThemeStyles = _context2.sent;
|
|
125
126
|
return _context2.abrupt("return", customThemeStyles);
|
|
126
|
-
case
|
|
127
|
-
_context2.prev =
|
|
128
|
-
|
|
127
|
+
case 4:
|
|
128
|
+
_context2.prev = 4;
|
|
129
|
+
_t2 = _context2["catch"](1);
|
|
129
130
|
return _context2.abrupt("return", undefined);
|
|
130
|
-
case
|
|
131
|
+
case 5:
|
|
131
132
|
return _context2.abrupt("return", undefined);
|
|
132
|
-
case
|
|
133
|
+
case 6:
|
|
133
134
|
case "end":
|
|
134
135
|
return _context2.stop();
|
|
135
136
|
}
|
|
136
|
-
}, _callee2, null, [[1,
|
|
137
|
+
}, _callee2, null, [[1, 4]]);
|
|
137
138
|
}))()]));
|
|
138
|
-
case
|
|
139
|
+
case 1:
|
|
139
140
|
results = _context3.sent;
|
|
140
141
|
return _context3.abrupt("return", results.flat().filter(function (theme) {
|
|
141
142
|
return theme !== undefined;
|
|
142
143
|
}));
|
|
143
|
-
case
|
|
144
|
+
case 2:
|
|
144
145
|
case "end":
|
|
145
146
|
return _context3.stop();
|
|
146
147
|
}
|
|
@@ -6,8 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _customTheme = require("./custom-theme");
|
|
8
8
|
var _themeConfig = require("./theme-config");
|
|
9
|
-
var _colorUtils = require("./utils/color-utils");
|
|
10
9
|
var _customThemeLoadingUtils = require("./utils/custom-theme-loading-utils");
|
|
10
|
+
var _isValidBrandHex = require("./utils/is-valid-brand-hex");
|
|
11
11
|
/**
|
|
12
12
|
* Synchronously generates and applies custom theme styles to the page.
|
|
13
13
|
*
|
|
@@ -29,7 +29,7 @@ var UNSAFE_loadCustomThemeStyles = function UNSAFE_loadCustomThemeStyles() {
|
|
|
29
29
|
_ref$UNSAFE_themeOpti = _ref.UNSAFE_themeOptions,
|
|
30
30
|
UNSAFE_themeOptions = _ref$UNSAFE_themeOpti === void 0 ? _themeConfig.themeStateDefaults['UNSAFE_themeOptions'] : _ref$UNSAFE_themeOpti;
|
|
31
31
|
// Load custom theme styles
|
|
32
|
-
if (UNSAFE_themeOptions && (0,
|
|
32
|
+
if (UNSAFE_themeOptions && (0, _isValidBrandHex.isValidBrandHex)(UNSAFE_themeOptions === null || UNSAFE_themeOptions === void 0 ? void 0 : UNSAFE_themeOptions.brandColor)) {
|
|
33
33
|
var attrOfMissingCustomStyles = (0, _customThemeLoadingUtils.findMissingCustomStyleElements)(UNSAFE_themeOptions, colorMode);
|
|
34
34
|
if (attrOfMissingCustomStyles.length !== 0) {
|
|
35
35
|
(0, _customTheme.loadAndAppendCustomThemeCss)({
|
|
@@ -12,15 +12,16 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
|
|
|
12
12
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
13
13
|
var _getGlobalTheme = _interopRequireDefault(require("./get-global-theme"));
|
|
14
14
|
var _themeConfig = require("./theme-config");
|
|
15
|
-
var _colorUtils = require("./utils/color-utils");
|
|
16
15
|
var _configurePage = _interopRequireDefault(require("./utils/configure-page"));
|
|
17
16
|
var _customThemeLoadingUtils = require("./utils/custom-theme-loading-utils");
|
|
17
|
+
var _getThemeOverridePreferences = require("./utils/get-theme-override-preferences");
|
|
18
18
|
var _getThemePreferences = require("./utils/get-theme-preferences");
|
|
19
|
+
var _isValidBrandHex = require("./utils/is-valid-brand-hex");
|
|
19
20
|
var _themeLoading = require("./utils/theme-loading");
|
|
20
21
|
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
|
|
21
22
|
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
22
23
|
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
23
|
-
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var
|
|
24
|
+
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t2 in e) "default" !== _t2 && {}.hasOwnProperty.call(e, _t2) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t2)) && (i.get || i.set) ? o(f, _t2, i) : f[_t2] = e[_t2]); return f; })(e, t); }
|
|
24
25
|
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; }
|
|
25
26
|
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) { (0, _defineProperty2.default)(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; }
|
|
26
27
|
/**
|
|
@@ -79,8 +80,9 @@ var setGlobalTheme = /*#__PURE__*/function () {
|
|
|
79
80
|
_step,
|
|
80
81
|
themeId,
|
|
81
82
|
autoUnbind,
|
|
82
|
-
_args3 = arguments
|
|
83
|
-
|
|
83
|
+
_args3 = arguments,
|
|
84
|
+
_t;
|
|
85
|
+
return _regenerator.default.wrap(function (_context3) {
|
|
84
86
|
while (1) switch (_context3.prev = _context3.next) {
|
|
85
87
|
case 0:
|
|
86
88
|
nextThemeState = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : {};
|
|
@@ -114,14 +116,14 @@ var setGlobalTheme = /*#__PURE__*/function () {
|
|
|
114
116
|
loadingStrategy = themeLoader ? themeLoader : _themeLoading.loadAndAppendThemeCss; // Load standard themes
|
|
115
117
|
loadingTasks = themePreferences.map( /*#__PURE__*/function () {
|
|
116
118
|
var _ref3 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee(themeId) {
|
|
117
|
-
return _regenerator.default.wrap(function
|
|
119
|
+
return _regenerator.default.wrap(function (_context) {
|
|
118
120
|
while (1) switch (_context.prev = _context.next) {
|
|
119
121
|
case 0:
|
|
120
|
-
_context.next =
|
|
122
|
+
_context.next = 1;
|
|
121
123
|
return loadingStrategy(themeId);
|
|
122
|
-
case
|
|
124
|
+
case 1:
|
|
123
125
|
return _context.abrupt("return", _context.sent);
|
|
124
|
-
case
|
|
126
|
+
case 2:
|
|
125
127
|
case "end":
|
|
126
128
|
return _context.stop();
|
|
127
129
|
}
|
|
@@ -131,22 +133,22 @@ var setGlobalTheme = /*#__PURE__*/function () {
|
|
|
131
133
|
return _ref3.apply(this, arguments);
|
|
132
134
|
};
|
|
133
135
|
}()); // Load custom themes if needed
|
|
134
|
-
if (!themeLoader && UNSAFE_themeOptions && (0,
|
|
136
|
+
if (!themeLoader && UNSAFE_themeOptions && (0, _isValidBrandHex.isValidBrandHex)(UNSAFE_themeOptions === null || UNSAFE_themeOptions === void 0 ? void 0 : UNSAFE_themeOptions.brandColor)) {
|
|
135
137
|
mode = colorMode || _themeConfig.themeStateDefaults['colorMode'];
|
|
136
138
|
attrOfMissingCustomStyles = (0, _customThemeLoadingUtils.findMissingCustomStyleElements)(UNSAFE_themeOptions, mode);
|
|
137
139
|
if (attrOfMissingCustomStyles.length > 0) {
|
|
138
140
|
// Load custom theme styles
|
|
139
141
|
loadingTasks.push((0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee2() {
|
|
140
142
|
var _yield$import, loadAndAppendCustomThemeCss;
|
|
141
|
-
return _regenerator.default.wrap(function
|
|
143
|
+
return _regenerator.default.wrap(function (_context2) {
|
|
142
144
|
while (1) switch (_context2.prev = _context2.next) {
|
|
143
145
|
case 0:
|
|
144
|
-
_context2.next =
|
|
146
|
+
_context2.next = 1;
|
|
145
147
|
return Promise.resolve().then(function () {
|
|
146
148
|
return _interopRequireWildcard(require( /* webpackChunkName: "@atlaskit-internal_atlassian-custom-theme" */
|
|
147
149
|
'./custom-theme'));
|
|
148
150
|
});
|
|
149
|
-
case
|
|
151
|
+
case 1:
|
|
150
152
|
_yield$import = _context2.sent;
|
|
151
153
|
loadAndAppendCustomThemeCss = _yield$import.loadAndAppendCustomThemeCss;
|
|
152
154
|
loadAndAppendCustomThemeCss({
|
|
@@ -155,7 +157,7 @@ var setGlobalTheme = /*#__PURE__*/function () {
|
|
|
155
157
|
attrOfMissingCustomStyles[0],
|
|
156
158
|
UNSAFE_themeOptions: UNSAFE_themeOptions
|
|
157
159
|
});
|
|
158
|
-
case
|
|
160
|
+
case 2:
|
|
159
161
|
case "end":
|
|
160
162
|
return _context2.stop();
|
|
161
163
|
}
|
|
@@ -163,44 +165,44 @@ var setGlobalTheme = /*#__PURE__*/function () {
|
|
|
163
165
|
}))());
|
|
164
166
|
}
|
|
165
167
|
}
|
|
166
|
-
_context3.next =
|
|
168
|
+
_context3.next = 1;
|
|
167
169
|
return Promise.all(loadingTasks);
|
|
168
|
-
case
|
|
170
|
+
case 1:
|
|
169
171
|
// Load override themes after standard themes
|
|
170
|
-
themeOverridePreferences = (0,
|
|
172
|
+
themeOverridePreferences = (0, _getThemeOverridePreferences.getThemeOverridePreferences)(themeState);
|
|
171
173
|
_iterator = _createForOfIteratorHelper(themeOverridePreferences);
|
|
172
|
-
_context3.prev =
|
|
174
|
+
_context3.prev = 2;
|
|
173
175
|
_iterator.s();
|
|
174
|
-
case
|
|
176
|
+
case 3:
|
|
175
177
|
if ((_step = _iterator.n()).done) {
|
|
176
|
-
_context3.next =
|
|
178
|
+
_context3.next = 5;
|
|
177
179
|
break;
|
|
178
180
|
}
|
|
179
181
|
themeId = _step.value;
|
|
180
|
-
_context3.next =
|
|
182
|
+
_context3.next = 4;
|
|
181
183
|
return loadingStrategy(themeId);
|
|
182
|
-
case
|
|
183
|
-
_context3.next =
|
|
184
|
+
case 4:
|
|
185
|
+
_context3.next = 3;
|
|
184
186
|
break;
|
|
185
|
-
case
|
|
186
|
-
_context3.next =
|
|
187
|
+
case 5:
|
|
188
|
+
_context3.next = 7;
|
|
187
189
|
break;
|
|
188
|
-
case
|
|
189
|
-
_context3.prev =
|
|
190
|
-
|
|
191
|
-
_iterator.e(
|
|
192
|
-
case
|
|
193
|
-
_context3.prev =
|
|
190
|
+
case 6:
|
|
191
|
+
_context3.prev = 6;
|
|
192
|
+
_t = _context3["catch"](2);
|
|
193
|
+
_iterator.e(_t);
|
|
194
|
+
case 7:
|
|
195
|
+
_context3.prev = 7;
|
|
194
196
|
_iterator.f();
|
|
195
|
-
return _context3.finish(
|
|
196
|
-
case
|
|
197
|
+
return _context3.finish(7);
|
|
198
|
+
case 8:
|
|
197
199
|
autoUnbind = (0, _configurePage.default)(themeState);
|
|
198
200
|
return _context3.abrupt("return", autoUnbind);
|
|
199
|
-
case
|
|
201
|
+
case 9:
|
|
200
202
|
case "end":
|
|
201
203
|
return _context3.stop();
|
|
202
204
|
}
|
|
203
|
-
}, _callee3, null, [[
|
|
205
|
+
}, _callee3, null, [[2, 6, 7, 8]]);
|
|
204
206
|
}));
|
|
205
207
|
return function setGlobalTheme() {
|
|
206
208
|
return _ref.apply(this, arguments);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.themeColorModes = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Theme modes: The general purpose of a theme.
|
|
9
|
+
* This attr is used to apply the appropriate system-preference option
|
|
10
|
+
* It may also be used as a selector for mode-specific overrides such as light/dark images.
|
|
11
|
+
* The idea is there may exist many color themes, but every theme must either fit into light or dark.
|
|
12
|
+
*/
|
|
13
|
+
var themeColorModes = exports.themeColorModes = ['light', 'dark', 'auto'];
|
package/dist/cjs/theme-config.js
CHANGED
|
@@ -1,10 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
|
-
exports.
|
|
7
|
+
exports.default = void 0;
|
|
8
|
+
Object.defineProperty(exports, "themeColorModes", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function get() {
|
|
11
|
+
return _themeColorModes.themeColorModes;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
Object.defineProperty(exports, "themeIds", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function get() {
|
|
17
|
+
return _themeIds.themeIds;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
exports.themeStateDefaults = exports.themeIdsWithOverrides = void 0;
|
|
21
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
7
22
|
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
23
|
+
var _themeIds = require("./theme-ids");
|
|
24
|
+
var _themeColorModes = require("./theme-color-modes");
|
|
8
25
|
/**
|
|
9
26
|
* This file contains the source of truth for themes and all associated meta data.
|
|
10
27
|
*/
|
|
@@ -28,30 +45,16 @@ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
|
|
|
28
45
|
* In the future other types may be introduced such as typography.
|
|
29
46
|
*/
|
|
30
47
|
|
|
31
|
-
/**
|
|
32
|
-
* Theme modes: The general purpose of a theme.
|
|
33
|
-
* This attr is used to apply the appropriate system-preference option
|
|
34
|
-
* It may also be used as a selector for mode-specific overrides such as light/dark images.
|
|
35
|
-
* The idea is there may exist many color themes, but every theme must either fit into light or dark.
|
|
36
|
-
*/
|
|
37
|
-
var themeColorModes = exports.themeColorModes = ['light', 'dark', 'auto'];
|
|
38
48
|
/**
|
|
39
49
|
* Contrast preferences: The system contrast preference
|
|
40
50
|
*/
|
|
41
51
|
var themeContrastModes = ['more', 'no-preference', 'auto'];
|
|
42
|
-
/**
|
|
43
|
-
* Theme ids: The value that will be mounted to the DOM as a data attr
|
|
44
|
-
* For example: `data-theme="light:light dark:dark spacing:spacing"
|
|
45
|
-
*
|
|
46
|
-
* These ids must be kebab case
|
|
47
|
-
*/
|
|
48
|
-
var themeIds = exports.themeIds = ['light-increased-contrast', 'light', 'light-future', 'dark', 'dark-future', 'dark-increased-contrast', 'spacing', 'shape', 'typography', 'motion'];
|
|
49
52
|
/**
|
|
50
53
|
* Theme override ids: the equivalent of themeIds for theme overrides.
|
|
51
54
|
* Theme overrides are temporary and there may not be any defined at times.
|
|
52
55
|
*/
|
|
53
56
|
var themeOverrideIds = [];
|
|
54
|
-
var themeIdsWithOverrides = exports.themeIdsWithOverrides = [].concat(themeIds, themeOverrideIds);
|
|
57
|
+
var themeIdsWithOverrides = exports.themeIdsWithOverrides = [].concat((0, _toConsumableArray2.default)(_themeIds.themeIds), themeOverrideIds);
|
|
55
58
|
|
|
56
59
|
/**
|
|
57
60
|
* Theme to use a base. This will create the theme as
|
|
@@ -194,6 +197,7 @@ function getMotionDefault() {
|
|
|
194
197
|
/**
|
|
195
198
|
* themeStateDefaults: the default values for ThemeState used by theming utilities
|
|
196
199
|
*/
|
|
200
|
+
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
197
201
|
var themeStateDefaults = exports.themeStateDefaults = {
|
|
198
202
|
colorMode: 'auto',
|
|
199
203
|
contrastMode: 'auto',
|
|
@@ -210,4 +214,5 @@ var themeStateDefaults = exports.themeStateDefaults = {
|
|
|
210
214
|
* Represents theme state once mounted to the page
|
|
211
215
|
* (the page doesn't have an "auto" color mode, it's either light or dark)
|
|
212
216
|
*/
|
|
217
|
+
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
213
218
|
var _default = exports.default = themeConfig;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.themeIds = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Theme ids: The value that will be mounted to the DOM as a data attr
|
|
9
|
+
* For example: `data-theme="light:light dark:dark spacing:spacing"
|
|
10
|
+
*
|
|
11
|
+
* These ids must be kebab case
|
|
12
|
+
*/
|
|
13
|
+
var themeIds = exports.themeIds = ['light-increased-contrast', 'light', 'light-future', 'dark', 'dark-future', 'dark-increased-contrast', 'spacing', 'shape', 'typography', 'motion'];
|
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports.themeStringToObject = exports.themeObjectToString = void 0;
|
|
8
8
|
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
9
9
|
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
|
-
var
|
|
10
|
+
var _themeIds = require("./theme-ids");
|
|
11
11
|
var themeKinds = ['light', 'dark', 'spacing', 'typography', 'shape', 'motion'];
|
|
12
12
|
var customThemeOptions = 'UNSAFE_themeOptions';
|
|
13
13
|
var isThemeKind = function isThemeKind(themeKind) {
|
|
@@ -16,7 +16,7 @@ var isThemeKind = function isThemeKind(themeKind) {
|
|
|
16
16
|
}) !== undefined;
|
|
17
17
|
};
|
|
18
18
|
var isThemeIds = function isThemeIds(themeId) {
|
|
19
|
-
return
|
|
19
|
+
return _themeIds.themeIds.find(function (id) {
|
|
20
20
|
return id === themeId;
|
|
21
21
|
}) !== undefined;
|
|
22
22
|
};
|
|
@@ -73,6 +73,7 @@ var themeStringToObject = exports.themeStringToObject = function themeStringToOb
|
|
|
73
73
|
* // returns 'dark:dark light:light spacing:spacing'
|
|
74
74
|
* ```
|
|
75
75
|
*/
|
|
76
|
+
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
76
77
|
var themeObjectToString = exports.themeObjectToString = function themeObjectToString(themeState) {
|
|
77
78
|
return Object.entries(themeState).reduce(function (themeString, _ref3) {
|
|
78
79
|
var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
|
|
@@ -3,17 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
|
|
6
|
+
exports.getBoxShadow = void 0;
|
|
7
|
+
Object.defineProperty(exports, "hexToRGBAValues", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function get() {
|
|
10
|
+
return _hexToRgbaValues.hexToRGBAValues;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
var _hexToRgbaValues = require("./hex-to-rgba-values");
|
|
17
14
|
/**
|
|
18
15
|
* Returns a box shadow formatted for CSS from a ShadowToken raw value.
|
|
19
16
|
*
|
|
@@ -25,7 +22,7 @@ var getBoxShadow = exports.getBoxShadow = function getBoxShadow(rawShadow) {
|
|
|
25
22
|
offset = _ref.offset,
|
|
26
23
|
color = _ref.color,
|
|
27
24
|
opacity = _ref.opacity;
|
|
28
|
-
var _hexToRGBAValues = hexToRGBAValues(color),
|
|
25
|
+
var _hexToRGBAValues = (0, _hexToRgbaValues.hexToRGBAValues)(color),
|
|
29
26
|
r = _hexToRGBAValues.r,
|
|
30
27
|
g = _hexToRGBAValues.g,
|
|
31
28
|
b = _hexToRGBAValues.b;
|