2020-12-25 10:29:25 +01:00
|
|
|
import { FC } from 'react';
|
2020-12-25 10:43:36 +01:00
|
|
|
import { Dropdown, DropdownMenu, DropdownToggle } from 'reactstrap';
|
2020-12-25 10:29:25 +01:00
|
|
|
import { useToggle } from './helpers/hooks';
|
|
|
|
import './Dropdown.scss';
|
|
|
|
|
2020-12-25 10:43:36 +01:00
|
|
|
export interface DropdownBtnProps {
|
2020-12-25 10:29:25 +01:00
|
|
|
text: string;
|
|
|
|
disabled?: boolean;
|
|
|
|
className?: string;
|
|
|
|
}
|
|
|
|
|
2020-12-25 10:43:36 +01:00
|
|
|
export const DropdownBtn: FC<DropdownBtnProps> = ({ text, disabled = false, className = '', children }) => {
|
2020-12-25 10:29:25 +01:00
|
|
|
const [ isOpen, toggle ] = useToggle();
|
2020-12-25 10:54:49 +01:00
|
|
|
const toggleClasses = `dropdown-btn__toggle btn-block ${className}`;
|
2020-12-25 10:29:25 +01:00
|
|
|
|
|
|
|
return (
|
2020-12-25 10:43:36 +01:00
|
|
|
<Dropdown isOpen={isOpen} toggle={toggle} disabled={disabled}>
|
2020-12-25 10:39:54 +01:00
|
|
|
<DropdownToggle caret className={toggleClasses} color="primary">{text}</DropdownToggle>
|
2020-12-25 10:29:25 +01:00
|
|
|
<DropdownMenu className="w-100">{children}</DropdownMenu>
|
2020-12-25 10:43:36 +01:00
|
|
|
</Dropdown>
|
2020-12-25 10:29:25 +01:00
|
|
|
);
|
|
|
|
};
|