|
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'; |
9 | 1 | import FileNew from '@mui/icons-material/AddBox';
|
10 | 2 | import FileOpen from '@mui/icons-material/OpenInNew';
|
11 | 3 | import DriveFileRenameOutlineIcon from '@mui/icons-material/DriveFileRenameOutline';
|
12 | 4 | import SaveIcon from '@mui/icons-material/Save';
|
13 | 5 | import SaveAltIcon from '@mui/icons-material/SaveAlt';
|
14 | 6 | import ImportExportIcon from '@mui/icons-material/ImportExport';
|
15 | 7 | 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"; |
17 | 17 |
|
18 | 18 | 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 | + }; |
19 | 49 | return (
|
20 |
| - <Paper sx={{ width: 320, maxWidth: '100%' }}> |
| 50 | + <div> |
21 | 51 | <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> |
22 | 83 | <MenuItem>
|
23 | 84 | <ListItemIcon>
|
24 | 85 | <FileNew fontSize="small" />
|
@@ -72,15 +133,22 @@ export default function FileMenu() {
|
72 | 133 | <Typography variant="body2" color="text.secondary">
|
73 | 134 | ⌘DE
|
74 | 135 | </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} /> |
75 | 142 | </MenuItem>
|
76 |
| - <Divider /> |
77 | 143 | <MenuItem>
|
78 | 144 | <ListItemIcon>
|
79 | 145 | <PowerSettingsNewIcon fontSize="small" />
|
80 | 146 | </ListItemIcon>
|
81 | 147 | <ListItemText>Shut Down</ListItemText>
|
| 148 | + <div style={fontSize}>Help</div> |
| 149 | + <ArrowForwardIosRoundedIcon style={arrowStyle} /> |
82 | 150 | </MenuItem>
|
83 | 151 | </MenuList>
|
84 |
| - </Paper> |
| 152 | + </div> |
85 | 153 | );
|
86 |
| -} |
| 154 | +}; |
0 commit comments