UNPKG

wix-style-react

Version:
15 lines (13 loc) 430 B
import calc_color_vars from '../../Foundation/stylable/mixins/calc_color_vars'; var colorRegEx = new RegExp(/^#(?:[0-9a-fA-F]{3}){1,2}$/i); export var calcColors = function calcColors(color) { var colors = {}; if (color) { if (colorRegEx.test(color)) { Object.assign(colors, calc_color_vars(color)); } else { throw new Error('color must be a 3 or 6 hex digits string only'); } } return colors; };