UNPKG

ice.fo.utils

Version:

9 lines (7 loc) 333 B
import _isString from 'lodash/isString'; export default function getHexColor(colorObject) { if (_isString(colorObject)) { return colorObject; } const { value = '', label = '' } = colorObject || { value: '', label: '' }; const hexColor = (label).match(/#[0-9a-f]{6}|#[0-9a-f]{3}/gi); return hexColor ? hexColor[0] : value; }