Files
notesnook/apps/web/src/components/menu/index.js

52 lines
1.2 KiB
JavaScript
Raw Normal View History

2019-12-02 10:19:32 +05:00
import React from "react";
import { Flex, Box, Text } from "rebass";
import Dropdown from "../dropdown";
2019-12-02 10:19:32 +05:00
function Menu(props) {
return (
2019-12-19 10:04:46 +05:00
<Flex
2020-01-08 15:04:18 +05:00
bg="background"
2019-12-19 10:04:46 +05:00
py={1}
sx={{
position: "relative",
borderRadius: "default",
boxShadow: 2,
width: 120
}}
>
2020-01-08 15:04:18 +05:00
<Box width="100%">
2019-12-02 10:19:32 +05:00
{props.menuItems.map(item => (
<Flex
2019-12-02 10:28:54 +05:00
key={item.title}
2019-12-04 13:13:00 +05:00
onClick={e => {
2020-01-06 17:34:45 +05:00
e.stopPropagation();
Dropdown.closeLastOpened();
2019-12-02 10:19:32 +05:00
if (props.dropdownRef) {
props.dropdownRef.hide();
}
if (item.onClick) {
item.onClick(props.data);
}
}}
flexDirection="row"
alignItems="center"
py={1}
px={2}
sx={{
2019-12-02 10:28:54 +05:00
color: item.color || "fontPrimary",
2019-12-02 10:19:32 +05:00
":hover": {
2020-01-08 14:58:24 +05:00
backgroundColor: "shade"
2019-12-02 10:19:32 +05:00
}
}}
>
<Text as="span" mx={1} fontFamily="body" fontSize="menu">
2019-12-02 10:19:32 +05:00
{item.title}
</Text>
</Flex>
))}
</Box>
</Flex>
);
}
export default Menu;