Skip to content

Commit fa50381

Browse files
committed
style: ActionButton for new designs
Signed-off-by: Tharun T <[email protected]>
1 parent 369d3ea commit fa50381

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

src/custom/ActionButton/ActionButton.tsx

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
Button,
44
ButtonGroup,
55
ClickAwayListener,
6+
Divider,
67
MenuItem,
78
MenuList,
89
Paper,
@@ -13,6 +14,8 @@ interface Option {
1314
icon: React.ReactNode;
1415
label: string;
1516
onClick: (event: React.MouseEvent<HTMLLIElement, MouseEvent>, index: number) => void;
17+
isDivider?: boolean;
18+
show?: boolean;
1619
}
1720

1821
interface ActionButtonProps {
@@ -68,18 +71,24 @@ export default function ActionButton({
6871
<Paper>
6972
<ClickAwayListener onClickAway={handleClose}>
7073
<MenuList id="split-button-menu" autoFocusItem>
71-
{options.map((option, index) => (
72-
<MenuItem
73-
key={index}
74-
onClick={(event) => {
75-
handleMenuItemClick();
76-
option.onClick(event, index);
77-
}}
78-
>
79-
<div style={{ marginRight: '1rem' }}>{option.icon}</div>
80-
{option.label}
81-
</MenuItem>
82-
))}
74+
{options
75+
.filter((option) => option.show !== false)
76+
.map((option, index) =>
77+
option.isDivider ? (
78+
<Divider />
79+
) : (
80+
<MenuItem
81+
key={index}
82+
onClick={(event) => {
83+
handleMenuItemClick();
84+
option.onClick(event, index);
85+
}}
86+
>
87+
<div style={{ marginRight: '1rem' }}>{option.icon}</div>
88+
{option.label}
89+
</MenuItem>
90+
)
91+
)}
8392
</MenuList>
8493
</ClickAwayListener>
8594
</Paper>

0 commit comments

Comments
 (0)