import { colors } from '../../../../src/style/variables'; import { Prefix } from '../constants'; import { getVarName, hexToRgb, rgbToHsl } from '../helpers'; import { GumColorMainHelper, GumColors, GumColorVar } from '../models'; /** * Returns hex and hsl values of main colors defined in variables.ts config */ export const getMainColors: GumColorMainHelper = () => { const newValues = {} as { [key in GumColors]: GumColorVar }; for (const key in colors) { if (colors.hasOwnProperty(key)) { const [r, g, b] = hexToRgb(colors[key]); const hslColor = rgbToHsl(r, g, b); const mainLabel = Math.floor(hslColor[2] / 10) + 1; const baseVarName = getVarName(Prefix.color, key); newValues[key] = { hex: colors[key], hsl: `${baseVarName}-${mainLabel}`, }; } } return newValues; };