Files
twenty/front/src/modules/ui/menu-item/components/MenuItemToggle.tsx
T
gitstart-twenty 00a3c8ca2b Change to using arrow functions (#1603)
* 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>
2023-09-15 18:41:10 -07:00

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>
);
};