@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
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/tokens",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.1.1",
|
|
4
4
|
"description": "Design tokens are the single source of truth to name and store design decisions.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -50,31 +50,31 @@
|
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@af/formatting": "workspace:^",
|
|
52
52
|
"@af/visual-regression": "workspace:^",
|
|
53
|
-
"@atlaskit/avatar": "^25.
|
|
53
|
+
"@atlaskit/avatar": "^25.15.0",
|
|
54
54
|
"@atlaskit/button": "^23.11.0",
|
|
55
55
|
"@atlaskit/calendar": "^17.2.0",
|
|
56
56
|
"@atlaskit/checkbox": "^17.3.0",
|
|
57
57
|
"@atlaskit/code": "^17.5.0",
|
|
58
58
|
"@atlaskit/css": "^0.19.0",
|
|
59
59
|
"@atlaskit/docs": "^11.8.0",
|
|
60
|
-
"@atlaskit/dropdown-menu": "^16.
|
|
60
|
+
"@atlaskit/dropdown-menu": "^16.10.0",
|
|
61
61
|
"@atlaskit/dynamic-table": "^18.4.0",
|
|
62
62
|
"@atlaskit/form": "^15.5.0",
|
|
63
63
|
"@atlaskit/heading": "^5.4.0",
|
|
64
|
-
"@atlaskit/icon": "^
|
|
64
|
+
"@atlaskit/icon": "^35.3.0",
|
|
65
65
|
"@atlaskit/inline-message": "^15.6.0",
|
|
66
66
|
"@atlaskit/link": "^3.4.0",
|
|
67
67
|
"@atlaskit/lozenge": "^13.8.0",
|
|
68
|
-
"@atlaskit/popup": "^4.
|
|
68
|
+
"@atlaskit/popup": "^4.23.0",
|
|
69
69
|
"@atlaskit/primitives": "^19.0.0",
|
|
70
70
|
"@atlaskit/radio": "^8.6.0",
|
|
71
|
-
"@atlaskit/section-message": "^8.
|
|
72
|
-
"@atlaskit/select": "^21.
|
|
73
|
-
"@atlaskit/tag": "^14.
|
|
71
|
+
"@atlaskit/section-message": "^8.13.0",
|
|
72
|
+
"@atlaskit/select": "^21.12.0",
|
|
73
|
+
"@atlaskit/tag": "^14.14.0",
|
|
74
74
|
"@atlaskit/textarea": "^8.3.0",
|
|
75
75
|
"@atlaskit/textfield": "^8.3.0",
|
|
76
|
-
"@atlaskit/theme": "^
|
|
77
|
-
"@atlaskit/tooltip": "^22.
|
|
76
|
+
"@atlaskit/theme": "^25.0.0",
|
|
77
|
+
"@atlaskit/tooltip": "^22.5.0",
|
|
78
78
|
"@atlassian/codegen": "^0.2.0",
|
|
79
79
|
"@atlassian/feature-flags-test-utils": "^1.1.0",
|
|
80
80
|
"@atlassian/react-compiler-gating": "workspace:^",
|
|
@@ -86,13 +86,13 @@
|
|
|
86
86
|
"@testing-library/react": "^16.3.0",
|
|
87
87
|
"color-blend": "^4.0.0",
|
|
88
88
|
"echarts": "^5.4.1",
|
|
89
|
-
"echarts-for-react": "
|
|
89
|
+
"echarts-for-react": "3.0.6",
|
|
90
90
|
"jscodeshift": "^17.0.0",
|
|
91
91
|
"json5": "^2.2.2",
|
|
92
92
|
"lodash": "^4.17.21",
|
|
93
93
|
"postcss": "^8.4.7",
|
|
94
94
|
"postcss-less": "^6.0.0",
|
|
95
|
-
"react": "^
|
|
95
|
+
"react": "^19.0.0",
|
|
96
96
|
"react-window": "^1.8.8",
|
|
97
97
|
"style-dictionary": "^3.8.0"
|
|
98
98
|
},
|
package/tokens.docs.tsx
CHANGED
|
@@ -1,53 +1,55 @@
|
|
|
1
1
|
import path from 'path';
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type { StructuredContentSource } from '@atlassian/structured-docs-types/types';
|
|
4
4
|
|
|
5
|
-
const documentation:
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
description:
|
|
9
|
-
'Design tokens provide consistent, semantic values for colors, spacing, typography, motion, and other design properties across the Atlassian Design System. Use tokens instead of hardcoded values to ensure consistency and proper theming.',
|
|
10
|
-
status: 'general-availability',
|
|
11
|
-
import: {
|
|
5
|
+
const documentation: StructuredContentSource = {
|
|
6
|
+
components: [
|
|
7
|
+
{
|
|
12
8
|
name: 'token',
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
],
|
|
23
|
-
accessibilityGuidelines: [
|
|
24
|
-
'Use color tokens to ensure proper contrast ratios',
|
|
25
|
-
'Test color combinations for accessibility compliance',
|
|
26
|
-
'Use semantic color names (success, warning, danger) for better meaning',
|
|
27
|
-
],
|
|
28
|
-
examples: [
|
|
29
|
-
{
|
|
30
|
-
name: 'Basic',
|
|
31
|
-
description: 'Basic example',
|
|
32
|
-
source: path.resolve(__dirname, './examples/ai/basic.tsx'),
|
|
9
|
+
description:
|
|
10
|
+
'Design tokens provide consistent, semantic values for colors, spacing, typography, motion, and other design properties across the Atlassian Design System. Use tokens instead of hardcoded values to ensure consistency and proper theming.',
|
|
11
|
+
status: 'general-availability',
|
|
12
|
+
import: {
|
|
13
|
+
name: 'token',
|
|
14
|
+
package: '@atlaskit/tokens',
|
|
15
|
+
type: 'named',
|
|
16
|
+
packagePath: path.resolve(__dirname),
|
|
17
|
+
packageJson: require('./package.json'),
|
|
33
18
|
},
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
19
|
+
usageGuidelines: [
|
|
20
|
+
'AVOID hardcoding any CSS values where a token exists for that type; in many cases you may be forced to use a token',
|
|
21
|
+
'Use the `token()` function with CSS-in-JS',
|
|
22
|
+
'Use semantic token names for better maintainability',
|
|
23
|
+
],
|
|
24
|
+
accessibilityGuidelines: [
|
|
25
|
+
'Use color tokens to ensure proper contrast ratios',
|
|
26
|
+
'Test color combinations for accessibility compliance',
|
|
27
|
+
'Use semantic color names (success, warning, danger) for better meaning',
|
|
28
|
+
],
|
|
29
|
+
examples: [
|
|
30
|
+
{
|
|
31
|
+
name: 'Basic',
|
|
32
|
+
description: 'Basic example',
|
|
33
|
+
source: path.resolve(__dirname, './examples/ai/basic.tsx'),
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
keywords: [
|
|
37
|
+
'token',
|
|
38
|
+
'design',
|
|
39
|
+
'system',
|
|
40
|
+
'color',
|
|
41
|
+
'motion',
|
|
42
|
+
'spacing',
|
|
43
|
+
'typography',
|
|
44
|
+
'radius',
|
|
45
|
+
'theme',
|
|
46
|
+
'css',
|
|
47
|
+
'style',
|
|
48
|
+
'variable',
|
|
49
|
+
],
|
|
50
|
+
categories: ['tokens'],
|
|
51
|
+
},
|
|
52
|
+
],
|
|
53
|
+
};
|
|
52
54
|
|
|
53
55
|
export default documentation;
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.themeStringToObject = exports.themeObjectToString = void 0;
|
|
8
|
-
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
9
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
10
|
-
var _themeIds = require("./theme-ids");
|
|
11
|
-
var themeKinds = ['light', 'dark', 'spacing', 'typography', 'shape', 'motion'];
|
|
12
|
-
var customThemeOptions = 'UNSAFE_themeOptions';
|
|
13
|
-
var isThemeKind = function isThemeKind(themeKind) {
|
|
14
|
-
return themeKinds.find(function (kind) {
|
|
15
|
-
return kind === themeKind;
|
|
16
|
-
}) !== undefined;
|
|
17
|
-
};
|
|
18
|
-
var isThemeIds = function isThemeIds(themeId) {
|
|
19
|
-
return _themeIds.themeIds.find(function (id) {
|
|
20
|
-
return id === themeId;
|
|
21
|
-
}) !== undefined;
|
|
22
|
-
};
|
|
23
|
-
var isColorMode = function isColorMode(modeId) {
|
|
24
|
-
return ['light', 'dark', 'auto'].includes(modeId);
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* Converts a string that is formatted for the `data-theme` HTML attribute
|
|
28
|
-
* to an object that can be passed to `setGlobalTheme`.
|
|
29
|
-
*
|
|
30
|
-
* @param {string} themes The themes that should be applied.
|
|
31
|
-
*
|
|
32
|
-
* @example
|
|
33
|
-
* ```
|
|
34
|
-
* themeStringToObject('dark:dark light:light spacing:spacing');
|
|
35
|
-
* // returns { dark: 'dark', light: 'light', spacing: 'spacing' }
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
var themeStringToObject = exports.themeStringToObject = function themeStringToObject(themeState) {
|
|
39
|
-
return themeState.split(' ')
|
|
40
|
-
// @ts-ignore - TS1501 TypeScript 5.9.2 upgrade
|
|
41
|
-
.map(function (theme) {
|
|
42
|
-
return theme.split(/:([^]*)/);
|
|
43
|
-
}).reduce(function (themeObject, _ref) {
|
|
44
|
-
var _ref2 = (0, _slicedToArray2.default)(_ref, 2),
|
|
45
|
-
kind = _ref2[0],
|
|
46
|
-
id = _ref2[1];
|
|
47
|
-
if (kind === 'colorMode' && isColorMode(id)) {
|
|
48
|
-
themeObject[kind] = id;
|
|
49
|
-
}
|
|
50
|
-
if (isThemeKind(kind) && isThemeIds(id)) {
|
|
51
|
-
// @ts-expect-error FIXME - this is a valid ts error
|
|
52
|
-
themeObject[kind] = id;
|
|
53
|
-
}
|
|
54
|
-
if (kind === customThemeOptions) {
|
|
55
|
-
try {
|
|
56
|
-
themeObject[customThemeOptions] = JSON.parse(id);
|
|
57
|
-
} catch (_unused) {
|
|
58
|
-
new Error('Invalid custom theme string');
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return themeObject;
|
|
62
|
-
}, {});
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Converts a theme object to a string formatted for the `data-theme` HTML attribute.
|
|
67
|
-
*
|
|
68
|
-
* @param {object} themes The themes that should be applied.
|
|
69
|
-
*
|
|
70
|
-
* @example
|
|
71
|
-
* ```
|
|
72
|
-
* themeObjectToString({ dark: 'dark', light: 'light', spacing: 'spacing' });
|
|
73
|
-
* // returns 'dark:dark light:light spacing:spacing'
|
|
74
|
-
* ```
|
|
75
|
-
*/
|
|
76
|
-
var themeObjectToString = exports.themeObjectToString = function themeObjectToString(themeState) {
|
|
77
|
-
return Object.entries(themeState).reduce(function (themeString, _ref3) {
|
|
78
|
-
var _ref4 = (0, _slicedToArray2.default)(_ref3, 2),
|
|
79
|
-
kind = _ref4[0],
|
|
80
|
-
id = _ref4[1];
|
|
81
|
-
if (
|
|
82
|
-
// colorMode theme state
|
|
83
|
-
kind === 'colorMode' && typeof id === 'string' && isColorMode(id) ||
|
|
84
|
-
// custom theme state
|
|
85
|
-
kind === customThemeOptions && (0, _typeof2.default)(id) === 'object' ||
|
|
86
|
-
// other theme states
|
|
87
|
-
isThemeKind(kind) && typeof id === 'string' && isThemeIds(id)) {
|
|
88
|
-
return themeString + "".concat(themeString ? ' ' : '') + "".concat(kind, ":").concat((0, _typeof2.default)(id) === 'object' ? JSON.stringify(id) : id);
|
|
89
|
-
}
|
|
90
|
-
return themeString;
|
|
91
|
-
}, '');
|
|
92
|
-
};
|
|
@@ -1,168 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "HSLToRGB", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function get() {
|
|
9
|
-
return _hslToRgb.HSLToRGB;
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
exports.deltaE = deltaE;
|
|
13
|
-
Object.defineProperty(exports, "getAlpha", {
|
|
14
|
-
enumerable: true,
|
|
15
|
-
get: function get() {
|
|
16
|
-
return _getAlpha.getAlpha;
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
exports.getContrastRatio = getContrastRatio;
|
|
20
|
-
exports.hexToHSL = hexToHSL;
|
|
21
|
-
exports.hexToRgb = hexToRgb;
|
|
22
|
-
exports.hexToRgbA = hexToRgbA;
|
|
23
|
-
Object.defineProperty(exports, "isValidBrandHex", {
|
|
24
|
-
enumerable: true,
|
|
25
|
-
get: function get() {
|
|
26
|
-
return _isValidBrandHex.isValidBrandHex;
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
Object.defineProperty(exports, "relativeLuminanceW3C", {
|
|
30
|
-
enumerable: true,
|
|
31
|
-
get: function get() {
|
|
32
|
-
return _relativeLuminanceW3C.relativeLuminanceW3C;
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
Object.defineProperty(exports, "rgbToHex", {
|
|
36
|
-
enumerable: true,
|
|
37
|
-
get: function get() {
|
|
38
|
-
return _rgbToHex.rgbToHex;
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
var _getAlpha = require("./get-alpha");
|
|
42
|
-
var _relativeLuminanceW3C = require("./relative-luminance-w3-c");
|
|
43
|
-
var _isValidBrandHex = require("./is-valid-brand-hex");
|
|
44
|
-
var _rgbToHex = require("./rgb-to-hex");
|
|
45
|
-
var _hslToRgb = require("./hsl-to-rgb");
|
|
46
|
-
// valid hex color with 4, 6 or 8 digits
|
|
47
|
-
var isValidHex = function isValidHex(hex) {
|
|
48
|
-
return /^#([A-Fa-f0-9]{3,4}){1,2}$/.test(hex);
|
|
49
|
-
};
|
|
50
|
-
function hexToRgbA(hex) {
|
|
51
|
-
if (!isValidHex(hex)) {
|
|
52
|
-
throw new Error('Invalid HEX');
|
|
53
|
-
}
|
|
54
|
-
var c;
|
|
55
|
-
c = hex.substring(1).split('');
|
|
56
|
-
if (c.length === 3) {
|
|
57
|
-
c = [c[0], c[0], c[1], c[1], c[2], c[2]];
|
|
58
|
-
}
|
|
59
|
-
c = '0x' + c.join('');
|
|
60
|
-
return [c >> 16 & 255, c >> 8 & 255, c & 255, (0, _getAlpha.getAlpha)(hex)];
|
|
61
|
-
}
|
|
62
|
-
function hexToRgb(hex) {
|
|
63
|
-
if (!isValidHex(hex)) {
|
|
64
|
-
throw new Error('Invalid HEX');
|
|
65
|
-
}
|
|
66
|
-
var c;
|
|
67
|
-
c = hex.substring(1).split('');
|
|
68
|
-
if (c.length === 3) {
|
|
69
|
-
c = [c[0], c[0], c[1], c[1], c[2], c[2]];
|
|
70
|
-
}
|
|
71
|
-
c = '0x' + c.join('');
|
|
72
|
-
return [c >> 16 & 255, c >> 8 & 255, c & 255];
|
|
73
|
-
}
|
|
74
|
-
function hexToHSL(hex) {
|
|
75
|
-
if (!isValidHex(hex)) {
|
|
76
|
-
throw new Error('Invalid HEX');
|
|
77
|
-
}
|
|
78
|
-
var r = 0,
|
|
79
|
-
g = 0,
|
|
80
|
-
b = 0;
|
|
81
|
-
if (hex.length === 4) {
|
|
82
|
-
r = '0x' + hex[1] + hex[1];
|
|
83
|
-
g = '0x' + hex[2] + hex[2];
|
|
84
|
-
b = '0x' + hex[3] + hex[3];
|
|
85
|
-
} else if (hex.length === 7) {
|
|
86
|
-
r = '0x' + hex[1] + hex[2];
|
|
87
|
-
g = '0x' + hex[3] + hex[4];
|
|
88
|
-
b = '0x' + hex[5] + hex[6];
|
|
89
|
-
}
|
|
90
|
-
// Then to HSL
|
|
91
|
-
r /= 255;
|
|
92
|
-
g /= 255;
|
|
93
|
-
b /= 255;
|
|
94
|
-
var cmin = Math.min(r, g, b),
|
|
95
|
-
cmax = Math.max(r, g, b),
|
|
96
|
-
delta = cmax - cmin,
|
|
97
|
-
h = 0,
|
|
98
|
-
s = 0,
|
|
99
|
-
l = 0;
|
|
100
|
-
if (delta === 0) {
|
|
101
|
-
h = 0;
|
|
102
|
-
} else if (cmax === r) {
|
|
103
|
-
h = (g - b) / delta % 6;
|
|
104
|
-
} else if (cmax === g) {
|
|
105
|
-
h = (b - r) / delta + 2;
|
|
106
|
-
} else {
|
|
107
|
-
h = (r - g) / delta + 4;
|
|
108
|
-
}
|
|
109
|
-
h = Math.round(h * 60);
|
|
110
|
-
if (h < 0) {
|
|
111
|
-
h += 360;
|
|
112
|
-
}
|
|
113
|
-
l = (cmax + cmin) / 2;
|
|
114
|
-
s = delta === 0 ? 0 : delta / (1 - Math.abs(2 * l - 1));
|
|
115
|
-
s = +(s * 100).toFixed(1);
|
|
116
|
-
l = +(l * 100).toFixed(1);
|
|
117
|
-
return [h, s, l];
|
|
118
|
-
}
|
|
119
|
-
function getContrastRatio(foreground, background) {
|
|
120
|
-
if (!isValidHex(foreground) || !isValidHex(background)) {
|
|
121
|
-
throw new Error('Invalid HEX');
|
|
122
|
-
}
|
|
123
|
-
var foregroundRgb = hexToRgb(foreground);
|
|
124
|
-
var backgroundRgb = hexToRgb(background);
|
|
125
|
-
var foregroundLuminance = (0, _relativeLuminanceW3C.relativeLuminanceW3C)(foregroundRgb[0], foregroundRgb[1], foregroundRgb[2]);
|
|
126
|
-
var backgroundLuminance = (0, _relativeLuminanceW3C.relativeLuminanceW3C)(backgroundRgb[0], backgroundRgb[1], backgroundRgb[2]);
|
|
127
|
-
// calculate the color contrast ratio
|
|
128
|
-
var brightest = Math.max(foregroundLuminance, backgroundLuminance);
|
|
129
|
-
var darkest = Math.min(foregroundLuminance, backgroundLuminance);
|
|
130
|
-
return (brightest + 0.05) / (darkest + 0.05);
|
|
131
|
-
}
|
|
132
|
-
function deltaE(rgbA, rgbB) {
|
|
133
|
-
var labA = rgbToLab(rgbA);
|
|
134
|
-
var labB = rgbToLab(rgbB);
|
|
135
|
-
var deltaL = labA[0] - labB[0];
|
|
136
|
-
var deltaA = labA[1] - labB[1];
|
|
137
|
-
var deltaB = labA[2] - labB[2];
|
|
138
|
-
var c1 = Math.sqrt(labA[1] * labA[1] + labA[2] * labA[2]);
|
|
139
|
-
var c2 = Math.sqrt(labB[1] * labB[1] + labB[2] * labB[2]);
|
|
140
|
-
var deltaC = c1 - c2;
|
|
141
|
-
var deltaH = deltaA * deltaA + deltaB * deltaB - deltaC * deltaC;
|
|
142
|
-
deltaH = deltaH < 0 ? 0 : Math.sqrt(deltaH);
|
|
143
|
-
var sc = 1.0 + 0.045 * c1;
|
|
144
|
-
var sh = 1.0 + 0.015 * c1;
|
|
145
|
-
var deltaLKlsl = deltaL / 1.0;
|
|
146
|
-
var deltaCkcsc = deltaC / sc;
|
|
147
|
-
var deltaHkhsh = deltaH / sh;
|
|
148
|
-
var i = deltaLKlsl * deltaLKlsl + deltaCkcsc * deltaCkcsc + deltaHkhsh * deltaHkhsh;
|
|
149
|
-
return i < 0 ? 0 : Math.sqrt(i);
|
|
150
|
-
}
|
|
151
|
-
function rgbToLab(rgb) {
|
|
152
|
-
var r = rgb[0] / 255,
|
|
153
|
-
g = rgb[1] / 255,
|
|
154
|
-
b = rgb[2] / 255,
|
|
155
|
-
x,
|
|
156
|
-
y,
|
|
157
|
-
z;
|
|
158
|
-
r = r > 0.04045 ? Math.pow((r + 0.055) / 1.055, 2.4) : r / 12.92;
|
|
159
|
-
g = g > 0.04045 ? Math.pow((g + 0.055) / 1.055, 2.4) : g / 12.92;
|
|
160
|
-
b = b > 0.04045 ? Math.pow((b + 0.055) / 1.055, 2.4) : b / 12.92;
|
|
161
|
-
x = (r * 0.4124 + g * 0.3576 + b * 0.1805) / 0.95047;
|
|
162
|
-
y = (r * 0.2126 + g * 0.7152 + b * 0.0722) / 1.0;
|
|
163
|
-
z = (r * 0.0193 + g * 0.1192 + b * 0.9505) / 1.08883;
|
|
164
|
-
x = x > 0.008856 ? Math.pow(x, 1 / 3) : 7.787 * x + 16 / 116;
|
|
165
|
-
y = y > 0.008856 ? Math.pow(y, 1 / 3) : 7.787 * y + 16 / 116;
|
|
166
|
-
z = z > 0.008856 ? Math.pow(z, 1 / 3) : 7.787 * z + 16 / 116;
|
|
167
|
-
return [116 * y - 16, 500 * (x - y), 200 * (y - z)];
|
|
168
|
-
}
|