00a3c8ca2b
* Change to using arrow functions Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Matheus <matheus_benini@hotmail.com> * Add lint rule --------- Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Matheus <matheus_benini@hotmail.com> Co-authored-by: Charles Bochet <charles@twenty.com>
33 lines
858 B
TypeScript
33 lines
858 B
TypeScript
import { IconComponent } from '@/ui/icon/types/IconComponent';
|
|
import { Toggle } from '@/ui/input/components/Toggle';
|
|
|
|
import { MenuItemLeftContent } from '../internals/components/MenuItemLeftContent';
|
|
import { StyledMenuItemBase } from '../internals/components/StyledMenuItemBase';
|
|
|
|
type OwnProps = {
|
|
LeftIcon?: IconComponent;
|
|
toggled: boolean;
|
|
text: string;
|
|
className: string;
|
|
onToggleChange?: (toggled: boolean) => void;
|
|
};
|
|
|
|
export const MenuItemToggle = ({
|
|
LeftIcon,
|
|
text,
|
|
toggled,
|
|
className,
|
|
onToggleChange,
|
|
}: OwnProps) => {
|
|
const handleOnClick = () => {
|
|
onToggleChange?.(!toggled);
|
|
};
|
|
|
|
return (
|
|
<StyledMenuItemBase className={className} onClick={handleOnClick}>
|
|
<MenuItemLeftContent LeftIcon={LeftIcon} text={text} />
|
|
<Toggle value={toggled} onChange={onToggleChange} />
|
|
</StyledMenuItemBase>
|
|
);
|
|
};
|