@atlaskit/tokens 13.1.0 → 13.2.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 +34 -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 -336
- 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/generated-pairs.js +2 -2
- 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 +21 -1
- package/dist/cjs/artifacts/token-names.js +21 -1
- package/dist/cjs/artifacts/tokens-raw/atlassian-dark-increased-contrast.js +471 -31
- package/dist/cjs/artifacts/tokens-raw/atlassian-dark.js +471 -31
- package/dist/cjs/artifacts/tokens-raw/atlassian-light-increased-contrast.js +471 -31
- package/dist/cjs/artifacts/tokens-raw/atlassian-light.js +471 -31
- package/dist/cjs/entry-points/theme-state-transformer.js +4 -3
- package/dist/cjs/entry-points/token-metadata.codegen.js +196 -16
- 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/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/theme-config.js +8 -44
- 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 -22
- package/dist/cjs/utils/custom-theme-token-contrast-check.js +2 -40
- 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 -75
- 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/reduce-token-map.js +18 -0
- package/dist/cjs/utils/rgb-to-lab.js +24 -0
- package/dist/es2019/artifacts/generated-pairs.js +2 -2
- package/dist/es2019/artifacts/palettes-raw/palette.js +35 -1
- package/dist/es2019/artifacts/themes/atlassian-dark-increased-contrast.js +21 -1
- package/dist/es2019/artifacts/themes/atlassian-dark.js +21 -1
- package/dist/es2019/artifacts/themes/atlassian-light-increased-contrast.js +21 -1
- package/dist/es2019/artifacts/themes/atlassian-light.js +21 -1
- package/dist/es2019/artifacts/token-default-values.js +21 -1
- package/dist/es2019/artifacts/token-names.js +21 -1
- package/dist/es2019/artifacts/tokens-raw/atlassian-dark-increased-contrast.js +471 -31
- package/dist/es2019/artifacts/tokens-raw/atlassian-dark.js +471 -31
- package/dist/es2019/artifacts/tokens-raw/atlassian-light-increased-contrast.js +471 -31
- package/dist/es2019/artifacts/tokens-raw/atlassian-light.js +471 -31
- package/dist/es2019/entry-points/theme-state-transformer.js +2 -1
- package/dist/es2019/entry-points/token-metadata.codegen.js +196 -16
- 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 +4 -45
- 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 -11
- package/dist/es2019/utils/custom-theme-token-contrast-check.js +1 -41
- 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 -63
- 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/generated-pairs.js +2 -2
- 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 +21 -1
- package/dist/esm/artifacts/token-names.js +21 -1
- package/dist/esm/artifacts/tokens-raw/atlassian-dark-increased-contrast.js +471 -31
- package/dist/esm/artifacts/tokens-raw/atlassian-dark.js +471 -31
- package/dist/esm/artifacts/tokens-raw/atlassian-light-increased-contrast.js +471 -31
- package/dist/esm/artifacts/tokens-raw/atlassian-light.js +471 -31
- package/dist/esm/entry-points/theme-state-transformer.js +2 -1
- package/dist/esm/entry-points/token-metadata.codegen.js +196 -16
- 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/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/theme-config.js +4 -45
- 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 -15
- package/dist/esm/utils/custom-theme-token-contrast-check.js +1 -38
- 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 -67
- 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/reduce-token-map.js +11 -0
- package/dist/esm/utils/rgb-to-lab.js +18 -0
- package/dist/types/artifacts/generated-pairs.d.ts +1 -1
- 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 +21 -1
- package/dist/types/artifacts/token-names.d.ts +41 -1
- 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/types-internal.d.ts +2 -2
- package/dist/types/artifacts/types.d.ts +2 -2
- package/dist/types/entry-points/css-type-schema.codegen.d.ts +3 -3
- 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/types.d.ts +75 -15
- 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/generated-pairs.d.ts +1 -1
- 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 +21 -1
- package/dist/types-ts4.5/artifacts/token-names.d.ts +41 -1
- 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/types-internal.d.ts +2 -2
- package/dist/types-ts4.5/artifacts/types.d.ts +2 -2
- package/dist/types-ts4.5/entry-points/css-type-schema.codegen.d.ts +3 -3
- 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/types.d.ts +75 -15
- 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 +180 -0
- package/figma/atlassian-dark.json +180 -0
- package/figma/atlassian-light-increased-contrast.json +180 -0
- package/figma/atlassian-light.json +180 -0
- package/package.json +7 -7
- package/dist/cjs/theme-state-transformer.js +0 -93
- package/dist/cjs/utils/color-utils.js +0 -176
- package/dist/cjs/utils/hct-color-utils/color-utils.js +0 -279
- package/dist/es2019/theme-state-transformer.js +0 -70
- package/dist/es2019/utils/color-utils.js +0 -136
- package/dist/es2019/utils/hct-color-utils/color-utils.js +0 -249
- package/dist/esm/theme-state-transformer.js +0 -86
- package/dist/esm/utils/color-utils.js +0 -138
- package/dist/esm/utils/hct-color-utils/color-utils.js +0 -248
- 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
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
var getColorFromTokenRaw = function getColorFromTokenRaw(tokenName, mode) {
|
|
6
|
+
return mode === 'light' ? tokenValuesLight[tokenName] : tokenValuesDark[tokenName];
|
|
7
|
+
};
|
|
8
|
+
export var additionalContrastChecker = function additionalContrastChecker(_ref) {
|
|
9
|
+
var customThemeTokenMap = _ref.customThemeTokenMap,
|
|
10
|
+
mode = _ref.mode,
|
|
11
|
+
themeRamp = _ref.themeRamp;
|
|
12
|
+
var updatedCustomThemeTokenMap = {};
|
|
13
|
+
var brandTokens = Object.keys(customThemeTokenMap);
|
|
14
|
+
additionalChecks.forEach(function (pairing) {
|
|
15
|
+
var backgroundLight = pairing.backgroundLight,
|
|
16
|
+
backgroundDark = pairing.backgroundDark,
|
|
17
|
+
foreground = pairing.foreground,
|
|
18
|
+
desiredContrast = pairing.desiredContrast,
|
|
19
|
+
updatedTokens = pairing.updatedTokens;
|
|
20
|
+
var background = mode === 'light' ? backgroundLight : backgroundDark;
|
|
21
|
+
var foregroundTokenValue = customThemeTokenMap[foreground];
|
|
22
|
+
var backgroundTokenValue = customThemeTokenMap[background];
|
|
23
|
+
var foregroundColor = brandTokens.includes(foreground) ? typeof foregroundTokenValue === 'string' ? foregroundTokenValue : themeRamp[foregroundTokenValue] : getColorFromTokenRaw(foreground, mode);
|
|
24
|
+
var backgroundColor = brandTokens.includes(background) ? typeof backgroundTokenValue === 'string' ? backgroundTokenValue : themeRamp[backgroundTokenValue] : getColorFromTokenRaw(background, mode);
|
|
25
|
+
var contrast = getContrastRatio(foregroundColor, backgroundColor);
|
|
26
|
+
if (contrast <= desiredContrast) {
|
|
27
|
+
updatedTokens.forEach(function (token) {
|
|
28
|
+
var rampValue = customThemeTokenMap[token];
|
|
29
|
+
if (typeof rampValue === 'number') {
|
|
30
|
+
updatedCustomThemeTokenMap[token] = mode === 'light' ? rampValue + 1 : rampValue - 1;
|
|
31
|
+
}
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
return updatedCustomThemeTokenMap;
|
|
36
|
+
};
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
-
import tokens from '../artifacts/token-names';
|
|
3
1
|
import { CUSTOM_THEME_ATTRIBUTE, THEME_DATA_ATTRIBUTE } from '../constants';
|
|
4
2
|
import { hash } from './hash';
|
|
5
3
|
export function findMissingCustomStyleElements(UNSAFE_themeOptions, mode) {
|
|
@@ -16,16 +14,4 @@ export function findMissingCustomStyleElements(UNSAFE_themeOptions, mode) {
|
|
|
16
14
|
}
|
|
17
15
|
});
|
|
18
16
|
return attrOfMissingCustomStyles;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
22
|
-
export function reduceTokenMap(tokenMap, themeRamp) {
|
|
23
|
-
return Object.entries(tokenMap).reduce(function (acc, _ref) {
|
|
24
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
|
25
|
-
key = _ref2[0],
|
|
26
|
-
value = _ref2[1];
|
|
27
|
-
var cssVar = tokens[key];
|
|
28
|
-
return cssVar ? "".concat(acc, "\n ").concat(cssVar, ": ").concat(typeof value === 'string' ? value : themeRamp[value], ";") : acc;
|
|
29
|
-
}, '');
|
|
30
|
-
}
|
|
31
|
-
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 var additionalChecks = [{
|
|
5
2
|
foreground: 'color.text.brand',
|
|
6
3
|
backgroundLight: 'elevation.surface.sunken',
|
|
@@ -42,38 +39,4 @@ export var 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
|
-
var getColorFromTokenRaw = function getColorFromTokenRaw(tokenName, mode) {
|
|
47
|
-
return mode === 'light' ? tokenValuesLight[tokenName] : tokenValuesDark[tokenName];
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
51
|
-
export var additionalContrastChecker = function additionalContrastChecker(_ref) {
|
|
52
|
-
var customThemeTokenMap = _ref.customThemeTokenMap,
|
|
53
|
-
mode = _ref.mode,
|
|
54
|
-
themeRamp = _ref.themeRamp;
|
|
55
|
-
var updatedCustomThemeTokenMap = {};
|
|
56
|
-
var brandTokens = Object.keys(customThemeTokenMap);
|
|
57
|
-
additionalChecks.forEach(function (pairing) {
|
|
58
|
-
var backgroundLight = pairing.backgroundLight,
|
|
59
|
-
backgroundDark = pairing.backgroundDark,
|
|
60
|
-
foreground = pairing.foreground,
|
|
61
|
-
desiredContrast = pairing.desiredContrast,
|
|
62
|
-
updatedTokens = pairing.updatedTokens;
|
|
63
|
-
var background = mode === 'light' ? backgroundLight : backgroundDark;
|
|
64
|
-
var foregroundTokenValue = customThemeTokenMap[foreground];
|
|
65
|
-
var backgroundTokenValue = customThemeTokenMap[background];
|
|
66
|
-
var foregroundColor = brandTokens.includes(foreground) ? typeof foregroundTokenValue === 'string' ? foregroundTokenValue : themeRamp[foregroundTokenValue] : getColorFromTokenRaw(foreground, mode);
|
|
67
|
-
var backgroundColor = brandTokens.includes(background) ? typeof backgroundTokenValue === 'string' ? backgroundTokenValue : themeRamp[backgroundTokenValue] : getColorFromTokenRaw(background, mode);
|
|
68
|
-
var contrast = getContrastRatio(foregroundColor, backgroundColor);
|
|
69
|
-
if (contrast <= desiredContrast) {
|
|
70
|
-
updatedTokens.forEach(function (token) {
|
|
71
|
-
var rampValue = customThemeTokenMap[token];
|
|
72
|
-
if (typeof rampValue === 'number') {
|
|
73
|
-
updatedCustomThemeTokenMap[token] = mode === 'light' ? rampValue + 1 : rampValue - 1;
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
});
|
|
78
|
-
return updatedCustomThemeTokenMap;
|
|
79
|
-
};
|
|
42
|
+
}];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { rgbToLab } from './rgb-to-lab';
|
|
2
|
+
export function deltaE(rgbA, rgbB) {
|
|
3
|
+
var labA = rgbToLab(rgbA);
|
|
4
|
+
var labB = rgbToLab(rgbB);
|
|
5
|
+
var deltaL = labA[0] - labB[0];
|
|
6
|
+
var deltaA = labA[1] - labB[1];
|
|
7
|
+
var deltaB = labA[2] - labB[2];
|
|
8
|
+
var c1 = Math.sqrt(labA[1] * labA[1] + labA[2] * labA[2]);
|
|
9
|
+
var c2 = Math.sqrt(labB[1] * labB[1] + labB[2] * labB[2]);
|
|
10
|
+
var deltaC = c1 - c2;
|
|
11
|
+
var deltaH = deltaA * deltaA + deltaB * deltaB - deltaC * deltaC;
|
|
12
|
+
deltaH = deltaH < 0 ? 0 : Math.sqrt(deltaH);
|
|
13
|
+
var sc = 1.0 + 0.045 * c1;
|
|
14
|
+
var sh = 1.0 + 0.015 * c1;
|
|
15
|
+
var deltaLKlsl = deltaL / 1.0;
|
|
16
|
+
var deltaCkcsc = deltaC / sc;
|
|
17
|
+
var deltaHkhsh = deltaH / sh;
|
|
18
|
+
var i = deltaLKlsl * deltaLKlsl + deltaCkcsc * deltaCkcsc + deltaHkhsh * deltaHkhsh;
|
|
19
|
+
return i < 0 ? 0 : Math.sqrt(i);
|
|
20
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import { getClosestColorIndex } from './get-closest-color-index';
|
|
3
|
+
import { argbFromRgba, Contrast, Hct, rgbaFromArgb } from './hct-color-utils';
|
|
4
|
+
import { hexToHSL } from './hex-to-hsl';
|
|
5
|
+
import { hexToRgbA } from './hex-to-rgb-a';
|
|
6
|
+
import { HSLToRGB } from './hsl-to-rgb';
|
|
7
|
+
import { relativeLuminanceW3C } from './relative-luminance-w3-c';
|
|
8
|
+
import { rgbToHex } from './rgb-to-hex';
|
|
9
|
+
var lowLuminanceContrastRatios = [1.12, 1.33, 2.03, 2.73, 3.33, 4.27, 5.2, 6.62, 12.46, 14.25];
|
|
10
|
+
var highLuminanceContrastRatios = [1.08, 1.24, 1.55, 1.99, 2.45, 3.34, 4.64, 6.1, 10.19, 12.6];
|
|
11
|
+
export var generateColors = function generateColors(brandColor) {
|
|
12
|
+
// Determine luminance
|
|
13
|
+
var HSLBrandColorHue = hexToHSL(brandColor)[0];
|
|
14
|
+
var baseRgb = HSLToRGB(HSLBrandColorHue, 100, 60);
|
|
15
|
+
var isLowLuminance = relativeLuminanceW3C(baseRgb[0], baseRgb[1], baseRgb[2]) < 0.4;
|
|
16
|
+
// Choose right palette
|
|
17
|
+
var themeRatios = isLowLuminance ? lowLuminanceContrastRatios : highLuminanceContrastRatios;
|
|
18
|
+
var brandRgba = hexToRgbA(brandColor);
|
|
19
|
+
var hctColor = Hct.fromInt(argbFromRgba({
|
|
20
|
+
r: brandRgba[0],
|
|
21
|
+
g: brandRgba[1],
|
|
22
|
+
b: brandRgba[2],
|
|
23
|
+
a: brandRgba[3]
|
|
24
|
+
}));
|
|
25
|
+
var themeRamp = themeRatios.map(function (contrast) {
|
|
26
|
+
var 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
|
+
var closestColorIndex = getClosestColorIndex(themeRamp, brandColor);
|
|
31
|
+
|
|
32
|
+
// Replace closet color with brandColor
|
|
33
|
+
var updatedThemeRamp = _toConsumableArray(themeRamp);
|
|
34
|
+
updatedThemeRamp[closestColorIndex] = brandColor;
|
|
35
|
+
return {
|
|
36
|
+
ramp: updatedThemeRamp,
|
|
37
|
+
// add the replaced color into the result
|
|
38
|
+
replacedColor: themeRamp[closestColorIndex]
|
|
39
|
+
};
|
|
40
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
+
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; }
|
|
4
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
5
|
+
import { additionalContrastChecker } from './additional-contrast-checker';
|
|
6
|
+
import { generateColors } from './generate-colors';
|
|
7
|
+
import { generateTokenMap } from './generate-token-map';
|
|
8
|
+
export var generateTokenMapWithContrastCheck = function generateTokenMapWithContrastCheck(brandColor, mode, themeRamp) {
|
|
9
|
+
var colors = themeRamp || generateColors(brandColor).ramp;
|
|
10
|
+
var tokenMaps = generateTokenMap(brandColor, mode, colors);
|
|
11
|
+
var result = {};
|
|
12
|
+
Object.entries(tokenMaps).forEach(function (_ref) {
|
|
13
|
+
var _ref2 = _slicedToArray(_ref, 2),
|
|
14
|
+
mode = _ref2[0],
|
|
15
|
+
map = _ref2[1];
|
|
16
|
+
if (mode === 'light' || mode === 'dark') {
|
|
17
|
+
result[mode] = _objectSpread(_objectSpread({}, map), additionalContrastChecker({
|
|
18
|
+
customThemeTokenMap: map,
|
|
19
|
+
mode: mode,
|
|
20
|
+
themeRamp: colors
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
@@ -1,49 +1,8 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
1
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
3
|
-
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
4
|
-
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; }
|
|
5
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
6
2
|
import rawTokensDark from '../artifacts/atlassian-dark-token-value-for-contrast-check';
|
|
7
|
-
import {
|
|
8
|
-
import { additionalContrastChecker } from './custom-theme-token-contrast-check';
|
|
3
|
+
import { generateColors } from './generate-colors';
|
|
9
4
|
import { getClosestColorIndex } from './get-closest-color-index';
|
|
10
|
-
import {
|
|
11
|
-
import { HSLToRGB } from './hsl-to-rgb';
|
|
12
|
-
import { relativeLuminanceW3C } from './relative-luminance-w3-c';
|
|
13
|
-
import { rgbToHex } from './rgb-to-hex';
|
|
14
|
-
var lowLuminanceContrastRatios = [1.12, 1.33, 2.03, 2.73, 3.33, 4.27, 5.2, 6.62, 12.46, 14.25];
|
|
15
|
-
var highLuminanceContrastRatios = [1.08, 1.24, 1.55, 1.99, 2.45, 3.34, 4.64, 6.1, 10.19, 12.6];
|
|
16
|
-
export var generateColors = function generateColors(brandColor) {
|
|
17
|
-
// Determine luminance
|
|
18
|
-
var HSLBrandColorHue = hexToHSL(brandColor)[0];
|
|
19
|
-
var baseRgb = HSLToRGB(HSLBrandColorHue, 100, 60);
|
|
20
|
-
var isLowLuminance = relativeLuminanceW3C(baseRgb[0], baseRgb[1], baseRgb[2]) < 0.4;
|
|
21
|
-
// Choose right palette
|
|
22
|
-
var themeRatios = isLowLuminance ? lowLuminanceContrastRatios : highLuminanceContrastRatios;
|
|
23
|
-
var brandRgba = hexToRgbA(brandColor);
|
|
24
|
-
var hctColor = Hct.fromInt(argbFromRgba({
|
|
25
|
-
r: brandRgba[0],
|
|
26
|
-
g: brandRgba[1],
|
|
27
|
-
b: brandRgba[2],
|
|
28
|
-
a: brandRgba[3]
|
|
29
|
-
}));
|
|
30
|
-
var themeRamp = themeRatios.map(function (contrast) {
|
|
31
|
-
var rgbaColor = rgbaFromArgb(Hct.from(hctColor.hue, hctColor.chroma, Contrast.darker(100, contrast) + 0.25 // Material's utils provide an offset
|
|
32
|
-
).toInt());
|
|
33
|
-
return rgbToHex(rgbaColor.r, rgbaColor.g, rgbaColor.b);
|
|
34
|
-
});
|
|
35
|
-
var closestColorIndex = getClosestColorIndex(themeRamp, brandColor);
|
|
36
|
-
|
|
37
|
-
// Replace closet color with brandColor
|
|
38
|
-
var updatedThemeRamp = _toConsumableArray(themeRamp);
|
|
39
|
-
updatedThemeRamp[closestColorIndex] = brandColor;
|
|
40
|
-
return {
|
|
41
|
-
ramp: updatedThemeRamp,
|
|
42
|
-
// add the replaced color into the result
|
|
43
|
-
replacedColor: themeRamp[closestColorIndex]
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
|
|
5
|
+
import { getContrastRatio } from './get-contrast-ratio';
|
|
47
6
|
/**
|
|
48
7
|
* Return the interaction tokens for a color, given its ramp position and the number of
|
|
49
8
|
* needed interaction states. Use higher-indexed colors (i.e. darker colors) if possible;
|
|
@@ -63,8 +22,6 @@ function getInteractionStates(rampPosition, number, colors) {
|
|
|
63
22
|
}
|
|
64
23
|
return result;
|
|
65
24
|
}
|
|
66
|
-
|
|
67
|
-
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
68
25
|
export var generateTokenMap = function generateTokenMap(brandColor, mode, themeRamp) {
|
|
69
26
|
var _generateColors = generateColors(brandColor),
|
|
70
27
|
ramp = _generateColors.ramp,
|
|
@@ -203,25 +160,4 @@ export var generateTokenMap = function generateTokenMap(brandColor, mode, themeR
|
|
|
203
160
|
light: customThemeTokenMapLight,
|
|
204
161
|
dark: customThemeTokenMapDark
|
|
205
162
|
};
|
|
206
|
-
};
|
|
207
|
-
|
|
208
|
-
// eslint-disable-next-line @atlaskit/volt-strict-mode/no-multiple-exports
|
|
209
|
-
export var generateTokenMapWithContrastCheck = function generateTokenMapWithContrastCheck(brandColor, mode, themeRamp) {
|
|
210
|
-
var colors = themeRamp || generateColors(brandColor).ramp;
|
|
211
|
-
var tokenMaps = generateTokenMap(brandColor, mode, colors);
|
|
212
|
-
var result = {};
|
|
213
|
-
Object.entries(tokenMaps).forEach(function (_ref3) {
|
|
214
|
-
var _ref4 = _slicedToArray(_ref3, 2),
|
|
215
|
-
mode = _ref4[0],
|
|
216
|
-
map = _ref4[1];
|
|
217
|
-
if (mode === 'light' || mode === 'dark') {
|
|
218
|
-
result[mode] = _objectSpread(_objectSpread({}, map), additionalContrastChecker({
|
|
219
|
-
customThemeTokenMap: map,
|
|
220
|
-
mode: mode,
|
|
221
|
-
themeRamp: colors
|
|
222
|
-
}));
|
|
223
|
-
}
|
|
224
|
-
});
|
|
225
|
-
return result;
|
|
226
|
-
};
|
|
227
|
-
export { getClosestColorIndex } from './get-closest-color-index';
|
|
163
|
+
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { deltaE
|
|
1
|
+
import { deltaE } from './delta-e';
|
|
2
|
+
import { hexToRgb } from './hex-to-rgb';
|
|
2
3
|
export var getClosestColorIndex = function getClosestColorIndex(themeRamp, brandColor) {
|
|
3
4
|
// Iterate over themeRamp and find whichever color is closest to brandColor
|
|
4
5
|
var 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
|
+
var foregroundRgb = hexToRgb(foreground);
|
|
9
|
+
var backgroundRgb = hexToRgb(background);
|
|
10
|
+
var foregroundLuminance = relativeLuminanceW3C(foregroundRgb[0], foregroundRgb[1], foregroundRgb[2]);
|
|
11
|
+
var 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
|
+
var r = delinearized(linrgb[0]);
|
|
9
|
+
var g = delinearized(linrgb[1]);
|
|
10
|
+
var 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
|
+
var y = yFromLstar(lstar);
|
|
14
|
+
var component = delinearized(y);
|
|
15
|
+
return argbFromRgb(component, component, component);
|
|
16
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
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(_ref) {
|
|
9
|
+
var r = _ref.r,
|
|
10
|
+
g = _ref.g,
|
|
11
|
+
b = _ref.b,
|
|
12
|
+
a = _ref.a;
|
|
13
|
+
var rValue = clampComponent(r);
|
|
14
|
+
var gValue = clampComponent(g);
|
|
15
|
+
var bValue = clampComponent(b);
|
|
16
|
+
var aValue = clampComponent(a);
|
|
17
|
+
return aValue << 24 | rValue << 16 | gValue << 8 | bValue;
|
|
18
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { argbFromRgb } from './argb-from-rgb';
|
|
2
|
+
import { delinearized } from './delinearized';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Color science utilities.
|
|
6
|
+
*
|
|
7
|
+
* Utility methods for color science constants and color space
|
|
8
|
+
* conversions that aren't HCT or CAM16.
|
|
9
|
+
*/
|
|
10
|
+
var XYZ_TO_SRGB = [[3.2413774792388685, -1.5376652402851851, -0.49885366846268053], [-0.9691452513005321, 1.8758853451067872, 0.04156585616912061], [0.05562093689691305, -0.20395524564742123, 1.0571799111220335]];
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Converts a color from ARGB to XYZ.
|
|
14
|
+
*/
|
|
15
|
+
export function argbFromXyz(x, y, z) {
|
|
16
|
+
var matrix = XYZ_TO_SRGB;
|
|
17
|
+
var linearR = matrix[0][0] * x + matrix[0][1] * y + matrix[0][2] * z;
|
|
18
|
+
var linearG = matrix[1][0] * x + matrix[1][1] * y + matrix[1][2] * z;
|
|
19
|
+
var linearB = matrix[2][0] * x + matrix[2][1] * y + matrix[2][2] * z;
|
|
20
|
+
var r = delinearized(linearR);
|
|
21
|
+
var g = delinearized(linearG);
|
|
22
|
+
var b = delinearized(linearB);
|
|
23
|
+
return argbFromRgb(r, g, b);
|
|
24
|
+
}
|
|
@@ -28,9 +28,9 @@ import _createClass from "@babel/runtime/helpers/createClass";
|
|
|
28
28
|
//
|
|
29
29
|
// tslint:disable:class-as-namespace
|
|
30
30
|
|
|
31
|
-
import
|
|
32
|
-
import
|
|
33
|
-
|
|
31
|
+
import { clampDouble } from './clamp-double';
|
|
32
|
+
import { lstarFromY } from './lstar-from-y';
|
|
33
|
+
import { yFromLstar } from './y-from-lstar';
|
|
34
34
|
/**
|
|
35
35
|
* Utility methods for calculating contrast given two colors, or calculating a
|
|
36
36
|
* color given one color and a contrast ratio.
|
|
@@ -57,9 +57,9 @@ export var Contrast = /*#__PURE__*/function () {
|
|
|
57
57
|
* @param toneB Tone between 0 and 100. Values outside will be clamped.
|
|
58
58
|
*/
|
|
59
59
|
function ratioOfTones(toneA, toneB) {
|
|
60
|
-
toneA =
|
|
61
|
-
toneB =
|
|
62
|
-
return Contrast.ratioOfYs(
|
|
60
|
+
toneA = clampDouble(0.0, 100.0, toneA);
|
|
61
|
+
toneB = clampDouble(0.0, 100.0, toneB);
|
|
62
|
+
return Contrast.ratioOfYs(yFromLstar(toneA), yFromLstar(toneB));
|
|
63
63
|
}
|
|
64
64
|
}, {
|
|
65
65
|
key: "ratioOfYs",
|
|
@@ -85,7 +85,7 @@ export var Contrast = /*#__PURE__*/function () {
|
|
|
85
85
|
if (tone < 0.0 || tone > 100.0) {
|
|
86
86
|
return -1.0;
|
|
87
87
|
}
|
|
88
|
-
var darkY =
|
|
88
|
+
var darkY = yFromLstar(tone);
|
|
89
89
|
var lightY = ratio * (darkY + 5.0) - 5.0;
|
|
90
90
|
var realContrast = Contrast.ratioOfYs(lightY, darkY);
|
|
91
91
|
var delta = Math.abs(realContrast - ratio);
|
|
@@ -95,7 +95,7 @@ export var Contrast = /*#__PURE__*/function () {
|
|
|
95
95
|
|
|
96
96
|
// Ensure gamut mapping, which requires a 'range' on tone, will still result
|
|
97
97
|
// the correct ratio by darkening slightly.
|
|
98
|
-
var returnValue =
|
|
98
|
+
var returnValue = lstarFromY(lightY) + 0.4;
|
|
99
99
|
if (returnValue < 0 || returnValue > 100) {
|
|
100
100
|
return -1;
|
|
101
101
|
}
|
|
@@ -118,7 +118,7 @@ export var Contrast = /*#__PURE__*/function () {
|
|
|
118
118
|
if (tone < 0.0 || tone > 100.0) {
|
|
119
119
|
return -1.0;
|
|
120
120
|
}
|
|
121
|
-
var lightY =
|
|
121
|
+
var lightY = yFromLstar(tone);
|
|
122
122
|
var darkY = (lightY + 5.0) / ratio - 5.0;
|
|
123
123
|
var realContrast = Contrast.ratioOfYs(lightY, darkY);
|
|
124
124
|
var delta = Math.abs(realContrast - ratio);
|
|
@@ -128,7 +128,7 @@ export var Contrast = /*#__PURE__*/function () {
|
|
|
128
128
|
|
|
129
129
|
// Ensure gamut mapping, which requires a 'range' on tone, will still result
|
|
130
130
|
// the correct ratio by darkening slightly.
|
|
131
|
-
var returnValue =
|
|
131
|
+
var returnValue = lstarFromY(darkY) - 0.4;
|
|
132
132
|
if (returnValue < 0 || returnValue > 100) {
|
|
133
133
|
return -1;
|
|
134
134
|
}
|
|
@@ -23,9 +23,16 @@ import _createClass from "@babel/runtime/helpers/createClass";
|
|
|
23
23
|
* limitations under the License.
|
|
24
24
|
*/
|
|
25
25
|
|
|
26
|
-
import
|
|
26
|
+
import { argbFromLinrgb } from './argb-from-linrgb';
|
|
27
|
+
import { argbFromLstar } from './argb-from-lstar';
|
|
28
|
+
import { argbFromXyz } from './argb-from-xyz';
|
|
29
|
+
import { linearized } from './linearized';
|
|
30
|
+
import { lstarFromArgb } from './lstar-from-argb';
|
|
31
|
+
import { lstarFromY } from './lstar-from-y';
|
|
27
32
|
import * as math from './math-utils';
|
|
28
33
|
import { ViewingConditions } from './viewing-conditions';
|
|
34
|
+
import { yFromLstar } from './y-from-lstar';
|
|
35
|
+
|
|
29
36
|
/**
|
|
30
37
|
* A color system built using CAM16 hue and chroma, and L* from
|
|
31
38
|
* L*a*b*.
|
|
@@ -54,7 +61,7 @@ export var Hct = /*#__PURE__*/function () {
|
|
|
54
61
|
var cam = Cam16.fromInt(argb);
|
|
55
62
|
this.internalHue = cam.hue;
|
|
56
63
|
this.internalChroma = cam.chroma;
|
|
57
|
-
this.internalTone =
|
|
64
|
+
this.internalTone = lstarFromArgb(argb);
|
|
58
65
|
}
|
|
59
66
|
return _createClass(Hct, [{
|
|
60
67
|
key: "toInt",
|
|
@@ -118,7 +125,7 @@ export var Hct = /*#__PURE__*/function () {
|
|
|
118
125
|
var cam = Cam16.fromInt(argb);
|
|
119
126
|
this.internalHue = cam.hue;
|
|
120
127
|
this.internalChroma = cam.chroma;
|
|
121
|
-
this.internalTone =
|
|
128
|
+
this.internalTone = lstarFromArgb(argb);
|
|
122
129
|
this.argb = argb;
|
|
123
130
|
}
|
|
124
131
|
|
|
@@ -149,7 +156,7 @@ export var Hct = /*#__PURE__*/function () {
|
|
|
149
156
|
// 3. Create HCT from:
|
|
150
157
|
// - CAM16 using default VC with XYZ coordinates in specified VC.
|
|
151
158
|
// - L* converted from Y in XYZ coordinates in specified VC.
|
|
152
|
-
var recastHct = Hct.from(recastInVc.hue, recastInVc.chroma,
|
|
159
|
+
var recastHct = Hct.from(recastInVc.hue, recastInVc.chroma, lstarFromY(viewedInVc[1]));
|
|
153
160
|
return recastHct;
|
|
154
161
|
}
|
|
155
162
|
}], [{
|
|
@@ -300,7 +307,7 @@ var Cam16 = /*#__PURE__*/function () {
|
|
|
300
307
|
var x = 1.86206786 * rF - 1.01125463 * gF + 0.14918677 * bF;
|
|
301
308
|
var y = 0.38752654 * rF + 0.62144744 * gF - 0.00897398 * bF;
|
|
302
309
|
var z = -0.0158415 * rF - 0.03412294 * gF + 1.04996444 * bF;
|
|
303
|
-
var argb =
|
|
310
|
+
var argb = argbFromXyz(x, y, z);
|
|
304
311
|
return argb;
|
|
305
312
|
}
|
|
306
313
|
|
|
@@ -358,9 +365,9 @@ var Cam16 = /*#__PURE__*/function () {
|
|
|
358
365
|
var red = (argb & 0x00ff0000) >> 16;
|
|
359
366
|
var green = (argb & 0x0000ff00) >> 8;
|
|
360
367
|
var blue = argb & 0x000000ff;
|
|
361
|
-
var redL =
|
|
362
|
-
var greenL =
|
|
363
|
-
var blueL =
|
|
368
|
+
var redL = linearized(red);
|
|
369
|
+
var greenL = linearized(green);
|
|
370
|
+
var blueL = linearized(blue);
|
|
364
371
|
var x = 0.41233895 * redL + 0.35762064 * greenL + 0.18051042 * blueL;
|
|
365
372
|
var y = 0.2126 * redL + 0.7152 * greenL + 0.0722 * blueL;
|
|
366
373
|
var z = 0.01932141 * redL + 0.11916382 * greenL + 0.95034478 * blueL;
|
|
@@ -881,7 +888,7 @@ var HctSolver = /*#__PURE__*/function () {
|
|
|
881
888
|
if (linrgb[0] > 100.01 || linrgb[1] > 100.01 || linrgb[2] > 100.01) {
|
|
882
889
|
return 0;
|
|
883
890
|
}
|
|
884
|
-
return
|
|
891
|
+
return argbFromLinrgb(linrgb);
|
|
885
892
|
}
|
|
886
893
|
// Iterates with Newton method,
|
|
887
894
|
// Using 2 * fn(j) / j as the approximation of fn'(j)
|
|
@@ -906,17 +913,17 @@ var HctSolver = /*#__PURE__*/function () {
|
|
|
906
913
|
key: "solveToInt",
|
|
907
914
|
value: function solveToInt(hueDegrees, chroma, lstar) {
|
|
908
915
|
if (chroma < 0.0001 || lstar < 0.0001 || lstar > 99.9999) {
|
|
909
|
-
return
|
|
916
|
+
return argbFromLstar(lstar);
|
|
910
917
|
}
|
|
911
918
|
hueDegrees = math.sanitizeDegreesDouble(hueDegrees);
|
|
912
919
|
var hueRadians = hueDegrees / 180 * Math.PI;
|
|
913
|
-
var y =
|
|
920
|
+
var y = yFromLstar(lstar);
|
|
914
921
|
var exactAnswer = HctSolver.findResultByJ(hueRadians, chroma, y);
|
|
915
922
|
if (exactAnswer !== 0) {
|
|
916
923
|
return exactAnswer;
|
|
917
924
|
}
|
|
918
925
|
var linrgb = HctSolver.bisectToLimit(y, hueRadians);
|
|
919
|
-
return
|
|
926
|
+
return argbFromLinrgb(linrgb);
|
|
920
927
|
}
|
|
921
928
|
|
|
922
929
|
/**
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { blueFromArgb } from './blue-from-argb';
|
|
2
|
+
import { greenFromArgb } from './green-from-argb';
|
|
3
|
+
import { labF } from './lab-f';
|
|
4
|
+
import { linearized } from './linearized';
|
|
5
|
+
import { matrixMultiply } from './matrix-multiply';
|
|
6
|
+
import { redFromArgb } from './red-from-argb';
|
|
7
|
+
var SRGB_TO_XYZ = [[0.41233895, 0.35762064, 0.18051042], [0.2126, 0.7152, 0.0722], [0.01932141, 0.11916382, 0.95034478]];
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Converts a color from XYZ to ARGB.
|
|
11
|
+
*/
|
|
12
|
+
function xyzFromArgb(argb) {
|
|
13
|
+
var r = linearized(redFromArgb(argb));
|
|
14
|
+
var g = linearized(greenFromArgb(argb));
|
|
15
|
+
var b = linearized(blueFromArgb(argb));
|
|
16
|
+
return matrixMultiply([r, g, b], SRGB_TO_XYZ);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Computes the L* value of a color in ARGB representation.
|
|
21
|
+
*
|
|
22
|
+
* @param argb ARGB representation of a color
|
|
23
|
+
* @return L*, from L*a*b*, coordinate of the color
|
|
24
|
+
*/
|
|
25
|
+
export function lstarFromArgb(argb) {
|
|
26
|
+
var y = xyzFromArgb(argb)[1];
|
|
27
|
+
return 116.0 * labF(y / 100.0) - 16.0;
|
|
28
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { labF } from './lab-f';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Converts a Y value to an L* value.
|
|
5
|
+
*
|
|
6
|
+
* L* in L*a*b* and Y in XYZ measure the same quantity, luminance.
|
|
7
|
+
*
|
|
8
|
+
* L* measures perceptual luminance, a linear scale. Y in XYZ
|
|
9
|
+
* measures relative luminance, a logarithmic scale.
|
|
10
|
+
*
|
|
11
|
+
* @param y Y in XYZ
|
|
12
|
+
* @return L* in L*a*b*
|
|
13
|
+
*/
|
|
14
|
+
export function lstarFromY(y) {
|
|
15
|
+
return labF(y / 100.0) * 116.0 - 16.0;
|
|
16
|
+
}
|