Refactor/new menu item (#1448)
* wip * finished * Added disabled * Fixed disabled * Finished cleaning * Minor fixes from merge * Added docs * Added PascalCase * Fix from review * Fixes from merge * Fix lint * Fixed storybook tests
This commit is contained in:
@ -1,32 +1,22 @@
|
||||
import { ReactNode } from 'react';
|
||||
import styled from '@emotion/styled';
|
||||
import { IconComponent } from '@/ui/icon/types/IconComponent';
|
||||
import { MenuItem } from '@/ui/menu-item/components/MenuItem';
|
||||
|
||||
import { DropdownMenuItem } from '@/ui/dropdown/components/DropdownMenuItem';
|
||||
|
||||
type ContextMenuEntryAccent = 'regular' | 'danger';
|
||||
type ContextMenuEntryAccent = 'default' | 'danger';
|
||||
|
||||
type OwnProps = {
|
||||
icon: ReactNode;
|
||||
Icon: IconComponent;
|
||||
label: string;
|
||||
accent?: ContextMenuEntryAccent;
|
||||
onClick: () => void;
|
||||
};
|
||||
|
||||
const StyledButtonLabel = styled.div`
|
||||
font-weight: ${({ theme }) => theme.font.weight.medium};
|
||||
margin-left: ${({ theme }) => theme.spacing(2)};
|
||||
`;
|
||||
|
||||
export function ContextMenuEntry({
|
||||
label,
|
||||
icon,
|
||||
accent = 'regular',
|
||||
Icon,
|
||||
accent = 'default',
|
||||
onClick,
|
||||
}: OwnProps) {
|
||||
return (
|
||||
<DropdownMenuItem onClick={onClick} accent={accent}>
|
||||
{icon}
|
||||
<StyledButtonLabel>{label}</StyledButtonLabel>
|
||||
</DropdownMenuItem>
|
||||
<MenuItem LeftIcon={Icon} onClick={onClick} accent={accent} text={label} />
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user