@atlaskit/tokens 13.0.4 → 13.1.1
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 +16 -0
- package/codemods/css-to-design-tokens/lib/colors.tsx +3 -8
- package/codemods/css-to-design-tokens/lib/declaration.tsx +3 -13
- package/codemods/css-to-design-tokens/lib/extract-between-parentheses.tsx +4 -0
- package/codemods/css-to-design-tokens/lib/extract-less-var-name.tsx +3 -0
- package/codemods/css-to-design-tokens/lib/get-css-var-meta.tsx +13 -0
- package/codemods/css-to-design-tokens/lib/get-named-color-meta.tsx +5 -0
- package/codemods/css-to-design-tokens/lib/get-raw-color-meta.tsx +11 -0
- package/codemods/css-to-design-tokens/lib/is-css-declaration.tsx +3 -0
- package/codemods/css-to-design-tokens/lib/is-known-css-variable.tsx +5 -0
- package/codemods/css-to-design-tokens/lib/known-named-colors.tsx +150 -0
- package/codemods/css-to-design-tokens/lib/known-raw-colors.tsx +17 -0
- package/codemods/css-to-design-tokens/lib/known-variables.tsx +167 -0
- package/codemods/css-to-design-tokens/lib/legacy-colors.tsx +3 -335
- package/codemods/css-to-design-tokens/lib/meta.tsx +3 -28
- package/codemods/css-to-design-tokens/lib/split-css-value.tsx +4 -0
- package/codemods/css-to-design-tokens/lib/value.tsx +6 -9
- package/codemods/css-to-design-tokens/transform.tsx +3 -1
- package/dist/cjs/artifacts/palettes-raw/palette.js +35 -1
- 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/constants.js +1 -0
- package/dist/cjs/entry-points/theme-state-transformer.js +4 -3
- package/dist/cjs/entry-points/token-metadata.codegen.js +2 -2
- package/dist/cjs/get-custom-theme-styles.js +7 -6
- 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 +27 -27
- package/dist/cjs/index.js +4 -3
- package/dist/cjs/is-color-mode.js +9 -0
- package/dist/cjs/is-theme-ids.js +12 -0
- package/dist/cjs/is-theme-kind.js +12 -0
- package/dist/cjs/set-global-theme.js +32 -31
- package/dist/cjs/theme-config.js +9 -43
- package/dist/cjs/theme-object-to-string.js +42 -0
- package/dist/cjs/theme-options-schema.js +1 -0
- package/dist/cjs/theme-state-defaults.js +39 -0
- package/dist/cjs/theme-state.js +5 -0
- package/dist/cjs/theme-string-to-object.js +51 -0
- package/dist/cjs/utils/additional-contrast-checker.js +43 -0
- package/dist/cjs/utils/custom-theme-loading-utils.js +0 -20
- package/dist/cjs/utils/custom-theme-token-contrast-check.js +2 -38
- package/dist/cjs/utils/delta-e.js +26 -0
- package/dist/cjs/utils/generate-colors.js +47 -0
- package/dist/cjs/utils/generate-token-map-with-contrast-check.js +32 -0
- package/dist/cjs/utils/{generate-custom-color-ramp.js → generate-token-map.js} +6 -71
- package/dist/cjs/utils/get-closest-color-index.js +3 -2
- package/dist/cjs/utils/get-contrast-ratio.js +22 -0
- package/dist/cjs/utils/hct-color-utils/alpha-from-argb.js +12 -0
- package/dist/cjs/utils/hct-color-utils/argb-from-linrgb.js +17 -0
- package/dist/cjs/utils/hct-color-utils/argb-from-lstar.js +21 -0
- package/dist/cjs/utils/hct-color-utils/argb-from-rgba.js +24 -0
- package/dist/cjs/utils/hct-color-utils/argb-from-xyz.js +29 -0
- package/dist/cjs/utils/hct-color-utils/blue-from-argb.js +12 -0
- package/dist/cjs/utils/hct-color-utils/clamp-component.js +15 -0
- package/dist/cjs/utils/hct-color-utils/contrast.js +10 -11
- package/dist/cjs/utils/hct-color-utils/green-from-argb.js +12 -0
- package/dist/cjs/utils/hct-color-utils/hct.js +18 -12
- package/dist/cjs/utils/hct-color-utils/index.js +4 -3
- package/dist/cjs/utils/hct-color-utils/lab-f.js +15 -0
- package/dist/cjs/utils/hct-color-utils/lab-invf.js +16 -0
- package/dist/cjs/utils/hct-color-utils/lstar-from-argb.js +34 -0
- package/dist/cjs/utils/hct-color-utils/lstar-from-y.js +21 -0
- package/dist/cjs/utils/hct-color-utils/red-from-argb.js +12 -0
- package/dist/cjs/utils/hct-color-utils/rgba-from-argb.js +28 -0
- package/dist/cjs/utils/hct-color-utils/rgba.js +1 -0
- package/dist/cjs/utils/hct-color-utils/viewing-conditions.js +5 -4
- package/dist/cjs/utils/hct-color-utils/white-point-d65.js +14 -0
- package/dist/cjs/utils/hct-color-utils/y-from-lstar.js +21 -0
- package/dist/cjs/utils/hex-to-hsl.js +52 -0
- package/dist/cjs/utils/hex-to-rgb-a.js +20 -0
- package/dist/cjs/utils/hex-to-rgb.js +19 -0
- package/dist/cjs/utils/is-valid-hex.js +10 -0
- package/dist/cjs/utils/load-theme-css.js +4 -4
- package/dist/cjs/utils/reduce-token-map.js +18 -0
- package/dist/cjs/utils/rgb-to-lab.js +24 -0
- package/dist/cjs/utils/theme-loading.js +8 -8
- package/dist/es2019/artifacts/palettes-raw/palette.js +35 -1
- 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/constants.js +1 -0
- package/dist/es2019/entry-points/theme-state-transformer.js +2 -1
- package/dist/es2019/entry-points/token-metadata.codegen.js +2 -2
- package/dist/es2019/get-custom-theme-styles.js +3 -2
- package/dist/es2019/get-global-theme.js +1 -1
- package/dist/es2019/get-theme-html-attrs.js +1 -1
- package/dist/es2019/index.js +2 -1
- package/dist/es2019/is-color-mode.js +3 -0
- package/dist/es2019/is-theme-ids.js +4 -0
- package/dist/es2019/is-theme-kind.js +4 -0
- package/dist/es2019/theme-config.js +5 -44
- package/dist/es2019/theme-object-to-string.js +28 -0
- package/dist/es2019/theme-options-schema.js +0 -0
- package/dist/es2019/theme-state-defaults.js +34 -0
- package/dist/es2019/theme-state.js +1 -0
- package/dist/es2019/theme-string-to-object.js +38 -0
- package/dist/es2019/utils/additional-contrast-checker.js +39 -0
- package/dist/es2019/utils/custom-theme-loading-utils.js +1 -9
- package/dist/es2019/utils/custom-theme-token-contrast-check.js +1 -39
- package/dist/es2019/utils/delta-e.js +20 -0
- package/dist/es2019/utils/generate-colors.js +39 -0
- package/dist/es2019/utils/generate-token-map-with-contrast-check.js +21 -0
- package/dist/es2019/utils/{generate-custom-color-ramp.js → generate-token-map.js} +3 -59
- package/dist/es2019/utils/get-closest-color-index.js +2 -1
- package/dist/es2019/utils/get-contrast-ratio.js +16 -0
- package/dist/es2019/utils/hct-color-utils/alpha-from-argb.js +6 -0
- package/dist/es2019/utils/hct-color-utils/argb-from-linrgb.js +12 -0
- package/dist/es2019/utils/hct-color-utils/argb-from-lstar.js +16 -0
- package/dist/es2019/utils/hct-color-utils/argb-from-rgba.js +19 -0
- package/dist/es2019/utils/hct-color-utils/argb-from-xyz.js +24 -0
- package/dist/es2019/utils/hct-color-utils/blue-from-argb.js +6 -0
- package/dist/es2019/utils/hct-color-utils/clamp-component.js +9 -0
- package/dist/es2019/utils/hct-color-utils/contrast.js +10 -10
- package/dist/es2019/utils/hct-color-utils/green-from-argb.js +6 -0
- package/dist/es2019/utils/hct-color-utils/hct.js +19 -12
- package/dist/es2019/utils/hct-color-utils/index.js +2 -1
- package/dist/es2019/utils/hct-color-utils/lab-f.js +9 -0
- package/dist/es2019/utils/hct-color-utils/lab-invf.js +10 -0
- package/dist/es2019/utils/hct-color-utils/lstar-from-argb.js +28 -0
- package/dist/es2019/utils/hct-color-utils/lstar-from-y.js +16 -0
- package/dist/es2019/utils/hct-color-utils/red-from-argb.js +6 -0
- package/dist/es2019/utils/hct-color-utils/rgba-from-argb.js +22 -0
- package/dist/es2019/utils/hct-color-utils/rgba.js +0 -0
- package/dist/es2019/utils/hct-color-utils/viewing-conditions.js +4 -3
- package/dist/es2019/utils/hct-color-utils/white-point-d65.js +8 -0
- package/dist/es2019/utils/hct-color-utils/y-from-lstar.js +16 -0
- package/dist/es2019/utils/hex-to-hsl.js +46 -0
- package/dist/es2019/utils/hex-to-rgb-a.js +14 -0
- package/dist/es2019/utils/hex-to-rgb.js +13 -0
- package/dist/es2019/utils/is-valid-hex.js +2 -0
- package/dist/es2019/utils/reduce-token-map.js +7 -0
- package/dist/es2019/utils/rgb-to-lab.js +18 -0
- package/dist/esm/artifacts/palettes-raw/palette.js +35 -1
- 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/constants.js +1 -0
- package/dist/esm/entry-points/theme-state-transformer.js +2 -1
- package/dist/esm/entry-points/token-metadata.codegen.js +2 -2
- package/dist/esm/get-custom-theme-styles.js +3 -2
- 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 +26 -26
- package/dist/esm/index.js +2 -1
- package/dist/esm/is-color-mode.js +3 -0
- package/dist/esm/is-theme-ids.js +6 -0
- package/dist/esm/is-theme-kind.js +6 -0
- package/dist/esm/set-global-theme.js +31 -30
- package/dist/esm/theme-config.js +5 -44
- package/dist/esm/theme-object-to-string.js +35 -0
- package/dist/esm/theme-options-schema.js +0 -0
- package/dist/esm/theme-state-defaults.js +34 -0
- package/dist/esm/theme-state.js +1 -0
- package/dist/esm/theme-string-to-object.js +44 -0
- package/dist/esm/utils/additional-contrast-checker.js +36 -0
- package/dist/esm/utils/custom-theme-loading-utils.js +1 -13
- package/dist/esm/utils/custom-theme-token-contrast-check.js +1 -36
- package/dist/esm/utils/delta-e.js +20 -0
- package/dist/esm/utils/generate-colors.js +40 -0
- package/dist/esm/utils/generate-token-map-with-contrast-check.js +25 -0
- package/dist/esm/utils/{generate-custom-color-ramp.js → generate-token-map.js} +3 -63
- package/dist/esm/utils/get-closest-color-index.js +2 -1
- package/dist/esm/utils/get-contrast-ratio.js +16 -0
- package/dist/esm/utils/hct-color-utils/alpha-from-argb.js +6 -0
- package/dist/esm/utils/hct-color-utils/argb-from-linrgb.js +12 -0
- package/dist/esm/utils/hct-color-utils/argb-from-lstar.js +16 -0
- package/dist/esm/utils/hct-color-utils/argb-from-rgba.js +18 -0
- package/dist/esm/utils/hct-color-utils/argb-from-xyz.js +24 -0
- package/dist/esm/utils/hct-color-utils/blue-from-argb.js +6 -0
- package/dist/esm/utils/hct-color-utils/clamp-component.js +9 -0
- package/dist/esm/utils/hct-color-utils/contrast.js +10 -10
- package/dist/esm/utils/hct-color-utils/green-from-argb.js +6 -0
- package/dist/esm/utils/hct-color-utils/hct.js +19 -12
- package/dist/esm/utils/hct-color-utils/index.js +2 -1
- package/dist/esm/utils/hct-color-utils/lab-f.js +9 -0
- package/dist/esm/utils/hct-color-utils/lab-invf.js +10 -0
- package/dist/esm/utils/hct-color-utils/lstar-from-argb.js +28 -0
- package/dist/esm/utils/hct-color-utils/lstar-from-y.js +16 -0
- package/dist/esm/utils/hct-color-utils/red-from-argb.js +6 -0
- package/dist/esm/utils/hct-color-utils/rgba-from-argb.js +22 -0
- package/dist/esm/utils/hct-color-utils/rgba.js +0 -0
- package/dist/esm/utils/hct-color-utils/viewing-conditions.js +5 -4
- package/dist/esm/utils/hct-color-utils/white-point-d65.js +8 -0
- package/dist/esm/utils/hct-color-utils/y-from-lstar.js +16 -0
- package/dist/esm/utils/hex-to-hsl.js +46 -0
- package/dist/esm/utils/hex-to-rgb-a.js +14 -0
- package/dist/esm/utils/hex-to-rgb.js +13 -0
- package/dist/esm/utils/is-valid-hex.js +4 -0
- package/dist/esm/utils/load-theme-css.js +4 -4
- package/dist/esm/utils/reduce-token-map.js +11 -0
- package/dist/esm/utils/rgb-to-lab.js +18 -0
- package/dist/esm/utils/theme-loading.js +8 -8
- package/dist/types/artifacts/palettes-raw/palette.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/entry-points/theme-state-transformer.d.ts +2 -1
- package/dist/types/entry-points/token-metadata.codegen.d.ts +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/is-color-mode.d.ts +2 -0
- package/dist/types/is-theme-ids.d.ts +2 -0
- package/dist/types/is-theme-kind.d.ts +4 -0
- package/dist/types/theme-color-modes.d.ts +1 -0
- package/dist/types/theme-config.d.ts +8 -40
- package/dist/types/theme-ids.d.ts +1 -0
- package/dist/types/theme-object-to-string.d.ts +13 -0
- package/dist/types/theme-options-schema.d.ts +7 -0
- package/dist/types/theme-state-defaults.d.ts +14 -0
- package/dist/types/theme-state.d.ts +17 -0
- package/dist/types/{theme-state-transformer.d.ts → theme-string-to-object.d.ts} +0 -12
- package/dist/types/utils/additional-contrast-checker.d.ts +9 -0
- package/dist/types/utils/custom-theme-loading-utils.d.ts +1 -6
- package/dist/types/utils/custom-theme-token-contrast-check.d.ts +0 -9
- package/dist/types/utils/delta-e.d.ts +1 -0
- package/dist/types/utils/generate-colors.d.ts +5 -0
- package/dist/types/utils/{generate-custom-color-ramp.d.ts → generate-token-map-with-contrast-check.d.ts} +1 -6
- package/dist/types/utils/generate-token-map.d.ts +9 -0
- package/dist/types/utils/get-contrast-ratio.d.ts +1 -0
- package/dist/types/utils/hct-color-utils/alpha-from-argb.d.ts +4 -0
- package/dist/types/utils/hct-color-utils/argb-from-linrgb.d.ts +4 -0
- package/dist/types/utils/hct-color-utils/argb-from-lstar.d.ts +8 -0
- package/dist/types/utils/hct-color-utils/argb-from-rgba.d.ts +8 -0
- package/dist/types/utils/hct-color-utils/argb-from-xyz.d.ts +4 -0
- package/dist/types/utils/hct-color-utils/blue-from-argb.d.ts +4 -0
- package/dist/types/utils/hct-color-utils/clamp-component.d.ts +1 -0
- package/dist/types/utils/hct-color-utils/green-from-argb.d.ts +4 -0
- package/dist/types/utils/hct-color-utils/index.d.ts +2 -1
- package/dist/types/utils/hct-color-utils/lab-f.d.ts +1 -0
- package/dist/types/utils/hct-color-utils/lab-invf.d.ts +1 -0
- package/dist/types/utils/hct-color-utils/lstar-from-argb.d.ts +7 -0
- package/dist/types/utils/hct-color-utils/lstar-from-y.d.ts +12 -0
- package/dist/types/utils/hct-color-utils/red-from-argb.d.ts +4 -0
- package/dist/types/utils/hct-color-utils/rgba-from-argb.d.ts +8 -0
- package/dist/types/utils/hct-color-utils/rgba.d.ts +14 -0
- package/dist/types/utils/hct-color-utils/white-point-d65.d.ts +6 -0
- package/dist/types/utils/hct-color-utils/y-from-lstar.d.ts +12 -0
- package/dist/types/utils/hex-to-hsl.d.ts +1 -0
- package/dist/types/utils/hex-to-rgb-a.d.ts +1 -0
- package/dist/types/utils/hex-to-rgb.d.ts +1 -0
- package/dist/types/utils/is-valid-hex.d.ts +1 -0
- package/dist/types/utils/reduce-token-map.d.ts +6 -0
- package/dist/types/utils/rgb-to-lab.d.ts +1 -0
- package/dist/types-ts4.5/artifacts/palettes-raw/palette.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/entry-points/theme-state-transformer.d.ts +2 -1
- package/dist/types-ts4.5/entry-points/token-metadata.codegen.d.ts +1 -1
- package/dist/types-ts4.5/index.d.ts +2 -1
- package/dist/types-ts4.5/is-color-mode.d.ts +2 -0
- package/dist/types-ts4.5/is-theme-ids.d.ts +2 -0
- package/dist/types-ts4.5/is-theme-kind.d.ts +11 -0
- package/dist/types-ts4.5/theme-color-modes.d.ts +1 -0
- package/dist/types-ts4.5/theme-config.d.ts +8 -40
- package/dist/types-ts4.5/theme-ids.d.ts +1 -0
- package/dist/types-ts4.5/theme-object-to-string.d.ts +13 -0
- package/dist/types-ts4.5/theme-options-schema.d.ts +7 -0
- package/dist/types-ts4.5/theme-state-defaults.d.ts +14 -0
- package/dist/types-ts4.5/theme-state.d.ts +17 -0
- package/dist/types-ts4.5/{theme-state-transformer.d.ts → theme-string-to-object.d.ts} +0 -12
- package/dist/types-ts4.5/utils/additional-contrast-checker.d.ts +9 -0
- package/dist/types-ts4.5/utils/custom-theme-loading-utils.d.ts +1 -6
- package/dist/types-ts4.5/utils/custom-theme-token-contrast-check.d.ts +0 -9
- package/dist/types-ts4.5/utils/delta-e.d.ts +1 -0
- package/dist/types-ts4.5/utils/generate-colors.d.ts +5 -0
- package/dist/types-ts4.5/utils/{generate-custom-color-ramp.d.ts → generate-token-map-with-contrast-check.d.ts} +1 -8
- package/dist/types-ts4.5/utils/generate-token-map.d.ts +11 -0
- package/dist/types-ts4.5/utils/get-contrast-ratio.d.ts +1 -0
- package/dist/types-ts4.5/utils/hct-color-utils/alpha-from-argb.d.ts +4 -0
- package/dist/types-ts4.5/utils/hct-color-utils/argb-from-linrgb.d.ts +4 -0
- package/dist/types-ts4.5/utils/hct-color-utils/argb-from-lstar.d.ts +8 -0
- package/dist/types-ts4.5/utils/hct-color-utils/argb-from-rgba.d.ts +8 -0
- package/dist/types-ts4.5/utils/hct-color-utils/argb-from-xyz.d.ts +4 -0
- package/dist/types-ts4.5/utils/hct-color-utils/blue-from-argb.d.ts +4 -0
- package/dist/types-ts4.5/utils/hct-color-utils/clamp-component.d.ts +1 -0
- package/dist/types-ts4.5/utils/hct-color-utils/green-from-argb.d.ts +4 -0
- package/dist/types-ts4.5/utils/hct-color-utils/index.d.ts +2 -1
- package/dist/types-ts4.5/utils/hct-color-utils/lab-f.d.ts +1 -0
- package/dist/types-ts4.5/utils/hct-color-utils/lab-invf.d.ts +1 -0
- package/dist/types-ts4.5/utils/hct-color-utils/lstar-from-argb.d.ts +7 -0
- package/dist/types-ts4.5/utils/hct-color-utils/lstar-from-y.d.ts +12 -0
- package/dist/types-ts4.5/utils/hct-color-utils/red-from-argb.d.ts +4 -0
- package/dist/types-ts4.5/utils/hct-color-utils/rgba-from-argb.d.ts +8 -0
- package/dist/types-ts4.5/utils/hct-color-utils/rgba.d.ts +14 -0
- package/dist/types-ts4.5/utils/hct-color-utils/white-point-d65.d.ts +6 -0
- package/dist/types-ts4.5/utils/hct-color-utils/y-from-lstar.d.ts +12 -0
- package/dist/types-ts4.5/utils/hex-to-hsl.d.ts +5 -0
- package/dist/types-ts4.5/utils/hex-to-rgb-a.d.ts +6 -0
- package/dist/types-ts4.5/utils/hex-to-rgb.d.ts +5 -0
- package/dist/types-ts4.5/utils/is-valid-hex.d.ts +1 -0
- package/dist/types-ts4.5/utils/reduce-token-map.d.ts +6 -0
- package/dist/types-ts4.5/utils/rgb-to-lab.d.ts +5 -0
- 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/cjs/theme-state-transformer.js +0 -92
- package/dist/cjs/utils/color-utils.js +0 -168
- package/dist/cjs/utils/hct-color-utils/color-utils.js +0 -271
- package/dist/es2019/theme-state-transformer.js +0 -69
- package/dist/es2019/utils/color-utils.js +0 -128
- package/dist/es2019/utils/hct-color-utils/color-utils.js +0 -241
- package/dist/esm/theme-state-transformer.js +0 -85
- package/dist/esm/utils/color-utils.js +0 -130
- package/dist/esm/utils/hct-color-utils/color-utils.js +0 -240
- package/dist/types/utils/color-utils.d.ts +0 -10
- package/dist/types/utils/hct-color-utils/color-utils.d.ts +0 -88
- package/dist/types-ts4.5/utils/color-utils.d.ts +0 -23
- package/dist/types-ts4.5/utils/hct-color-utils/color-utils.d.ts +0 -88
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
* @codegen <<SignedSource::
|
|
3
|
+
* @codegen <<SignedSource::d7798f5da9c5cb814cf6b4e2e6137397>>
|
|
4
4
|
* @codegenCommand yarn build tokens
|
|
5
5
|
*/
|
|
6
6
|
|
|
@@ -4587,7 +4587,7 @@ const tokens = [{
|
|
|
4587
4587
|
"introduced": "0.0.15",
|
|
4588
4588
|
"description": "Use for backgrounds of elements in a disabled state."
|
|
4589
4589
|
},
|
|
4590
|
-
"value": "#
|
|
4590
|
+
"value": "#0515240F",
|
|
4591
4591
|
"filePath": "schema/themes/atlassian-light/color/background.tsx",
|
|
4592
4592
|
"isSource": true,
|
|
4593
4593
|
"original": {
|
|
@@ -4597,7 +4597,7 @@ const tokens = [{
|
|
|
4597
4597
|
"introduced": "0.0.15",
|
|
4598
4598
|
"description": "Use for backgrounds of elements in a disabled state."
|
|
4599
4599
|
},
|
|
4600
|
-
"value": "
|
|
4600
|
+
"value": "Neutral200A"
|
|
4601
4601
|
},
|
|
4602
4602
|
"name": "color.background.disabled",
|
|
4603
4603
|
"path": ["color", "background", "disabled"],
|
package/dist/es2019/constants.js
CHANGED
|
@@ -6,4 +6,5 @@ export const CUSTOM_THEME_ATTRIBUTE = 'data-custom-theme';
|
|
|
6
6
|
export const CSS_PREFIX = 'ds';
|
|
7
7
|
export const CSS_VAR_FULL = ['opacity', 'font', 'space', 'border', 'radius'];
|
|
8
8
|
export const TOKEN_NOT_FOUND_CSS_VAR = `--${CSS_PREFIX}-token-not-found`;
|
|
9
|
+
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
9
10
|
export const CURRENT_SURFACE_CSS_VAR = `--${CSS_PREFIX}-elevation-surface-current`;
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { themeStringToObject
|
|
1
|
+
export { themeStringToObject } from '../theme-string-to-object';
|
|
2
|
+
export { themeObjectToString } from '../theme-object-to-string';
|
|
@@ -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
|
|
|
@@ -2315,7 +2315,7 @@ export const tokens = [{
|
|
|
2315
2315
|
name: 'color.background.disabled',
|
|
2316
2316
|
path: ['color', 'background', 'disabled'],
|
|
2317
2317
|
description: 'Use for backgrounds of elements in a disabled state.',
|
|
2318
|
-
exampleValue: '#
|
|
2318
|
+
exampleValue: '#0515240F',
|
|
2319
2319
|
usageGuidelines: {
|
|
2320
2320
|
usage: 'The color for backgrounds. Use for areas behind content (e.g. color.background.neutral, color.background.selected)',
|
|
2321
2321
|
cssProperties: ['background-color']
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { COLOR_MODE_ATTRIBUTE, CUSTOM_THEME_ATTRIBUTE } from './constants';
|
|
2
2
|
import { themeStateDefaults } from './theme-config';
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { generateColors } from './utils/generate-colors';
|
|
4
|
+
import { generateTokenMapWithContrastCheck } from './utils/generate-token-map-with-contrast-check';
|
|
5
5
|
import { hash } from './utils/hash';
|
|
6
|
+
import { reduceTokenMap } from './utils/reduce-token-map';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* Takes a color mode and custom branding options, and returns an array of objects for use in applying custom styles to the document head.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { COLOR_MODE_ATTRIBUTE, THEME_DATA_ATTRIBUTE } from './constants';
|
|
2
2
|
import { themeColorModes } from './theme-color-modes';
|
|
3
|
-
import { themeStringToObject } from './theme-
|
|
3
|
+
import { themeStringToObject } from './theme-string-to-object';
|
|
4
4
|
const isThemeColorMode = colorMode => {
|
|
5
5
|
return themeColorModes.find(mode => mode === colorMode) !== undefined;
|
|
6
6
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
2
|
import { COLOR_MODE_ATTRIBUTE, CONTRAST_MODE_ATTRIBUTE, CUSTOM_THEME_ATTRIBUTE, THEME_DATA_ATTRIBUTE } from './constants';
|
|
3
3
|
import { themeStateDefaults } from './theme-config';
|
|
4
|
-
import { themeObjectToString } from './theme-
|
|
4
|
+
import { themeObjectToString } from './theme-object-to-string';
|
|
5
5
|
import { hash } from './utils/hash';
|
|
6
6
|
import { isValidBrandHex } from './utils/is-valid-brand-hex';
|
|
7
7
|
const defaultColorMode = 'light';
|
package/dist/es2019/index.js
CHANGED
|
@@ -9,6 +9,7 @@ export { default as getSSRAutoScript } from './get-ssr-auto-script';
|
|
|
9
9
|
export { default as useThemeObserver } from './use-theme-observer';
|
|
10
10
|
export { default as ThemeMutationObserver } from './theme-mutation-observer';
|
|
11
11
|
export { default as getGlobalTheme } from './get-global-theme';
|
|
12
|
-
export { themeStringToObject
|
|
12
|
+
export { themeStringToObject } from './theme-string-to-object';
|
|
13
|
+
export { themeObjectToString } from './theme-object-to-string';
|
|
13
14
|
export { default as themeImportMap } from './artifacts/theme-import-map';
|
|
14
15
|
export { COLOR_MODE_ATTRIBUTE, CURRENT_SURFACE_CSS_VAR, SUBTREE_THEME_ATTRIBUTE, THEME_DATA_ATTRIBUTE } from './constants';
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
|
-
import { themeIds } from './theme-ids';
|
|
3
1
|
/**
|
|
4
2
|
* This file contains the source of truth for themes and all associated meta data.
|
|
5
3
|
*/
|
|
6
4
|
|
|
5
|
+
import { themeIds } from './theme-ids';
|
|
6
|
+
|
|
7
7
|
/**
|
|
8
8
|
* Themes: The internal identifier of a theme.
|
|
9
9
|
* These ids are what the actual theme files/folders are called.
|
|
@@ -146,52 +146,13 @@ const themeConfig = {
|
|
|
146
146
|
}
|
|
147
147
|
};
|
|
148
148
|
|
|
149
|
-
/**
|
|
150
|
-
* ThemeOptionsSchema: additional configuration options used to customize Atlassian's themes
|
|
151
|
-
*/
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* ThemeState: the standard representation of an app's current theme and preferences
|
|
155
|
-
*/
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Can't evaluate typography feature flags at the module level,
|
|
159
|
-
* it will always resolve to false when server side rendered or when flags are loaded async.
|
|
160
|
-
*/
|
|
161
|
-
|
|
162
|
-
function getShapeDefault() {
|
|
163
|
-
if (fg('platform-dst-shape-theme-default')) {
|
|
164
|
-
return 'shape';
|
|
165
|
-
}
|
|
166
|
-
return undefined;
|
|
167
|
-
}
|
|
168
|
-
function getMotionDefault() {
|
|
169
|
-
if (fg('platform-dst-motion-theme-default')) {
|
|
170
|
-
return 'motion';
|
|
171
|
-
}
|
|
172
|
-
return undefined;
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* themeStateDefaults: the default values for ThemeState used by theming utilities
|
|
177
|
-
*/
|
|
178
|
-
export const themeStateDefaults = {
|
|
179
|
-
colorMode: 'auto',
|
|
180
|
-
contrastMode: 'auto',
|
|
181
|
-
dark: 'dark',
|
|
182
|
-
light: 'light',
|
|
183
|
-
shape: getShapeDefault,
|
|
184
|
-
spacing: 'spacing',
|
|
185
|
-
typography: 'typography',
|
|
186
|
-
motion: getMotionDefault,
|
|
187
|
-
UNSAFE_themeOptions: undefined
|
|
188
|
-
};
|
|
189
|
-
|
|
190
149
|
/**
|
|
191
150
|
* Represents theme state once mounted to the page
|
|
192
151
|
* (the page doesn't have an "auto" color mode, it's either light or dark)
|
|
193
152
|
*/
|
|
194
153
|
|
|
154
|
+
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
195
155
|
export default themeConfig;
|
|
196
156
|
export { themeColorModes } from './theme-color-modes';
|
|
197
|
-
export { themeIds } from './theme-ids';
|
|
157
|
+
export { themeIds } from './theme-ids';
|
|
158
|
+
export { themeStateDefaults } from './theme-state-defaults';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { isColorMode } from './is-color-mode';
|
|
2
|
+
import { isThemeIds } from './is-theme-ids';
|
|
3
|
+
import { isThemeKind } from './is-theme-kind';
|
|
4
|
+
const customThemeOptions = 'UNSAFE_themeOptions';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Converts a theme object to a string formatted for the `data-theme` HTML attribute.
|
|
8
|
+
*
|
|
9
|
+
* @param {object} themes The themes that should be applied.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```
|
|
13
|
+
* themeObjectToString({ dark: 'dark', light: 'light', spacing: 'spacing' });
|
|
14
|
+
* // returns 'dark:dark light:light spacing:spacing'
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export const themeObjectToString = themeState => Object.entries(themeState).reduce((themeString, [kind, id]) => {
|
|
18
|
+
if (
|
|
19
|
+
// colorMode theme state
|
|
20
|
+
kind === 'colorMode' && typeof id === 'string' && isColorMode(id) ||
|
|
21
|
+
// custom theme state
|
|
22
|
+
kind === customThemeOptions && typeof id === 'object' ||
|
|
23
|
+
// other theme states
|
|
24
|
+
isThemeKind(kind) && typeof id === 'string' && isThemeIds(id)) {
|
|
25
|
+
return themeString + `${themeString ? ' ' : ''}` + `${kind}:${typeof id === 'object' ? JSON.stringify(id) : id}`;
|
|
26
|
+
}
|
|
27
|
+
return themeString;
|
|
28
|
+
}, '');
|
|
File without changes
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Can't evaluate typography feature flags at the module level,
|
|
5
|
+
* it will always resolve to false when server side rendered or when flags are loaded async.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
function getShapeDefault() {
|
|
9
|
+
if (fg('platform-dst-shape-theme-default')) {
|
|
10
|
+
return 'shape';
|
|
11
|
+
}
|
|
12
|
+
return undefined;
|
|
13
|
+
}
|
|
14
|
+
function getMotionDefault() {
|
|
15
|
+
if (fg('platform-dst-motion-theme-default')) {
|
|
16
|
+
return 'motion';
|
|
17
|
+
}
|
|
18
|
+
return undefined;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* themeStateDefaults: the default values for ThemeState used by theming utilities
|
|
23
|
+
*/
|
|
24
|
+
export const themeStateDefaults = {
|
|
25
|
+
colorMode: 'auto',
|
|
26
|
+
contrastMode: 'auto',
|
|
27
|
+
dark: 'dark',
|
|
28
|
+
light: 'light',
|
|
29
|
+
shape: getShapeDefault,
|
|
30
|
+
spacing: 'spacing',
|
|
31
|
+
typography: 'typography',
|
|
32
|
+
motion: getMotionDefault,
|
|
33
|
+
UNSAFE_themeOptions: undefined
|
|
34
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { isColorMode } from './is-color-mode';
|
|
2
|
+
import { isThemeIds } from './is-theme-ids';
|
|
3
|
+
import { isThemeKind } from './is-theme-kind';
|
|
4
|
+
const customThemeOptions = 'UNSAFE_themeOptions';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Converts a string that is formatted for the `data-theme` HTML attribute
|
|
8
|
+
* to an object that can be passed to `setGlobalTheme`.
|
|
9
|
+
*
|
|
10
|
+
* @param {string} themes The themes that should be applied.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```
|
|
14
|
+
* themeStringToObject('dark:dark light:light spacing:spacing');
|
|
15
|
+
* // returns { dark: 'dark', light: 'light', spacing: 'spacing' }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export const themeStringToObject = themeState => {
|
|
19
|
+
return themeState.split(' ')
|
|
20
|
+
// @ts-ignore - TS1501 TypeScript 5.9.2 upgrade
|
|
21
|
+
.map(theme => theme.split(/:(.*)/s)).reduce((themeObject, [kind, id]) => {
|
|
22
|
+
if (kind === 'colorMode' && isColorMode(id)) {
|
|
23
|
+
themeObject[kind] = id;
|
|
24
|
+
}
|
|
25
|
+
if (isThemeKind(kind) && isThemeIds(id)) {
|
|
26
|
+
// @ts-expect-error FIXME - this is a valid ts error
|
|
27
|
+
themeObject[kind] = id;
|
|
28
|
+
}
|
|
29
|
+
if (kind === customThemeOptions) {
|
|
30
|
+
try {
|
|
31
|
+
themeObject[customThemeOptions] = JSON.parse(id);
|
|
32
|
+
} catch {
|
|
33
|
+
new Error('Invalid custom theme string');
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return themeObject;
|
|
37
|
+
}, {});
|
|
38
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import tokenValuesDark from '../artifacts/atlassian-dark-token-value-for-contrast-check';
|
|
2
|
+
import tokenValuesLight from '../artifacts/atlassian-light-token-value-for-contrast-check';
|
|
3
|
+
import { additionalChecks } from './custom-theme-token-contrast-check';
|
|
4
|
+
import { getContrastRatio } from './get-contrast-ratio';
|
|
5
|
+
const getColorFromTokenRaw = (tokenName, mode) => {
|
|
6
|
+
return mode === 'light' ? tokenValuesLight[tokenName] : tokenValuesDark[tokenName];
|
|
7
|
+
};
|
|
8
|
+
export const additionalContrastChecker = ({
|
|
9
|
+
customThemeTokenMap,
|
|
10
|
+
mode,
|
|
11
|
+
themeRamp
|
|
12
|
+
}) => {
|
|
13
|
+
const updatedCustomThemeTokenMap = {};
|
|
14
|
+
const brandTokens = Object.keys(customThemeTokenMap);
|
|
15
|
+
additionalChecks.forEach(pairing => {
|
|
16
|
+
const {
|
|
17
|
+
backgroundLight,
|
|
18
|
+
backgroundDark,
|
|
19
|
+
foreground,
|
|
20
|
+
desiredContrast,
|
|
21
|
+
updatedTokens
|
|
22
|
+
} = pairing;
|
|
23
|
+
const background = mode === 'light' ? backgroundLight : backgroundDark;
|
|
24
|
+
const foregroundTokenValue = customThemeTokenMap[foreground];
|
|
25
|
+
const backgroundTokenValue = customThemeTokenMap[background];
|
|
26
|
+
const foregroundColor = brandTokens.includes(foreground) ? typeof foregroundTokenValue === 'string' ? foregroundTokenValue : themeRamp[foregroundTokenValue] : getColorFromTokenRaw(foreground, mode);
|
|
27
|
+
const backgroundColor = brandTokens.includes(background) ? typeof backgroundTokenValue === 'string' ? backgroundTokenValue : themeRamp[backgroundTokenValue] : getColorFromTokenRaw(background, mode);
|
|
28
|
+
const contrast = getContrastRatio(foregroundColor, backgroundColor);
|
|
29
|
+
if (contrast <= desiredContrast) {
|
|
30
|
+
updatedTokens.forEach(token => {
|
|
31
|
+
const rampValue = customThemeTokenMap[token];
|
|
32
|
+
if (typeof rampValue === 'number') {
|
|
33
|
+
updatedCustomThemeTokenMap[token] = mode === 'light' ? rampValue + 1 : rampValue - 1;
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
return updatedCustomThemeTokenMap;
|
|
39
|
+
};
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import tokens from '../artifacts/token-names';
|
|
2
1
|
import { CUSTOM_THEME_ATTRIBUTE, THEME_DATA_ATTRIBUTE } from '../constants';
|
|
3
2
|
import { hash } from './hash';
|
|
4
3
|
export function findMissingCustomStyleElements(UNSAFE_themeOptions, mode) {
|
|
@@ -15,11 +14,4 @@ export function findMissingCustomStyleElements(UNSAFE_themeOptions, mode) {
|
|
|
15
14
|
}
|
|
16
15
|
});
|
|
17
16
|
return attrOfMissingCustomStyles;
|
|
18
|
-
}
|
|
19
|
-
export function reduceTokenMap(tokenMap, themeRamp) {
|
|
20
|
-
return Object.entries(tokenMap).reduce((acc, [key, value]) => {
|
|
21
|
-
const cssVar = tokens[key];
|
|
22
|
-
return cssVar ? `${acc}\n ${cssVar}: ${typeof value === 'string' ? value : themeRamp[value]};` : acc;
|
|
23
|
-
}, '');
|
|
24
|
-
}
|
|
25
|
-
export { limitSizeOfCustomStyleElements } from './limit-size-of-custom-style-elements';
|
|
17
|
+
}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import tokenValuesDark from '../artifacts/atlassian-dark-token-value-for-contrast-check';
|
|
2
|
-
import tokenValuesLight from '../artifacts/atlassian-light-token-value-for-contrast-check';
|
|
3
|
-
import { getContrastRatio } from './color-utils';
|
|
4
1
|
export const additionalChecks = [{
|
|
5
2
|
foreground: 'color.text.brand',
|
|
6
3
|
backgroundLight: 'elevation.surface.sunken',
|
|
@@ -42,39 +39,4 @@ export const additionalChecks = [{
|
|
|
42
39
|
// In light mode: darken the following tokens by one base token
|
|
43
40
|
// In dark mode: lighten the following tokens by one base token
|
|
44
41
|
updatedTokens: ['color.chart.brand', 'color.chart.brand.hovered']
|
|
45
|
-
}];
|
|
46
|
-
const getColorFromTokenRaw = (tokenName, mode) => {
|
|
47
|
-
return mode === 'light' ? tokenValuesLight[tokenName] : tokenValuesDark[tokenName];
|
|
48
|
-
};
|
|
49
|
-
export const additionalContrastChecker = ({
|
|
50
|
-
customThemeTokenMap,
|
|
51
|
-
mode,
|
|
52
|
-
themeRamp
|
|
53
|
-
}) => {
|
|
54
|
-
const updatedCustomThemeTokenMap = {};
|
|
55
|
-
const brandTokens = Object.keys(customThemeTokenMap);
|
|
56
|
-
additionalChecks.forEach(pairing => {
|
|
57
|
-
const {
|
|
58
|
-
backgroundLight,
|
|
59
|
-
backgroundDark,
|
|
60
|
-
foreground,
|
|
61
|
-
desiredContrast,
|
|
62
|
-
updatedTokens
|
|
63
|
-
} = pairing;
|
|
64
|
-
const background = mode === 'light' ? backgroundLight : backgroundDark;
|
|
65
|
-
const foregroundTokenValue = customThemeTokenMap[foreground];
|
|
66
|
-
const backgroundTokenValue = customThemeTokenMap[background];
|
|
67
|
-
const foregroundColor = brandTokens.includes(foreground) ? typeof foregroundTokenValue === 'string' ? foregroundTokenValue : themeRamp[foregroundTokenValue] : getColorFromTokenRaw(foreground, mode);
|
|
68
|
-
const backgroundColor = brandTokens.includes(background) ? typeof backgroundTokenValue === 'string' ? backgroundTokenValue : themeRamp[backgroundTokenValue] : getColorFromTokenRaw(background, mode);
|
|
69
|
-
const contrast = getContrastRatio(foregroundColor, backgroundColor);
|
|
70
|
-
if (contrast <= desiredContrast) {
|
|
71
|
-
updatedTokens.forEach(token => {
|
|
72
|
-
const rampValue = customThemeTokenMap[token];
|
|
73
|
-
if (typeof rampValue === 'number') {
|
|
74
|
-
updatedCustomThemeTokenMap[token] = mode === 'light' ? rampValue + 1 : rampValue - 1;
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
return updatedCustomThemeTokenMap;
|
|
80
|
-
};
|
|
42
|
+
}];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { rgbToLab } from './rgb-to-lab';
|
|
2
|
+
export function deltaE(rgbA, rgbB) {
|
|
3
|
+
let labA = rgbToLab(rgbA);
|
|
4
|
+
let labB = rgbToLab(rgbB);
|
|
5
|
+
let deltaL = labA[0] - labB[0];
|
|
6
|
+
let deltaA = labA[1] - labB[1];
|
|
7
|
+
let deltaB = labA[2] - labB[2];
|
|
8
|
+
let c1 = Math.sqrt(labA[1] * labA[1] + labA[2] * labA[2]);
|
|
9
|
+
let c2 = Math.sqrt(labB[1] * labB[1] + labB[2] * labB[2]);
|
|
10
|
+
let deltaC = c1 - c2;
|
|
11
|
+
let deltaH = deltaA * deltaA + deltaB * deltaB - deltaC * deltaC;
|
|
12
|
+
deltaH = deltaH < 0 ? 0 : Math.sqrt(deltaH);
|
|
13
|
+
let sc = 1.0 + 0.045 * c1;
|
|
14
|
+
let sh = 1.0 + 0.015 * c1;
|
|
15
|
+
let deltaLKlsl = deltaL / 1.0;
|
|
16
|
+
let deltaCkcsc = deltaC / sc;
|
|
17
|
+
let deltaHkhsh = deltaH / sh;
|
|
18
|
+
let i = deltaLKlsl * deltaLKlsl + deltaCkcsc * deltaCkcsc + deltaHkhsh * deltaHkhsh;
|
|
19
|
+
return i < 0 ? 0 : Math.sqrt(i);
|
|
20
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { getClosestColorIndex } from './get-closest-color-index';
|
|
2
|
+
import { argbFromRgba, Contrast, Hct, rgbaFromArgb } from './hct-color-utils';
|
|
3
|
+
import { hexToHSL } from './hex-to-hsl';
|
|
4
|
+
import { hexToRgbA } from './hex-to-rgb-a';
|
|
5
|
+
import { HSLToRGB } from './hsl-to-rgb';
|
|
6
|
+
import { relativeLuminanceW3C } from './relative-luminance-w3-c';
|
|
7
|
+
import { rgbToHex } from './rgb-to-hex';
|
|
8
|
+
const lowLuminanceContrastRatios = [1.12, 1.33, 2.03, 2.73, 3.33, 4.27, 5.2, 6.62, 12.46, 14.25];
|
|
9
|
+
const highLuminanceContrastRatios = [1.08, 1.24, 1.55, 1.99, 2.45, 3.34, 4.64, 6.1, 10.19, 12.6];
|
|
10
|
+
export const generateColors = brandColor => {
|
|
11
|
+
// Determine luminance
|
|
12
|
+
const HSLBrandColorHue = hexToHSL(brandColor)[0];
|
|
13
|
+
const baseRgb = HSLToRGB(HSLBrandColorHue, 100, 60);
|
|
14
|
+
const isLowLuminance = relativeLuminanceW3C(baseRgb[0], baseRgb[1], baseRgb[2]) < 0.4;
|
|
15
|
+
// Choose right palette
|
|
16
|
+
const themeRatios = isLowLuminance ? lowLuminanceContrastRatios : highLuminanceContrastRatios;
|
|
17
|
+
const brandRgba = hexToRgbA(brandColor);
|
|
18
|
+
const hctColor = Hct.fromInt(argbFromRgba({
|
|
19
|
+
r: brandRgba[0],
|
|
20
|
+
g: brandRgba[1],
|
|
21
|
+
b: brandRgba[2],
|
|
22
|
+
a: brandRgba[3]
|
|
23
|
+
}));
|
|
24
|
+
const themeRamp = themeRatios.map(contrast => {
|
|
25
|
+
const rgbaColor = rgbaFromArgb(Hct.from(hctColor.hue, hctColor.chroma, Contrast.darker(100, contrast) + 0.25 // Material's utils provide an offset
|
|
26
|
+
).toInt());
|
|
27
|
+
return rgbToHex(rgbaColor.r, rgbaColor.g, rgbaColor.b);
|
|
28
|
+
});
|
|
29
|
+
const closestColorIndex = getClosestColorIndex(themeRamp, brandColor);
|
|
30
|
+
|
|
31
|
+
// Replace closet color with brandColor
|
|
32
|
+
const updatedThemeRamp = [...themeRamp];
|
|
33
|
+
updatedThemeRamp[closestColorIndex] = brandColor;
|
|
34
|
+
return {
|
|
35
|
+
ramp: updatedThemeRamp,
|
|
36
|
+
// add the replaced color into the result
|
|
37
|
+
replacedColor: themeRamp[closestColorIndex]
|
|
38
|
+
};
|
|
39
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { additionalContrastChecker } from './additional-contrast-checker';
|
|
2
|
+
import { generateColors } from './generate-colors';
|
|
3
|
+
import { generateTokenMap } from './generate-token-map';
|
|
4
|
+
export const generateTokenMapWithContrastCheck = (brandColor, mode, themeRamp) => {
|
|
5
|
+
const colors = themeRamp || generateColors(brandColor).ramp;
|
|
6
|
+
const tokenMaps = generateTokenMap(brandColor, mode, colors);
|
|
7
|
+
const result = {};
|
|
8
|
+
Object.entries(tokenMaps).forEach(([mode, map]) => {
|
|
9
|
+
if (mode === 'light' || mode === 'dark') {
|
|
10
|
+
result[mode] = {
|
|
11
|
+
...map,
|
|
12
|
+
...additionalContrastChecker({
|
|
13
|
+
customThemeTokenMap: map,
|
|
14
|
+
mode,
|
|
15
|
+
themeRamp: colors
|
|
16
|
+
})
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
return result;
|
|
21
|
+
};
|
|
@@ -1,44 +1,7 @@
|
|
|
1
1
|
import rawTokensDark from '../artifacts/atlassian-dark-token-value-for-contrast-check';
|
|
2
|
-
import {
|
|
3
|
-
import { additionalContrastChecker } from './custom-theme-token-contrast-check';
|
|
2
|
+
import { generateColors } from './generate-colors';
|
|
4
3
|
import { getClosestColorIndex } from './get-closest-color-index';
|
|
5
|
-
import {
|
|
6
|
-
import { HSLToRGB } from './hsl-to-rgb';
|
|
7
|
-
import { relativeLuminanceW3C } from './relative-luminance-w3-c';
|
|
8
|
-
import { rgbToHex } from './rgb-to-hex';
|
|
9
|
-
const lowLuminanceContrastRatios = [1.12, 1.33, 2.03, 2.73, 3.33, 4.27, 5.2, 6.62, 12.46, 14.25];
|
|
10
|
-
const highLuminanceContrastRatios = [1.08, 1.24, 1.55, 1.99, 2.45, 3.34, 4.64, 6.1, 10.19, 12.6];
|
|
11
|
-
export const generateColors = brandColor => {
|
|
12
|
-
// Determine luminance
|
|
13
|
-
const HSLBrandColorHue = hexToHSL(brandColor)[0];
|
|
14
|
-
const baseRgb = HSLToRGB(HSLBrandColorHue, 100, 60);
|
|
15
|
-
const isLowLuminance = relativeLuminanceW3C(baseRgb[0], baseRgb[1], baseRgb[2]) < 0.4;
|
|
16
|
-
// Choose right palette
|
|
17
|
-
const themeRatios = isLowLuminance ? lowLuminanceContrastRatios : highLuminanceContrastRatios;
|
|
18
|
-
const brandRgba = hexToRgbA(brandColor);
|
|
19
|
-
const hctColor = Hct.fromInt(argbFromRgba({
|
|
20
|
-
r: brandRgba[0],
|
|
21
|
-
g: brandRgba[1],
|
|
22
|
-
b: brandRgba[2],
|
|
23
|
-
a: brandRgba[3]
|
|
24
|
-
}));
|
|
25
|
-
const themeRamp = themeRatios.map(contrast => {
|
|
26
|
-
const rgbaColor = rgbaFromArgb(Hct.from(hctColor.hue, hctColor.chroma, Contrast.darker(100, contrast) + 0.25 // Material's utils provide an offset
|
|
27
|
-
).toInt());
|
|
28
|
-
return rgbToHex(rgbaColor.r, rgbaColor.g, rgbaColor.b);
|
|
29
|
-
});
|
|
30
|
-
const closestColorIndex = getClosestColorIndex(themeRamp, brandColor);
|
|
31
|
-
|
|
32
|
-
// Replace closet color with brandColor
|
|
33
|
-
const updatedThemeRamp = [...themeRamp];
|
|
34
|
-
updatedThemeRamp[closestColorIndex] = brandColor;
|
|
35
|
-
return {
|
|
36
|
-
ramp: updatedThemeRamp,
|
|
37
|
-
// add the replaced color into the result
|
|
38
|
-
replacedColor: themeRamp[closestColorIndex]
|
|
39
|
-
};
|
|
40
|
-
};
|
|
41
|
-
|
|
4
|
+
import { getContrastRatio } from './get-contrast-ratio';
|
|
42
5
|
/**
|
|
43
6
|
* Return the interaction tokens for a color, given its ramp position and the number of
|
|
44
7
|
* needed interaction states. Use higher-indexed colors (i.e. darker colors) if possible;
|
|
@@ -189,23 +152,4 @@ export const generateTokenMap = (brandColor, mode, themeRamp) => {
|
|
|
189
152
|
light: customThemeTokenMapLight,
|
|
190
153
|
dark: customThemeTokenMapDark
|
|
191
154
|
};
|
|
192
|
-
};
|
|
193
|
-
export const generateTokenMapWithContrastCheck = (brandColor, mode, themeRamp) => {
|
|
194
|
-
const colors = themeRamp || generateColors(brandColor).ramp;
|
|
195
|
-
const tokenMaps = generateTokenMap(brandColor, mode, colors);
|
|
196
|
-
const result = {};
|
|
197
|
-
Object.entries(tokenMaps).forEach(([mode, map]) => {
|
|
198
|
-
if (mode === 'light' || mode === 'dark') {
|
|
199
|
-
result[mode] = {
|
|
200
|
-
...map,
|
|
201
|
-
...additionalContrastChecker({
|
|
202
|
-
customThemeTokenMap: map,
|
|
203
|
-
mode,
|
|
204
|
-
themeRamp: colors
|
|
205
|
-
})
|
|
206
|
-
};
|
|
207
|
-
}
|
|
208
|
-
});
|
|
209
|
-
return result;
|
|
210
|
-
};
|
|
211
|
-
export { getClosestColorIndex } from './get-closest-color-index';
|
|
155
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { deltaE
|
|
1
|
+
import { deltaE } from './delta-e';
|
|
2
|
+
import { hexToRgb } from './hex-to-rgb';
|
|
2
3
|
export const getClosestColorIndex = (themeRamp, brandColor) => {
|
|
3
4
|
// Iterate over themeRamp and find whichever color is closest to brandColor
|
|
4
5
|
let closestColorIndex = 0;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { hexToRgb } from './hex-to-rgb';
|
|
2
|
+
import { isValidHex } from './is-valid-hex';
|
|
3
|
+
import { relativeLuminanceW3C } from './relative-luminance-w3-c';
|
|
4
|
+
export function getContrastRatio(foreground, background) {
|
|
5
|
+
if (!isValidHex(foreground) || !isValidHex(background)) {
|
|
6
|
+
throw new Error('Invalid HEX');
|
|
7
|
+
}
|
|
8
|
+
const foregroundRgb = hexToRgb(foreground);
|
|
9
|
+
const backgroundRgb = hexToRgb(background);
|
|
10
|
+
const foregroundLuminance = relativeLuminanceW3C(foregroundRgb[0], foregroundRgb[1], foregroundRgb[2]);
|
|
11
|
+
const backgroundLuminance = relativeLuminanceW3C(backgroundRgb[0], backgroundRgb[1], backgroundRgb[2]);
|
|
12
|
+
// calculate the color contrast ratio
|
|
13
|
+
var brightest = Math.max(foregroundLuminance, backgroundLuminance);
|
|
14
|
+
var darkest = Math.min(foregroundLuminance, backgroundLuminance);
|
|
15
|
+
return (brightest + 0.05) / (darkest + 0.05);
|
|
16
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { argbFromRgb } from './argb-from-rgb';
|
|
2
|
+
import { delinearized } from './delinearized';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Converts a color from linear RGB components to ARGB format.
|
|
6
|
+
*/
|
|
7
|
+
export function argbFromLinrgb(linrgb) {
|
|
8
|
+
const r = delinearized(linrgb[0]);
|
|
9
|
+
const g = delinearized(linrgb[1]);
|
|
10
|
+
const b = delinearized(linrgb[2]);
|
|
11
|
+
return argbFromRgb(r, g, b);
|
|
12
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { argbFromRgb } from './argb-from-rgb';
|
|
2
|
+
import { delinearized } from './delinearized';
|
|
3
|
+
import { yFromLstar } from './y-from-lstar';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Converts an L* value to an ARGB representation.
|
|
7
|
+
*
|
|
8
|
+
* @param lstar L* in L*a*b*
|
|
9
|
+
* @return ARGB representation of grayscale color with lightness
|
|
10
|
+
* matching L*
|
|
11
|
+
*/
|
|
12
|
+
export function argbFromLstar(lstar) {
|
|
13
|
+
const y = yFromLstar(lstar);
|
|
14
|
+
const component = delinearized(y);
|
|
15
|
+
return argbFromRgb(component, component, component);
|
|
16
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { clampComponent } from './clamp-component';
|
|
2
|
+
/**
|
|
3
|
+
* Return int32 color from a given RGBA component
|
|
4
|
+
*
|
|
5
|
+
* @param rgba RGBA representation of a int32 color.
|
|
6
|
+
* @returns ARGB representation of a int32 color.
|
|
7
|
+
*/
|
|
8
|
+
export function argbFromRgba({
|
|
9
|
+
r,
|
|
10
|
+
g,
|
|
11
|
+
b,
|
|
12
|
+
a
|
|
13
|
+
}) {
|
|
14
|
+
const rValue = clampComponent(r);
|
|
15
|
+
const gValue = clampComponent(g);
|
|
16
|
+
const bValue = clampComponent(b);
|
|
17
|
+
const aValue = clampComponent(a);
|
|
18
|
+
return aValue << 24 | rValue << 16 | gValue << 8 | bValue;
|
|
19
|
+
}
|