From 2c7f3781fcd8c496766b43973716c6bf6990352f Mon Sep 17 00:00:00 2001 From: hxtree Date: Fri, 22 Dec 2023 05:26:27 +0000 Subject: [PATCH] feat: add disable clear button Signed-off-by: hxtree --- .../src/components/DiceAnalyzer.tsx | 25 +++++++++---------- .../src/components/Button/Button.tsx | 11 ++++++-- .../src/components/Button/style.module.scss | 8 +++++- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/services/admin-client/src/components/DiceAnalyzer.tsx b/services/admin-client/src/components/DiceAnalyzer.tsx index d3462ae7..d2a4d823 100644 --- a/services/admin-client/src/components/DiceAnalyzer.tsx +++ b/services/admin-client/src/components/DiceAnalyzer.tsx @@ -123,21 +123,20 @@ export const DiceAnalyzer = (props: DiceAnalyzerProps) => {
diff --git a/services/design-system/src/components/Button/Button.tsx b/services/design-system/src/components/Button/Button.tsx index 9bf8753b..bee7370d 100644 --- a/services/design-system/src/components/Button/Button.tsx +++ b/services/design-system/src/components/Button/Button.tsx @@ -27,12 +27,13 @@ export type ButtonProps = { selected?: boolean; size?: keyof typeof ButtonSize; href?: string; // TODO add support + disabled?: boolean; onClick?: (event: React.MouseEvent) => void; testId?: string; } export const Button = React.forwardRef((props: ButtonProps, ref) => { - const { testId, href, loading, color, children, variant, selected, size, onClick } = props; + const { disabled, testId, href, loading, color, children, variant, selected, size, onClick } = props; const classNames: string[] = ['button']; @@ -63,7 +64,12 @@ export const Button = React.forwardRef((props: B } let onClickHandler; - if (onClick !== undefined) { + let isButtonDisabled = false; + + if(disabled){ + isButtonDisabled = true; + classNames.push(`button-disabled`) + } else if (onClick !== undefined) { onClickHandler = onClick; } else if(href){ onClickHandler = () => { window.location.href = href}; @@ -71,6 +77,7 @@ export const Button = React.forwardRef((props: B return (