Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// We find the line defining the `rgbString`
let matchingLine = _.find(lines, (line) => {
return _.startsWith(line, 'var rgbString');
});
// We parse it
let rgbString = matchingLine.replace(/(.*)"(.*)"(.*)/, '$2');
let split = _.map(rgbString.split(','), _.toInteger);
if (split.length !== 3) {
return null;
}
let red = split[0];
let green = split[1];
let blue = split[2];
let hexa = rgb2hex(red, green, blue).toUpperCase();
return {
red, green, blue, hexa
};
}
};
const toHex = color =>
(isHexColor(color) ? color : `#${rgbHex(color)}`).toLowerCase()
const toHex = ({
red,
green,
blue,
alpha,
}) => `#${rgbHex(red, green, blue, alpha / 255)}`;
Array.from(this.colorElements.children).forEach((colorElement) => {
const colorKey = colorElement.dataset.colorKey;
const computedStyle = getComputedStyle(colorElement);
colors[colorKey] = `#${rgbHex(computedStyle.color)}`;
});