import { colord, AnyColor } from 'colord'; import { Attributes, Lang } from '../../../types'; import { findBackgroundColor, findTextColor } from '../../../util/colors'; import { languages } from '../../../util/languages'; export const PillString = (attributes: Attributes) => { const { language, bgColor, textColor, headerString } = attributes; const bgC = colord(bgColor as AnyColor); let bg = bgC.toHex(); const textC = colord(textColor as AnyColor); let text = textC.isDark() ? textC.lighten(0.05).toHex() : textC.darken(0.05).toHex(); if (bgColor?.startsWith('var(')) { bg = findBackgroundColor(attributes) ?? bgColor; } if (textColor?.startsWith('var(')) { text = findTextColor(attributes) ?? textColor; } return ( {headerString || languages[language as Lang]} ); };