From 4b04843bbd06ba521f7d100e887047e22626aa7d Mon Sep 17 00:00:00 2001 From: MathieuG-P <40181755+Zagrios@users.noreply.github.com> Date: Mon, 25 Jul 2022 22:55:21 +0200 Subject: [PATCH] define props type for more readability --- .../shared/bsm-button.component.tsx | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/renderer/components/shared/bsm-button.component.tsx b/src/renderer/components/shared/bsm-button.component.tsx index daf76e84..c3e04b01 100644 --- a/src/renderer/components/shared/bsm-button.component.tsx +++ b/src/renderer/components/shared/bsm-button.component.tsx @@ -7,13 +7,29 @@ import { useThemeColor } from "renderer/hooks/use-theme-color.hook"; type BsmButtonType = "primary"|"success"|"cancel"|"error"; -export function BsmButton({className, style, imgClassName, icon, image, text, type, active, withBar = true, disabled, onClickOutside, onClick, typeColor}: {className?: string, style?: React.CSSProperties, imgClassName?: string, icon?: BsmIconType, image?: string, text?: string, type?: string, active?: boolean, withBar?: boolean, disabled?: boolean, onClickOutside?: (e: MouseEvent) => void, onClick?: (e: React.MouseEvent) => void, typeColor?:BsmButtonType}) { +type propsType = { + className?: string, + style?: React.CSSProperties, + imgClassName?: string, + icon?: BsmIconType, + image?: string, + text?: string, + type?: string, + active?: boolean, + withBar?: boolean, + disabled?: boolean, + onClickOutside?: (e: MouseEvent) => void, + onClick?: (e: React.MouseEvent) => void, + typeColor?:BsmButtonType +} + +export function BsmButton({className, style, imgClassName, icon, image, text, type, active, withBar = true, disabled, onClickOutside, onClick, typeColor}: propsType) { 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];