From fa503814270d14613a6bca624d35935ed60c3b0f Mon Sep 17 00:00:00 2001 From: Tharun T Date: Fri, 5 Jul 2024 21:17:06 +0530 Subject: [PATCH 1/3] style: ActionButton for new designs Signed-off-by: Tharun T --- src/custom/ActionButton/ActionButton.tsx | 33 +++++++++++++++--------- 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/src/custom/ActionButton/ActionButton.tsx b/src/custom/ActionButton/ActionButton.tsx index 86937c6a..f2b5878d 100644 --- a/src/custom/ActionButton/ActionButton.tsx +++ b/src/custom/ActionButton/ActionButton.tsx @@ -3,6 +3,7 @@ import { Button, ButtonGroup, ClickAwayListener, + Divider, MenuItem, MenuList, Paper, @@ -13,6 +14,8 @@ interface Option { icon: React.ReactNode; label: string; onClick: (event: React.MouseEvent, index: number) => void; + isDivider?: boolean; + show?: boolean; } interface ActionButtonProps { @@ -68,18 +71,24 @@ export default function ActionButton({ - {options.map((option, index) => ( - { - handleMenuItemClick(); - option.onClick(event, index); - }} - > -
{option.icon}
- {option.label} -
- ))} + {options + .filter((option) => option.show !== false) + .map((option, index) => + option.isDivider ? ( + + ) : ( + { + handleMenuItemClick(); + option.onClick(event, index); + }} + > +
{option.icon}
+ {option.label} +
+ ) + )}
From ca24a528acde8f1f3fc57f49fd7065db5490ebbe Mon Sep 17 00:00:00 2001 From: Tharun T Date: Fri, 5 Jul 2024 21:25:08 +0530 Subject: [PATCH 2/3] fix: optional show Signed-off-by: Tharun T --- src/custom/ActionButton/ActionButton.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/custom/ActionButton/ActionButton.tsx b/src/custom/ActionButton/ActionButton.tsx index f2b5878d..5ecfbc5f 100644 --- a/src/custom/ActionButton/ActionButton.tsx +++ b/src/custom/ActionButton/ActionButton.tsx @@ -72,7 +72,7 @@ export default function ActionButton({ {options - .filter((option) => option.show !== false) + .filter((option) => option?.show !== false) .map((option, index) => option.isDivider ? ( From 35b0e9e9d5aa9db4fea1c664551d324a01152948 Mon Sep 17 00:00:00 2001 From: Tharun T Date: Fri, 5 Jul 2024 21:53:40 +0530 Subject: [PATCH 3/3] fix: defaultActionDisabled flag Signed-off-by: Tharun T --- src/custom/ActionButton/ActionButton.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/custom/ActionButton/ActionButton.tsx b/src/custom/ActionButton/ActionButton.tsx index 5ecfbc5f..dc8d1647 100644 --- a/src/custom/ActionButton/ActionButton.tsx +++ b/src/custom/ActionButton/ActionButton.tsx @@ -20,12 +20,14 @@ interface Option { interface ActionButtonProps { defaultActionClick: () => void; + defaultActionDisabled?: boolean; options: Option[]; label: string; } export default function ActionButton({ defaultActionClick, + defaultActionDisabled = false, options, label }: ActionButtonProps): JSX.Element { @@ -53,7 +55,7 @@ export default function ActionButton({ style={{ boxShadow: 'none' }} aria-label="Button group with a nested menu" > -