Files
new-phone-who-dis/phone/src/ui/components/ContextMenu.tsx
T
J Francisco Rader 40f9555b39 Make Camera app use router (#69)
* Make Camera app use router

* Remove unused hooks

* Fucking communicate messages with camera with router

* Improved sharing in messages flow

* Fix clipboard

* Removeunused imports

* improve routing helpers

* Fix bug :D

* Fix stupid thing

* Add docs to useQueryParams hook
2021-02-06 22:24:50 +01:00

58 lines
1.3 KiB
TypeScript

import React from 'react';
import {
ListItemIcon,
ListItemText,
Slide,
makeStyles,
Paper,
} from '@material-ui/core';
import { List } from './List';
import { ListItem } from './ListItem';
const useStyles = makeStyles((theme) => ({
root: {
width: '100%',
position: 'absolute',
bottom: 0,
zIndex: 2,
},
}));
interface IContextMenuProps {
open: boolean;
onClose(): void;
options: Array<{
onClick(e, option): void;
label: string;
selected?: boolean;
icon?: React.ReactNode;
key?: string;
}>;
}
export const ContextMenu = ({ open, onClose, options }: IContextMenuProps) => {
const classes = useStyles();
return (
<Slide direction='up' in={open} mountOnEnter unmountOnExit>
<Paper square className={classes.root}>
<List disablePadding>
{options.map((option) => (
<ListItem
selected={option.selected}
key={option.key || option.label}
button
onClick={(e) => {
option.onClick(e, option);
onClose();
}}
>
{option.icon && <ListItemIcon>{option.icon}</ListItemIcon>}
<ListItemText primary={option.label} />
</ListItem>
))}
</List>
</Paper>
</Slide>
);
};