Skip to content

Commit 63eabf2

Browse files
committed
Merge branch 'test' of git://github.com/AceTheCreator/dnotebook into AceTheCreator-test
2 parents cc356ff + d3fd7da commit 63eabf2

File tree

16 files changed

+613
-202
lines changed

16 files changed

+613
-202
lines changed

node_modules/.yarn-integrity

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/frontend/components/IconMenu/file.tsx

Lines changed: 81 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,85 @@
1-
import * as React from 'react';
2-
import Divider from '@mui/material/Divider';
3-
import Paper from '@mui/material/Paper';
4-
import MenuList from '@mui/material/MenuList';
5-
import MenuItem from '@mui/material/MenuItem';
6-
import ListItemText from '@mui/material/ListItemText';
7-
import ListItemIcon from '@mui/material/ListItemIcon';
8-
import Typography from '@mui/material/Typography';
91
import FileNew from '@mui/icons-material/AddBox';
102
import FileOpen from '@mui/icons-material/OpenInNew';
113
import DriveFileRenameOutlineIcon from '@mui/icons-material/DriveFileRenameOutline';
124
import SaveIcon from '@mui/icons-material/Save';
135
import SaveAltIcon from '@mui/icons-material/SaveAlt';
146
import ImportExportIcon from '@mui/icons-material/ImportExport';
157
import PowerSettingsNewIcon from '@mui/icons-material/PowerSettingsNew';
16-
8+
import React, { useState } from "react";
9+
import MenuList from "@mui/material/MenuList";
10+
import Menu from "@mui/material/Menu";
11+
import MenuItem from "@mui/material/MenuItem";
12+
import ListItemText from "@mui/material/ListItemText";
13+
import ListItemIcon from "@mui/material/ListItemIcon";
14+
import Typography from "@mui/material/Typography";
15+
import ArrowForwardIosRoundedIcon from "@mui/icons-material/ArrowForwardIosRounded";
16+
import FileList from "./fileList";
1717

1818
export default function FileMenu() {
19+
const [activeMenuOption, setActiveMenuOptions] = useState({
20+
"file-menu": false,
21+
"edit-menu": false,
22+
});
23+
const [anchorEl, setAnchorEl] = useState<null | HTMLElement>(null);
24+
const handleMenuClick = (event: React.MouseEvent<HTMLButtonElement>) => {
25+
const id = event.currentTarget.id;
26+
setAnchorEl(event.currentTarget);
27+
//@ts-ignore */
28+
const selectedMenuOptionState = activeMenuOption[id];
29+
const newActiveMenuOption: any = {};
30+
31+
Object.keys(activeMenuOption).forEach((key) => {
32+
newActiveMenuOption[key] = false;
33+
});
34+
newActiveMenuOption[id] = !selectedMenuOptionState;
35+
setActiveMenuOptions(newActiveMenuOption);
36+
};
37+
const listStyle = {
38+
display: "flex",
39+
justifyContent: "space-between",
40+
};
41+
const fontSize = {
42+
fontSize: "13px",
43+
width: "70px",
44+
};
45+
const arrowStyle = {
46+
width: "15px",
47+
marginLeft: "20px",
48+
};
1949
return (
20-
<Paper sx={{ width: 320, maxWidth: '100%' }}>
50+
<div>
2151
<MenuList>
52+
<div>
53+
{/* @ts-ignore */}
54+
<MenuItem
55+
style={listStyle}
56+
id="file-menu"
57+
variant={activeMenuOption["file-menu"] ? "outlined" : "text"}
58+
onMouseEnter={handleMenuClick}
59+
>
60+
<div style={fontSize}>File</div>
61+
<ArrowForwardIosRoundedIcon style={arrowStyle} />
62+
</MenuItem>
63+
<Menu
64+
anchorEl={anchorEl}
65+
open={activeMenuOption["file-menu"]}
66+
onClose={handleMenuClick}
67+
anchorOrigin={{
68+
vertical: "top",
69+
horizontal: "right",
70+
}}
71+
transformOrigin={{
72+
vertical: "top",
73+
horizontal: "left",
74+
}}
75+
style={{
76+
marginTop: "-15px",
77+
borderRadius: "0px",
78+
}}
79+
>
80+
<FileList />
81+
</Menu>
82+
</div>
2283
<MenuItem>
2384
<ListItemIcon>
2485
<FileNew fontSize="small" />
@@ -72,15 +133,22 @@ export default function FileMenu() {
72133
<Typography variant="body2" color="text.secondary">
73134
⌘DE
74135
</Typography>
136+
<div style={fontSize}>Edit</div>
137+
<ArrowForwardIosRoundedIcon style={arrowStyle} />
138+
</MenuItem>
139+
<MenuItem>
140+
<div style={fontSize}>Selection</div>
141+
<ArrowForwardIosRoundedIcon style={arrowStyle} />
75142
</MenuItem>
76-
<Divider />
77143
<MenuItem>
78144
<ListItemIcon>
79145
<PowerSettingsNewIcon fontSize="small" />
80146
</ListItemIcon>
81147
<ListItemText>Shut Down</ListItemText>
148+
<div style={fontSize}>Help</div>
149+
<ArrowForwardIosRoundedIcon style={arrowStyle} />
82150
</MenuItem>
83151
</MenuList>
84-
</Paper>
152+
</div>
85153
);
86-
}
154+
};
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
import MenuList from "@mui/material/MenuList";
2+
import { useDispatch } from "react-redux";
3+
import { setDirectories } from "../../lib/state/reducer";
4+
import MenuItem from "@mui/material/MenuItem";
5+
import { openFile, openFolder } from "../../lib/utils/fileSystem";
6+
import { Divider } from "@mui/material";
7+
8+
export default function FileList() {
9+
const dispatch = useDispatch();
10+
async function onFolderSelect() {
11+
const folders = await openFolder();
12+
dispatch(setDirectories(folders));
13+
}
14+
const listStyle = {
15+
display: "flex",
16+
justifyContent: "space-between",
17+
};
18+
const fontSize = {
19+
fontSize: "13px",
20+
minWidth: "180px",
21+
};
22+
const arrowStyle = {
23+
width: "15px",
24+
marginLeft: "20px",
25+
};
26+
return (
27+
<div>
28+
<MenuList>
29+
<MenuItem style={listStyle}>
30+
<div style={fontSize}>New File</div>
31+
</MenuItem>
32+
<MenuItem style={listStyle}>
33+
<div style={fontSize}>New Window</div>
34+
</MenuItem>
35+
<Divider />
36+
<MenuItem onClick={() => openFile()}>
37+
<div style={fontSize}>Open File</div>
38+
</MenuItem>
39+
<MenuItem onClick={() => onFolderSelect()}>
40+
<div style={fontSize}>Open Folder</div>
41+
</MenuItem>
42+
<Divider />
43+
<MenuItem>
44+
<div style={fontSize}>Save</div>
45+
</MenuItem>
46+
<MenuItem>
47+
<div style={fontSize}>Save As</div>
48+
</MenuItem>
49+
<Divider />
50+
<MenuItem>
51+
<div style={fontSize}>Close Editor</div>
52+
</MenuItem>
53+
</MenuList>
54+
</div>
55+
);
56+
}

0 commit comments

Comments
 (0)