-
-
Notifications
You must be signed in to change notification settings - Fork 32.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[docs] Restore utility component docs from MUI Base to Material UI (#…
- Loading branch information
1 parent
94f35f3
commit a6e959d
Showing
8 changed files
with
234 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import * as React from 'react'; | ||
import Portal from '@mui/material/Portal'; | ||
import { Box } from '@mui/system'; | ||
|
||
export default function SimplePortal() { | ||
const [show, setShow] = React.useState(false); | ||
const container = React.useRef(null); | ||
|
||
const handleClick = () => { | ||
setShow(!show); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<button type="button" onClick={handleClick}> | ||
{show ? 'Unmount children' : 'Mount children'} | ||
</button> | ||
<Box sx={{ p: 1, my: 1, border: '1px solid' }}> | ||
It looks like I will render here. | ||
{show ? ( | ||
<Portal container={() => container.current}> | ||
<span>But I actually render here!</span> | ||
</Portal> | ||
) : null} | ||
</Box> | ||
<Box sx={{ p: 1, my: 1, border: '1px solid' }} ref={container} /> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import * as React from 'react'; | ||
import Portal from '@mui/material/Portal'; | ||
import { Box } from '@mui/system'; | ||
|
||
export default function SimplePortal() { | ||
const [show, setShow] = React.useState(false); | ||
const container = React.useRef(null); | ||
|
||
const handleClick = () => { | ||
setShow(!show); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<button type="button" onClick={handleClick}> | ||
{show ? 'Unmount children' : 'Mount children'} | ||
</button> | ||
<Box sx={{ p: 1, my: 1, border: '1px solid' }}> | ||
It looks like I will render here. | ||
{show ? ( | ||
<Portal container={() => container.current!}> | ||
<span>But I actually render here!</span> | ||
</Portal> | ||
) : null} | ||
</Box> | ||
<Box sx={{ p: 1, my: 1, border: '1px solid' }} ref={container} /> | ||
</div> | ||
); | ||
} |
12 changes: 12 additions & 0 deletions
12
docs/data/material/components/portal/SimplePortal.tsx.preview
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<button type="button" onClick={handleClick}> | ||
{show ? 'Unmount children' : 'Mount children'} | ||
</button> | ||
<Box sx={{ p: 1, my: 1, border: '1px solid' }}> | ||
It looks like I will render here. | ||
{show ? ( | ||
<Portal container={() => container.current!}> | ||
<span>But I actually render here!</span> | ||
</Portal> | ||
) : null} | ||
</Box> | ||
<Box sx={{ p: 1, my: 1, border: '1px solid' }} ref={container} /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters