New MenuItem components (#1389)

* wip

* Finished

* Fix from review

* Fix lint

* Fixed toggle
This commit is contained in:
Lucas Bordeau
2023-09-01 11:35:19 +02:00
committed by GitHub
parent 2538ad1c6b
commit 240edda25c
20 changed files with 933 additions and 39 deletions
@@ -0,0 +1,43 @@
import styled from '@emotion/styled';
import { IconComponent } from '@/ui/icon/types/IconComponent';
import { Checkbox } from '@/ui/input/checkbox/components/Checkbox';
import { MenuItemLeftContent } from '../internals/components/MenuItemLeftContent';
import { StyledMenuItemBase } from '../internals/components/StyledMenuItemBase';
const StyledLeftContentWithCheckboxContainer = styled.div`
align-items: center;
display: flex;
flex-direction: row;
gap: ${({ theme }) => theme.spacing(2)};
`;
type OwnProps = {
LeftIcon?: IconComponent;
selected: boolean;
text: string;
className: string;
onSelectChange?: (selected: boolean) => void;
};
export function MenuItemMultiSelect({
LeftIcon,
text,
selected,
className,
onSelectChange,
}: OwnProps) {
function handleOnClick() {
onSelectChange?.(!selected);
}
return (
<StyledMenuItemBase className={className} onClick={handleOnClick}>
<StyledLeftContentWithCheckboxContainer>
<Checkbox checked={selected} />
<MenuItemLeftContent LeftIcon={LeftIcon} text={text} />
</StyledLeftContentWithCheckboxContainer>
</StyledMenuItemBase>
);
}