Refactor/dropdown menu (#279)
* Created dropdown menu UI component with story * Added all components for composing Dropdown Menus * Better component naming and reordered stories * Solved comment thread from review
This commit is contained in:
@ -0,0 +1,44 @@
|
||||
import React from 'react';
|
||||
import styled from '@emotion/styled';
|
||||
import { IconCheck } from '@tabler/icons-react';
|
||||
|
||||
import { hoverBackground } from '@/ui/layout/styles/themes';
|
||||
|
||||
import { DropdownMenuButton } from './DropdownMenuButton';
|
||||
|
||||
type Props = {
|
||||
selected: boolean;
|
||||
onClick: () => void;
|
||||
};
|
||||
|
||||
const DropdownMenuSelectableItemContainer = styled(DropdownMenuButton)<Props>`
|
||||
${hoverBackground};
|
||||
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
`;
|
||||
|
||||
const StyledLeftContainer = styled.div`
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
gap: ${(props) => props.theme.spacing(2)};
|
||||
`;
|
||||
|
||||
const StyledRightIcon = styled.div`
|
||||
display: flex;
|
||||
`;
|
||||
|
||||
export function DropdownMenuSelectableItem({
|
||||
selected,
|
||||
onClick,
|
||||
children,
|
||||
}: React.PropsWithChildren<Props>) {
|
||||
return (
|
||||
<DropdownMenuSelectableItemContainer onClick={onClick} selected={selected}>
|
||||
<StyledLeftContainer>{children}</StyledLeftContainer>
|
||||
<StyledRightIcon>{selected && <IconCheck size={16} />}</StyledRightIcon>
|
||||
</DropdownMenuSelectableItemContainer>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user