2019-12-02 10:19:32 +05:00
|
|
|
import React from "react";
|
|
|
|
|
import { Flex, Box, Text } from "rebass";
|
2020-05-15 00:35:20 +05:00
|
|
|
import { useStore as useUserStore } from "../../stores/user-store";
|
2019-12-02 10:19:32 +05:00
|
|
|
|
|
|
|
|
function Menu(props) {
|
2020-08-25 08:56:40 +05:00
|
|
|
const isTrial = useUserStore(
|
|
|
|
|
(store) => store.user?.notesnook?.subscription?.isTrial
|
|
|
|
|
);
|
2020-05-15 00:35:20 +05:00
|
|
|
|
2019-12-02 10:19:32 +05:00
|
|
|
return (
|
2019-12-19 10:04:46 +05:00
|
|
|
<Flex
|
2020-03-01 20:03:37 +05:00
|
|
|
id={props.id}
|
2020-01-08 15:04:18 +05:00
|
|
|
bg="background"
|
2019-12-19 10:04:46 +05:00
|
|
|
py={1}
|
2020-03-01 20:03:37 +05:00
|
|
|
style={props.style}
|
2019-12-19 10:04:46 +05:00
|
|
|
sx={{
|
|
|
|
|
position: "relative",
|
|
|
|
|
borderRadius: "default",
|
2020-03-28 23:29:04 +05:00
|
|
|
border: "2px solid",
|
|
|
|
|
borderColor: "border",
|
2020-04-21 10:56:43 +05:00
|
|
|
width: 180,
|
2020-04-14 23:36:23 +05:00
|
|
|
...props.sx,
|
2019-12-19 10:04:46 +05:00
|
|
|
}}
|
|
|
|
|
>
|
2020-01-08 15:04:18 +05:00
|
|
|
<Box width="100%">
|
2020-03-02 15:00:53 +05:00
|
|
|
<Text
|
|
|
|
|
fontFamily="body"
|
|
|
|
|
fontSize="body"
|
|
|
|
|
color="primary"
|
|
|
|
|
py={"8px"}
|
|
|
|
|
px={3}
|
|
|
|
|
sx={{ borderBottom: "1px solid", borderBottomColor: "border" }}
|
|
|
|
|
>
|
|
|
|
|
Properties
|
|
|
|
|
</Text>
|
2020-03-17 12:39:49 +05:00
|
|
|
{props.menuItems.map(
|
2020-04-14 23:36:23 +05:00
|
|
|
(item) =>
|
2020-05-16 14:05:06 +05:00
|
|
|
(item.visible === undefined || item.visible === true) && (
|
2020-03-17 12:39:49 +05:00
|
|
|
<Flex
|
|
|
|
|
key={item.title}
|
2020-04-14 23:36:23 +05:00
|
|
|
onClick={(e) => {
|
2020-03-17 12:39:49 +05:00
|
|
|
e.stopPropagation();
|
|
|
|
|
if (props.closeMenu) {
|
|
|
|
|
props.closeMenu();
|
|
|
|
|
}
|
2020-08-25 09:50:21 +05:00
|
|
|
item.onClick(props.data);
|
2020-03-17 12:39:49 +05:00
|
|
|
}}
|
|
|
|
|
flexDirection="row"
|
|
|
|
|
alignItems="center"
|
2020-05-15 00:35:20 +05:00
|
|
|
justifyContent="space-between"
|
2020-03-17 12:39:49 +05:00
|
|
|
py={"8px"}
|
|
|
|
|
px={3}
|
|
|
|
|
sx={{
|
2020-04-14 23:36:23 +05:00
|
|
|
color: item.color || "text",
|
2020-04-16 14:18:00 +05:00
|
|
|
cursor: "pointer",
|
2020-03-17 12:39:49 +05:00
|
|
|
":hover": {
|
2020-04-14 23:36:23 +05:00
|
|
|
backgroundColor: "shade",
|
|
|
|
|
},
|
2020-03-17 12:39:49 +05:00
|
|
|
}}
|
|
|
|
|
>
|
2020-04-16 12:32:33 +05:00
|
|
|
{item.component ? (
|
|
|
|
|
<item.component data={props.data} />
|
|
|
|
|
) : (
|
|
|
|
|
<Text as="span" fontFamily="body" fontSize="menu">
|
|
|
|
|
{item.title}
|
|
|
|
|
</Text>
|
|
|
|
|
)}
|
2020-08-25 09:50:21 +05:00
|
|
|
{item.onlyPro && isTrial === undefined && (
|
2020-05-15 00:35:20 +05:00
|
|
|
<Text
|
|
|
|
|
fontSize="menu"
|
|
|
|
|
bg="primary"
|
|
|
|
|
color="static"
|
|
|
|
|
px={1}
|
|
|
|
|
sx={{ borderRadius: "default" }}
|
|
|
|
|
>
|
|
|
|
|
Pro
|
|
|
|
|
</Text>
|
|
|
|
|
)}
|
2020-03-17 12:39:49 +05:00
|
|
|
</Flex>
|
|
|
|
|
)
|
|
|
|
|
)}
|
2019-12-02 10:19:32 +05:00
|
|
|
</Box>
|
|
|
|
|
</Flex>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
export default Menu;
|