// import chroma from 'chroma-js' // TODO: add bak later for supporting deprecated lighten/darken function isHexColor(color: string): boolean { return /^#([0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/.test(color) } function lighten(color: string, percentage: number): string { return color // return chroma(color) // .brighten(percentage / 100) // .hex() } function darken(color: string, percentage: number): string { return color // return chroma(color) // .darken(percentage / 100) // .hex() } export function processColorString(colorString: string): string { const lightenRegex = /lighten\((#[0-9a-fA-F]{6}), (\d+)\)/ const darkenRegex = /darken\((#[0-9a-fA-F]{6}), (\d+)\)/ if (lightenRegex.test(colorString)) { const [, hex, percent] = lightenRegex.exec(colorString)! return lighten(hex, parseInt(percent)) } else if (darkenRegex.test(colorString)) { const [, hex, percent] = darkenRegex.exec(colorString)! return darken(hex, parseInt(percent)) } else if (isHexColor(colorString)) { // hex value return colorString } // string like '3px'... return colorString // Return original string if no match found }