Files
CHIEFSOFT\ameye 5f95d857d4 first commit
2023-10-14 22:02:57 -04:00

112 lines
2.2 KiB
JavaScript

import React from "react";
import Card from "@mui/material/Card";
import { Typography } from "@mui/material";
import Button from '@mui/material/Button';
import Snackbar from '@mui/material/Snackbar';
export default function PositionedSnackbars() {
const [state, setState] = React.useState({
open: false,
vertical: 'top',
horizontal: 'center',
});
const { vertical, horizontal, open } = state;
const handleClick = (newState) => () => {
setState({ open: true, ...newState });
};
const handleClose = () => {
setState({ ...state, open: false });
};
const buttons = (
<React.Fragment>
<Button
onClick={handleClick({
vertical: 'top',
horizontal: 'center',
})}
>
Top-Center
</Button>
<Button
onClick={handleClick({
vertical: 'top',
horizontal: 'right',
})}
>
Top-Right
</Button>
<Button
onClick={handleClick({
vertical: 'bottom',
horizontal: 'right',
})}
>
Bottom-Right
</Button>
<Button
onClick={handleClick({
vertical: 'bottom',
horizontal: 'center',
})}
>
Bottom-Center
</Button>
<Button
onClick={handleClick({
vertical: 'bottom',
horizontal: 'left',
})}
>
Bottom-Left
</Button>
<Button
onClick={handleClick({
vertical: 'top',
horizontal: 'left',
})}
>
Top-Left
</Button>
</React.Fragment>
);
return (
<>
<Card
sx={{
boxShadow: "none",
borderRadius: "10px",
p: "25px",
mb: "15px",
}}
>
<Typography
as="h3"
sx={{
fontSize: 18,
fontWeight: 500,
mb: '10px'
}}
>
Positioned Snackbars
</Typography>
<div>
{buttons}
<Snackbar
anchorOrigin={{ vertical, horizontal }}
open={open}
onClose={handleClose}
message="I love snacks"
key={vertical + horizontal}
/>
</div>
</Card>
</>
);
}