diff --git a/src/renderer/components/shared/bsm-button.component.tsx b/src/renderer/components/shared/bsm-button.component.tsx index b3c1ccd1..daf76e84 100644 --- a/src/renderer/components/shared/bsm-button.component.tsx +++ b/src/renderer/components/shared/bsm-button.component.tsx @@ -12,12 +12,25 @@ export function BsmButton({className, style, imgClassName, icon, image, text, ty const t = useTranslation(); const secondColor = useThemeColor("second-color"); + const primaryColor = typeColor === "primary" ? useThemeColor("first-color") : null; + + const textColor = !primaryColor ? null : (() => { + const hex = primaryColor.replaceAll("#", ""); + const uicolors = [parseInt(hex.substring(0, 2), 16) / 255, parseInt(hex.substring(0, 2), 16) / 255, parseInt(hex.substring(0, 2), 16) / 255]; + const c = uicolors.map(col => { + if (col <= 0.03928) { return col / 12.92; } + return Math.pow((col + 0.055) / 1.055, 2.4); + }); + const L = (0.2126 * c[0]) + (0.7152 * c[1]) + (0.0722 * c[2]); + return (L > 0.179) ? "#000" : "fff"; + })(); + return ( onClickOutside && onClickOutside(e)}> -
onClick && onClick(e)} className={`${className} overflow-hidden cursor-pointer group ${disabled && "brightness-75 cursor-not-allowed"} ${typeColor === "error" && 'bg-red-500'} ${typeColor == "primary" && 'bg-blue-500'}`} style={style}> +
onClick && onClick(e)} className={`${className} overflow-hidden cursor-pointer group ${disabled && "brightness-75 cursor-not-allowed"} ${typeColor === "error" && 'bg-red-500'}`} style={{...style, ...(!!primaryColor && {backgroundColor: primaryColor})}}> { image && } { icon && } - {text && (type === "submit" ? : {t(text)})} + {text && (type === "submit" ? : {t(text)})} { withBar && (