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

95 lines
2.5 KiB
JavaScript
Raw Normal View History

2019-12-02 10:19:32 +05:00
import React from "react";
import { Flex, Box, Text } from "rebass";
2020-10-28 12:22:01 +05:00
import { SUBSCRIPTION_STATUS } from "../../common";
import { useStore as useUserStore } from "../../stores/user-store";
2019-12-02 10:19:32 +05:00
function Menu(props) {
const isTrial = useUserStore(
2020-10-28 12:22:01 +05:00
(store) => store.user?.subscription?.status === SUBSCRIPTION_STATUS.TRIAL
);
2019-12-02 10:19:32 +05:00
return (
2019-12-19 10:04:46 +05:00
<Flex
id={props.id}
2020-01-08 15:04:18 +05:00
bg="background"
2019-12-19 10:04:46 +05:00
py={1}
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,
...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>
{props.menuItems.map(
(item) =>
item.visible !== false && (
<Flex
test: setup E2E Tests (#161) * test: intialize testing environment * test: add an example test for reference * test: add simple navigation test * some initial tests * some changes * name and other small changes * permanently delete a note * permanenlt delete a note * test: improve test readability I have added different id builders for building test ids. They make the tests more readable and fluent. * test lock a note * test add a note to notebook * test favorite a note * test pin a note * test: further improve test readability basically I refactored some frequently performed actions into helper functions * test: check for presence of toast * test: properly test pinned note * test: increase tests reliability * test: fix all tests * perf: load 2co script & fonts when needed * ci: initialize e2e gh test runner * ci: do not run npm ci * test: fix lock note test for all browsers * ci: fix playwright tests * ci: fix yaml syntax error * ci: no need to use custom ssh-agent action for eslint * test: improve lock a note test * ci: add GH_DEPLOY_KEY env in eslint.yml * test: check for state: "visible" in isPresent * test: do not check for toast in lock a note test * test: log crypto error to console * test: skip "lock a note" test for now until further investigation * ci: only run tests on firefox & chromium * fix: fix useMediaQuery for WebKit browsers * ci: try webkit once again * properties tests * test tag a color /properties * test: run some tests sequentially and independently * test: reenable all tests * fix: user only able to type on character in title box * test: skip lock/unlock tests in CI * test edit a notebook * test: fix all tests * test: fix and add more notebook tests * test: do not only run edit topics test * test: make sure all notes tests pass * test: skip add note to notebook tests for now * test: make sure all tests pass Co-authored-by: alihamuh <alihamuh@gmail.com>
2020-09-28 14:31:45 +05:00
data-test-id={`menuitem-${item.title
.split(" ")
.join("")
.toLowerCase()}`}
key={item.title}
2020-11-10 15:08:31 +05:00
onClick={async (e) => {
e.stopPropagation();
if (props.closeMenu) {
props.closeMenu();
}
2020-11-10 15:08:31 +05:00
2020-09-14 12:07:02 +05:00
if (!item.component) {
item.onClick(props.data);
}
}}
flexDirection="row"
alignItems="center"
justifyContent="space-between"
py={"8px"}
px={3}
sx={{
color: item.color || "text",
cursor: "pointer",
":hover": {
backgroundColor: "shade",
},
}}
>
{item.component ? (
<item.component data={props.data} />
) : (
<Text as="span" fontFamily="body" fontSize="menu">
{item.title}
</Text>
)}
2020-11-10 15:08:31 +05:00
{item.onlyPro && !isTrial && (
<Text
fontSize="menu"
bg="primary"
color="static"
px={1}
sx={{ borderRadius: "default" }}
>
Pro
</Text>
)}
</Flex>
)
)}
2019-12-02 10:19:32 +05:00
</Box>
</Flex>
);
}
export default Menu;