Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs][base] Move styles to the bottom of demos code for ModalUnstyled #36580

Merged
merged 5 commits into from
Apr 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 27 additions & 27 deletions docs/data/base/components/modal/KeepMountedModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,33 @@ import clsx from 'clsx';
import { styled, Box } from '@mui/system';
import ModalUnstyled from '@mui/base/ModalUnstyled';

export default function KeepMountedModal() {
const [open, setOpen] = React.useState(false);
const handleOpen = () => setOpen(true);
const handleClose = () => setOpen(false);

return (
<div>
<button type="button" onClick={handleOpen}>
Open modal
</button>
<Modal
aria-labelledby="keep-mounted-modal-title"
aria-describedby="keep-mounted-modal-description"
open={open}
onClose={handleClose}
slots={{ backdrop: Backdrop }}
keepMounted
>
<Box sx={style}>
<h2 id="keep-mounted-modal-title">Text in a modal</h2>
<p id="keep-mounted-modal-description">Aliquid amet deserunt earum!</p>
</Box>
</Modal>
</div>
);
}

const BackdropUnstyled = React.forwardRef((props, ref) => {
const { open, className, ...other } = props;
return (
Expand Down Expand Up @@ -52,30 +79,3 @@ const style = (theme) => ({
border: '2px solid currentColor',
padding: '16px 32px 24px 32px',
});

export default function ModalUnstyledDemo() {
const [open, setOpen] = React.useState(false);
const handleOpen = () => setOpen(true);
const handleClose = () => setOpen(false);

return (
<div>
<button type="button" onClick={handleOpen}>
Open modal
</button>
<Modal
aria-labelledby="keep-mounted-modal-title"
aria-describedby="keep-mounted-modal-description"
open={open}
onClose={handleClose}
slots={{ backdrop: Backdrop }}
keepMounted
>
<Box sx={style}>
<h2 id="keep-mounted-modal-title">Text in a modal</h2>
<p id="keep-mounted-modal-description">Aliquid amet deserunt earum!</p>
</Box>
</Modal>
</div>
);
}
54 changes: 27 additions & 27 deletions docs/data/base/components/modal/KeepMountedModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,33 @@ import clsx from 'clsx';
import { styled, Box, Theme } from '@mui/system';
import ModalUnstyled from '@mui/base/ModalUnstyled';

export default function KeepMountedModal() {
const [open, setOpen] = React.useState(false);
const handleOpen = () => setOpen(true);
const handleClose = () => setOpen(false);

return (
<div>
<button type="button" onClick={handleOpen}>
Open modal
</button>
<Modal
aria-labelledby="keep-mounted-modal-title"
aria-describedby="keep-mounted-modal-description"
open={open}
onClose={handleClose}
slots={{ backdrop: Backdrop }}
keepMounted
>
<Box sx={style}>
<h2 id="keep-mounted-modal-title">Text in a modal</h2>
<p id="keep-mounted-modal-description">Aliquid amet deserunt earum!</p>
</Box>
</Modal>
</div>
);
}

const BackdropUnstyled = React.forwardRef<
HTMLDivElement,
{ open?: boolean; className: string }
Expand Down Expand Up @@ -49,30 +76,3 @@ const style = (theme: Theme) => ({
border: '2px solid currentColor',
padding: '16px 32px 24px 32px',
});

export default function ModalUnstyledDemo() {
const [open, setOpen] = React.useState(false);
const handleOpen = () => setOpen(true);
const handleClose = () => setOpen(false);

return (
<div>
<button type="button" onClick={handleOpen}>
Open modal
</button>
<Modal
aria-labelledby="keep-mounted-modal-title"
aria-describedby="keep-mounted-modal-description"
open={open}
onClose={handleClose}
slots={{ backdrop: Backdrop }}
keepMounted
>
<Box sx={style}>
<h2 id="keep-mounted-modal-title">Text in a modal</h2>
<p id="keep-mounted-modal-description">Aliquid amet deserunt earum!</p>
</Box>
</Modal>
</div>
);
}
52 changes: 26 additions & 26 deletions docs/data/base/components/modal/ModalUnstyled.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,32 @@ import clsx from 'clsx';
import { styled, Box } from '@mui/system';
import ModalUnstyled from '@mui/base/ModalUnstyled';

export default function ModalUnstyledDemo() {
const [open, setOpen] = React.useState(false);
const handleOpen = () => setOpen(true);
const handleClose = () => setOpen(false);

return (
<div>
<button type="button" onClick={handleOpen}>
Open modal
</button>
<Modal
aria-labelledby="unstyled-modal-title"
aria-describedby="unstyled-modal-description"
open={open}
onClose={handleClose}
slots={{ backdrop: Backdrop }}
>
<Box sx={style}>
<h2 id="unstyled-modal-title">Text in a modal</h2>
<p id="unstyled-modal-description">Aliquid amet deserunt earum!</p>
</Box>
</Modal>
</div>
);
}

const BackdropUnstyled = React.forwardRef((props, ref) => {
const { open, className, ...other } = props;
return (
Expand Down Expand Up @@ -49,29 +75,3 @@ const style = (theme) => ({
border: '2px solid currentColor',
padding: '16px 32px 24px 32px',
});

export default function ModalUnstyledDemo() {
const [open, setOpen] = React.useState(false);
const handleOpen = () => setOpen(true);
const handleClose = () => setOpen(false);

return (
<div>
<button type="button" onClick={handleOpen}>
Open modal
</button>
<Modal
aria-labelledby="unstyled-modal-title"
aria-describedby="unstyled-modal-description"
open={open}
onClose={handleClose}
slots={{ backdrop: Backdrop }}
>
<Box sx={style}>
<h2 id="unstyled-modal-title">Text in a modal</h2>
<p id="unstyled-modal-description">Aliquid amet deserunt earum!</p>
</Box>
</Modal>
</div>
);
}
52 changes: 26 additions & 26 deletions docs/data/base/components/modal/ModalUnstyled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,32 @@ import clsx from 'clsx';
import { styled, Box, Theme } from '@mui/system';
import ModalUnstyled from '@mui/base/ModalUnstyled';

export default function ModalUnstyledDemo() {
const [open, setOpen] = React.useState(false);
const handleOpen = () => setOpen(true);
const handleClose = () => setOpen(false);

return (
<div>
<button type="button" onClick={handleOpen}>
Open modal
</button>
<Modal
aria-labelledby="unstyled-modal-title"
aria-describedby="unstyled-modal-description"
open={open}
onClose={handleClose}
slots={{ backdrop: Backdrop }}
>
<Box sx={style}>
<h2 id="unstyled-modal-title">Text in a modal</h2>
<p id="unstyled-modal-description">Aliquid amet deserunt earum!</p>
</Box>
</Modal>
</div>
);
}

const BackdropUnstyled = React.forwardRef<
HTMLDivElement,
{ open?: boolean; className: string }
Expand Down Expand Up @@ -46,29 +72,3 @@ const style = (theme: Theme) => ({
border: '2px solid currentColor',
padding: '16px 32px 24px 32px',
});

export default function ModalUnstyledDemo() {
const [open, setOpen] = React.useState(false);
const handleOpen = () => setOpen(true);
const handleClose = () => setOpen(false);

return (
<div>
<button type="button" onClick={handleOpen}>
Open modal
</button>
<Modal
aria-labelledby="unstyled-modal-title"
aria-describedby="unstyled-modal-description"
open={open}
onClose={handleClose}
slots={{ backdrop: Backdrop }}
>
<Box sx={style}>
<h2 id="unstyled-modal-title">Text in a modal</h2>
<p id="unstyled-modal-description">Aliquid amet deserunt earum!</p>
</Box>
</Modal>
</div>
);
}
124 changes: 62 additions & 62 deletions docs/data/base/components/modal/NestedModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,68 @@ import { styled, Box } from '@mui/system';
import ModalUnstyled from '@mui/base/ModalUnstyled';
import Button from '@mui/base/ButtonUnstyled';

export default function NestedModal() {
const [open, setOpen] = React.useState(false);
const handleOpen = () => {
setOpen(true);
};
const handleClose = () => {
setOpen(false);
};

return (
<div>
<Button onClick={handleOpen}>Open modal</Button>
<Modal
open={open}
onClose={handleClose}
aria-labelledby="parent-modal-title"
aria-describedby="parent-modal-description"
slots={{ backdrop: Backdrop }}
>
<Box sx={style}>
<h2 id="parent-modal-title">Text in a modal</h2>
<p id="parent-modal-description">
Duis mollis, est non commodo luctus, nisi erat porttitor ligula.
</p>
<ChildModal />
</Box>
</Modal>
</div>
);
}

function ChildModal() {
const [open, setOpen] = React.useState(false);
const handleOpen = () => {
setOpen(true);
};
const handleClose = () => {
setOpen(false);
};

return (
<React.Fragment>
<Button onClick={handleOpen}>Open Child Modal</Button>
<Modal
open={open}
onClose={handleClose}
aria-labelledby="child-modal-title"
aria-describedby="child-modal-description"
slots={{ backdrop: Backdrop }}
>
<Box sx={[style, { width: '200px' }]}>
<h2 id="child-modal-title">Text in a child modal</h2>
<p id="child-modal-description">
Lorem ipsum, dolor sit amet consectetur adipisicing elit.
</p>
<Button onClick={handleClose}>Close Child Modal</Button>
</Box>
</Modal>
</React.Fragment>
);
}

const BackdropUnstyled = React.forwardRef((props, ref) => {
const { open, className, ...other } = props;
return (
Expand Down Expand Up @@ -54,65 +116,3 @@ const style = (theme) => ({
border: '2px solid currentColor',
padding: '16px 32px 24px 32px',
});

function ChildModal() {
const [open, setOpen] = React.useState(false);
const handleOpen = () => {
setOpen(true);
};
const handleClose = () => {
setOpen(false);
};

return (
<React.Fragment>
<Button onClick={handleOpen}>Open Child Modal</Button>
<Modal
open={open}
onClose={handleClose}
aria-labelledby="child-modal-title"
aria-describedby="child-modal-description"
slots={{ backdrop: Backdrop }}
>
<Box sx={[style, { width: '200px' }]}>
<h2 id="child-modal-title">Text in a child modal</h2>
<p id="child-modal-description">
Lorem ipsum, dolor sit amet consectetur adipisicing elit.
</p>
<Button onClick={handleClose}>Close Child Modal</Button>
</Box>
</Modal>
</React.Fragment>
);
}

export default function NestedModal() {
const [open, setOpen] = React.useState(false);
const handleOpen = () => {
setOpen(true);
};
const handleClose = () => {
setOpen(false);
};

return (
<div>
<Button onClick={handleOpen}>Open modal</Button>
<Modal
open={open}
onClose={handleClose}
aria-labelledby="parent-modal-title"
aria-describedby="parent-modal-description"
slots={{ backdrop: Backdrop }}
>
<Box sx={style}>
<h2 id="parent-modal-title">Text in a modal</h2>
<p id="parent-modal-description">
Duis mollis, est non commodo luctus, nisi erat porttitor ligula.
</p>
<ChildModal />
</Box>
</Modal>
</div>
);
}
Loading