@financial-times/o-colors
Advanced tools
Comparing version 6.0.7 to 6.0.8
import { getContrastRatio, getWCAGRating } from '../shared/contrast-ratio.js'; | ||
import { getHexValues, mixHexes } from '../shared/colors-mix.js'; | ||
import { getHexValues, mixHexes, expandHexValues } from '../shared/colors-mix.js'; | ||
@@ -20,4 +20,4 @@ document.addEventListener('DOMContentLoaded', () => { | ||
function showContrastRatio(text, background) { | ||
const textHex = changeColor(text.value, 'foreground'); | ||
const backgroundHex = changeColor(background.value, 'background'); | ||
const textHex = expandHexValues(changeColor(text.value, 'foreground')); | ||
const backgroundHex = expandHexValues(changeColor(background.value, 'background')); | ||
@@ -46,3 +46,3 @@ const ratio = getContrastRatio(textHex, backgroundHex); | ||
root.style.setProperty(`--${property}`, hexValue); | ||
return hexValue; | ||
return hexValue.replace('#', '').trim(); | ||
} | ||
@@ -49,0 +49,0 @@ |
@@ -22,2 +22,4 @@ const getHexValues = (mixer, base) => { | ||
const mixHexes = (mixer, base) => { | ||
const fullMixer = expandHexValues(mixer); | ||
const fullBase = expandHexValues(base); | ||
const radix = 16; | ||
@@ -34,4 +36,4 @@ const decimalToHex = decimal => decimal.toString(radix); | ||
for (let i = 0; i <= 5; i += 2) { | ||
const mixPair = hexToDecimal(expandHexValues(mixer.substr(i, 2))); // extract r, g, b pairs for mixer color | ||
const basePair = hexToDecimal(expandHexValues(base.substr(i, 2))); // extract r, g, b pairs for base color | ||
const mixPair = hexToDecimal(fullMixer.substr(i, 2)); // extract r, g, b pairs for mixer color | ||
const basePair = hexToDecimal(fullBase.substr(i, 2)); // extract r, g, b pairs for base color | ||
@@ -52,3 +54,4 @@ // combine the r/g/b pairs from each color, based on percentage | ||
getHexValues, | ||
mixHexes | ||
mixHexes, | ||
expandHexValues | ||
}; |
{ | ||
"name": "@financial-times/o-colors", | ||
"type": "module", | ||
"version": "6.0.7", | ||
"version": "6.0.8", | ||
"description": "The default colour palette for all FT products. The palette supports colour contrast checking, colour mixing and toneing.", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
114055
667