2020-08-28 10:51:41 +00:00
|
|
|
import React, { ReactNode } from "react";
|
2020-08-31 13:04:34 +00:00
|
|
|
import { CommonComponentProps, Classes } from "./common";
|
2020-08-28 10:51:41 +00:00
|
|
|
import styled from "styled-components";
|
2020-08-31 04:59:18 +00:00
|
|
|
import Icon, { IconName, IconSize } from "./Icon";
|
2020-08-31 13:04:34 +00:00
|
|
|
import Text, { TextType, FontWeight } from "./Text";
|
2020-08-28 10:51:41 +00:00
|
|
|
|
|
|
|
|
type MenuItemProps = CommonComponentProps & {
|
|
|
|
|
icon?: IconName;
|
|
|
|
|
text: string;
|
|
|
|
|
label?: ReactNode;
|
|
|
|
|
onSelect?: () => void;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const ItemRow = styled.div`
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
justify-content: space-between;
|
|
|
|
|
padding: ${props => props.theme.spaces[4]}px
|
|
|
|
|
${props => props.theme.spaces[6]}px;
|
|
|
|
|
|
|
|
|
|
&:hover {
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
background-color: ${props => props.theme.colors.blackShades[4]};
|
2020-08-31 13:04:34 +00:00
|
|
|
.${Classes.TEXT} {
|
2020-08-28 10:51:41 +00:00
|
|
|
color: ${props => props.theme.colors.blackShades[9]};
|
|
|
|
|
}
|
2020-09-01 07:24:53 +00:00
|
|
|
.${Classes.ICON} {
|
2020-08-28 10:51:41 +00:00
|
|
|
path {
|
|
|
|
|
fill: ${props => props.theme.colors.blackShades[9]};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
const IconContainer = styled.div`
|
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
2020-09-01 07:24:53 +00:00
|
|
|
.${Classes.ICON} {
|
2020-08-28 10:51:41 +00:00
|
|
|
margin-right: ${props => props.theme.spaces[5]}px;
|
|
|
|
|
}
|
|
|
|
|
`;
|
|
|
|
|
|
|
|
|
|
function MenuItem(props: MenuItemProps) {
|
|
|
|
|
return (
|
|
|
|
|
<ItemRow onClick={props.onSelect}>
|
|
|
|
|
<IconContainer>
|
2020-08-31 04:59:18 +00:00
|
|
|
{props.icon ? <Icon name={props.icon} size={IconSize.LARGE} /> : null}
|
2020-08-31 13:04:34 +00:00
|
|
|
{props.text ? (
|
|
|
|
|
<Text type={TextType.H5} weight={FontWeight.NORMAL}>
|
|
|
|
|
{props.text}
|
|
|
|
|
</Text>
|
|
|
|
|
) : null}
|
2020-08-28 10:51:41 +00:00
|
|
|
</IconContainer>
|
|
|
|
|
{props.label ? <Text type={TextType.P1}>{props.label}</Text> : null}
|
|
|
|
|
</ItemRow>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default MenuItem;
|