import parseColor from 'color' ; const LOW_LIGHTNESS_COLOR = 'white' ; const HIGH_LIGHTNESS_COLOR = 'black' ; para export const highContrastColor = ( backgroundColor ) : string => { try { return parseColor ( backgroundColor ) . isLight ( ) ? HIGH_LIGHTNESS_COLOR : LOW_LIGHTNESS_COLOR ; } catch ( err ) { console . error ( err ) ; } return LOW_LIGHTNESS_COLOR ; } ;