-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathDropdownButton.tsx
More file actions
37 lines (35 loc) · 1.05 KB
/
DropdownButton.tsx
File metadata and controls
37 lines (35 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import React, { JSX } from 'react';
import { Menu, Button, Text } from '@mantine/core';
import { type DropdownButtonProps } from './types';
import { Icon } from '@iconify-icon/react';
const DropdownButton = ({
title,
dropdownItems,
}: DropdownButtonProps): JSX.Element => {
return (
<Menu onChange={(value) => console.log(value)}>
<Menu.Target>
<Button color="secondary">{title}</Button>
</Menu.Target>
<Menu.Dropdown>
{dropdownItems.map((button) => {
return (
<Menu.Item
key={button.title}
disabled={button.enabled !== undefined ? !button.enabled : true}
leftSection={
button?.leftIcon ? <Icon icon={button.leftIcon} /> : null
}
rightSection={
button?.rightIcon ? <Icon icon={button.rightIcon} /> : null
}
>
<Text>{button.title}</Text>
</Menu.Item>
);
})}
</Menu.Dropdown>
</Menu>
);
};
export default DropdownButton;