ntfy/web/src/components/PopupMenu.jsx

49 lines
1.2 KiB
React
Raw Normal View History

2023-05-23 21:13:01 +02:00
import { Fade, Menu } from "@mui/material";
import * as React from "react";
const PopupMenu = (props) => {
2023-05-23 21:13:01 +02:00
const horizontal = props.horizontal ?? "left";
const arrow = horizontal === "right" ? { right: 19 } : { left: 19 };
return (
<Menu
anchorEl={props.anchorEl}
open={props.open}
onClose={props.onClose}
onClick={props.onClose}
TransitionComponent={Fade}
PaperProps={{
elevation: 0,
sx: {
overflow: "visible",
filter: "drop-shadow(0px 2px 8px rgba(0,0,0,0.32))",
mt: 1.5,
"& .MuiAvatar-root": {
width: 32,
height: 32,
ml: -0.5,
mr: 1,
},
"&:before": {
content: '""',
display: "block",
position: "absolute",
top: 0,
width: 10,
height: 10,
bgcolor: "background.paper",
transform: "translateY(-50%) rotate(45deg)",
zIndex: 0,
...arrow,
},
},
}}
2023-05-24 09:03:28 +02:00
transformOrigin={{ horizontal, vertical: "top" }}
anchorOrigin={{ horizontal, vertical: "bottom" }}
2023-05-23 21:13:01 +02:00
>
{props.children}
</Menu>
);
};
export default PopupMenu;