first commit
This commit is contained in:
@@ -0,0 +1,124 @@
|
||||
import * as React from 'react';
|
||||
import PropTypes from 'prop-types';
|
||||
import Button from '@mui/material/Button';
|
||||
import Avatar from '@mui/material/Avatar';
|
||||
import List from '@mui/material/List';
|
||||
import ListItem from '@mui/material/ListItem';
|
||||
import ListItemAvatar from '@mui/material/ListItemAvatar';
|
||||
import ListItemButton from '@mui/material/ListItemButton';
|
||||
import ListItemText from '@mui/material/ListItemText';
|
||||
import DialogTitle from '@mui/material/DialogTitle';
|
||||
import Dialog from '@mui/material/Dialog';
|
||||
import PersonIcon from '@mui/icons-material/Person';
|
||||
import AddIcon from '@mui/icons-material/Add';
|
||||
import Typography from '@mui/material/Typography';
|
||||
import { blue } from '@mui/material/colors';
|
||||
import Card from "@mui/material/Card";
|
||||
|
||||
const emails = ['username@gmail.com', 'user02@gmail.com'];
|
||||
|
||||
function SimpleDialog(props) {
|
||||
const { onClose, selectedValue, open } = props;
|
||||
|
||||
const handleClose = () => {
|
||||
onClose(selectedValue);
|
||||
};
|
||||
|
||||
const handleListItemClick = (value) => {
|
||||
onClose(value);
|
||||
};
|
||||
|
||||
return (
|
||||
<Dialog onClose={handleClose} open={open}>
|
||||
<div className="bg-black">
|
||||
<DialogTitle>Set backup account</DialogTitle>
|
||||
|
||||
<List sx={{ pt: 0 }}>
|
||||
{emails.map((email) => (
|
||||
<ListItem disableGutters>
|
||||
<ListItemButton onClick={() => handleListItemClick(email)} key={email}>
|
||||
<ListItemAvatar>
|
||||
<Avatar sx={{ bgcolor: blue[100], color: blue[500] }}>
|
||||
<PersonIcon />
|
||||
</Avatar>
|
||||
</ListItemAvatar>
|
||||
<ListItemText primary={email} />
|
||||
</ListItemButton>
|
||||
</ListItem>
|
||||
))}
|
||||
|
||||
<ListItem disableGutters>
|
||||
<ListItemButton
|
||||
autoFocus
|
||||
onClick={() => handleListItemClick('addAccount')}
|
||||
>
|
||||
<ListItemAvatar>
|
||||
<Avatar>
|
||||
<AddIcon />
|
||||
</Avatar>
|
||||
</ListItemAvatar>
|
||||
<ListItemText primary="Add account" />
|
||||
</ListItemButton>
|
||||
</ListItem>
|
||||
</List>
|
||||
</div>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
SimpleDialog.propTypes = {
|
||||
onClose: PropTypes.func.isRequired,
|
||||
open: PropTypes.bool.isRequired,
|
||||
selectedValue: PropTypes.string.isRequired,
|
||||
};
|
||||
|
||||
export default function SimpleDialogDemo() {
|
||||
const [open, setOpen] = React.useState(false);
|
||||
const [selectedValue, setSelectedValue] = React.useState(emails[1]);
|
||||
|
||||
const handleClickOpen = () => {
|
||||
setOpen(true);
|
||||
};
|
||||
|
||||
const handleClose = (value) => {
|
||||
setOpen(false);
|
||||
setSelectedValue(value);
|
||||
};
|
||||
|
||||
return (
|
||||
<Card
|
||||
sx={{
|
||||
boxShadow: "none",
|
||||
borderRadius: "10px",
|
||||
p: "25px",
|
||||
mb: "15px",
|
||||
}}
|
||||
>
|
||||
<Typography
|
||||
as="h3"
|
||||
sx={{
|
||||
fontSize: 18,
|
||||
fontWeight: 500,
|
||||
mb: '10px'
|
||||
}}
|
||||
>
|
||||
Simple Dialog
|
||||
</Typography>
|
||||
|
||||
<div>
|
||||
<Typography variant="subtitle1" component="div">
|
||||
Selected: {selectedValue}
|
||||
</Typography>
|
||||
<br />
|
||||
<Button variant="outlined" onClick={handleClickOpen}>
|
||||
Open simple dialog
|
||||
</Button>
|
||||
<SimpleDialog
|
||||
selectedValue={selectedValue}
|
||||
open={open}
|
||||
onClose={handleClose}
|
||||
/>
|
||||
</div>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user