forked from mui/material-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Masonry] Observe every masonry child to trigger computation when nee…
…ded (mui#29896)
- Loading branch information
1 parent
ea1aeaf
commit d094172
Showing
6 changed files
with
144 additions
and
30 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
docs/src/pages/components/masonry/MasonryWithVariableHeightItems.js
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,39 @@ | ||
import ExpandMoreIcon from '@mui/icons-material/ExpandMore'; | ||
import Masonry from '@mui/lab/Masonry'; | ||
import { | ||
Accordion, | ||
AccordionDetails, | ||
AccordionSummary, | ||
Typography, | ||
} from '@mui/material'; | ||
import Box from '@mui/material/Box'; | ||
import Paper from '@mui/material/Paper'; | ||
import { styled } from '@mui/material/styles'; | ||
import * as React from 'react'; | ||
|
||
const heights = [150, 30, 90, 70, 90, 100, 150, 30, 50, 80]; | ||
|
||
const Item = styled(Paper)(({ theme }) => ({ | ||
...theme.typography.body2, | ||
color: theme.palette.text.secondary, | ||
border: '1px solid black', | ||
})); | ||
|
||
export default function MasonryWithVariableHeightItems() { | ||
return ( | ||
<Box sx={{ width: 500, minHeight: 377 }}> | ||
<Masonry columns={3} spacing={1}> | ||
{heights.map((height, index) => ( | ||
<Item key={index}> | ||
<Accordion sx={{ minHeight: height }}> | ||
<AccordionSummary expandIcon={<ExpandMoreIcon />}> | ||
<Typography>Accordion {index + 1}</Typography> | ||
</AccordionSummary> | ||
<AccordionDetails>Contents</AccordionDetails> | ||
</Accordion> | ||
</Item> | ||
))} | ||
</Masonry> | ||
</Box> | ||
); | ||
} |
39 changes: 39 additions & 0 deletions
39
docs/src/pages/components/masonry/MasonryWithVariableHeightItems.tsx
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,39 @@ | ||
import ExpandMoreIcon from '@mui/icons-material/ExpandMore'; | ||
import Masonry from '@mui/lab/Masonry'; | ||
import { | ||
Accordion, | ||
AccordionDetails, | ||
AccordionSummary, | ||
Typography, | ||
} from '@mui/material'; | ||
import Box from '@mui/material/Box'; | ||
import Paper from '@mui/material/Paper'; | ||
import { styled } from '@mui/material/styles'; | ||
import * as React from 'react'; | ||
|
||
const heights = [150, 30, 90, 70, 90, 100, 150, 30, 50, 80]; | ||
|
||
const Item = styled(Paper)(({ theme }) => ({ | ||
...theme.typography.body2, | ||
color: theme.palette.text.secondary, | ||
border: '1px solid black', | ||
})); | ||
|
||
export default function MasonryWithVariableHeightItems() { | ||
return ( | ||
<Box sx={{ width: 500, minHeight: 377 }}> | ||
<Masonry columns={3} spacing={1}> | ||
{heights.map((height, index) => ( | ||
<Item key={index}> | ||
<Accordion sx={{ minHeight: height }}> | ||
<AccordionSummary expandIcon={<ExpandMoreIcon />}> | ||
<Typography>Accordion {index + 1}</Typography> | ||
</AccordionSummary> | ||
<AccordionDetails>Contents</AccordionDetails> | ||
</Accordion> | ||
</Item> | ||
))} | ||
</Masonry> | ||
</Box> | ||
); | ||
} |
12 changes: 12 additions & 0 deletions
12
docs/src/pages/components/masonry/MasonryWithVariableHeightItems.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 @@ | ||
<Masonry columns={3} spacing={1}> | ||
{heights.map((height, index) => ( | ||
<Item key={index}> | ||
<Accordion sx={{ minHeight: height }}> | ||
<AccordionSummary expandIcon={<ExpandMoreIcon />}> | ||
<Typography>Accordion {index + 1}</Typography> | ||
</AccordionSummary> | ||
<AccordionDetails>Contents</AccordionDetails> | ||
</Accordion> | ||
</Item> | ||
))} | ||
</Masonry> |
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