Some checks failed
No response / noResponse (push) Has been cancelled
CI / Continuous releases (push) Has been cancelled
CI / test-dev (macos-latest) (push) Has been cancelled
CI / test-dev (ubuntu-latest) (push) Has been cancelled
CI / test-dev (windows-latest) (push) Has been cancelled
Maintenance / main (push) Has been cancelled
Scorecards supply-chain security / Scorecards analysis (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
65 lines
2.0 KiB
JavaScript
65 lines
2.0 KiB
JavaScript
import * as React from 'react';
|
|
import { Transition } from 'react-transition-group';
|
|
import Button from '@mui/joy/Button';
|
|
import Modal from '@mui/joy/Modal';
|
|
import ModalDialog from '@mui/joy/ModalDialog';
|
|
import DialogTitle from '@mui/joy/DialogTitle';
|
|
import DialogContent from '@mui/joy/DialogContent';
|
|
|
|
export default function FadeModalDialog() {
|
|
const [open, setOpen] = React.useState(false);
|
|
const nodeRef = React.useRef(null);
|
|
|
|
return (
|
|
<React.Fragment>
|
|
<Button variant="outlined" color="neutral" onClick={() => setOpen(true)}>
|
|
Open modal
|
|
</Button>
|
|
<Transition nodeRef={nodeRef} in={open} timeout={400}>
|
|
{(state) => (
|
|
<Modal
|
|
ref={nodeRef}
|
|
keepMounted
|
|
open={!['exited', 'exiting'].includes(state)}
|
|
onClose={() => setOpen(false)}
|
|
slotProps={{
|
|
backdrop: {
|
|
sx: {
|
|
opacity: 0,
|
|
backdropFilter: 'none',
|
|
transition: `opacity 400ms, backdrop-filter 400ms`,
|
|
...{
|
|
entering: { opacity: 1, backdropFilter: 'blur(8px)' },
|
|
entered: { opacity: 1, backdropFilter: 'blur(8px)' },
|
|
}[state],
|
|
},
|
|
},
|
|
}}
|
|
sx={[
|
|
state === 'exited'
|
|
? { visibility: 'hidden' }
|
|
: { visibility: 'visible' },
|
|
]}
|
|
>
|
|
<ModalDialog
|
|
sx={{
|
|
opacity: 0,
|
|
transition: `opacity 300ms`,
|
|
...{
|
|
entering: { opacity: 1 },
|
|
entered: { opacity: 1 },
|
|
}[state],
|
|
}}
|
|
>
|
|
<DialogTitle>Transition modal</DialogTitle>
|
|
<DialogContent>
|
|
Using `react-transition-group` to create a fade animation.
|
|
</DialogContent>
|
|
</ModalDialog>
|
|
</Modal>
|
|
)}
|
|
</Transition>
|
|
</React.Fragment>
|
|
);
|
|
}
|