Skip to content

Commit

Permalink
[Masonry] Set width to 100%
Browse files Browse the repository at this point in the history
  • Loading branch information
hbjORbj committed Oct 20, 2021
1 parent cd67243 commit 9341378
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
1 change: 1 addition & 0 deletions packages/mui-lab/src/Masonry/Masonry.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const validatePropValues = (base, prop) => {

export const getStyle = ({ ownerState, theme }) => {
let styles = {
width: '100%',
display: 'flex',
flexFlow: 'column wrap',
alignContent: 'space-between',
Expand Down
19 changes: 8 additions & 11 deletions packages/mui-lab/src/Masonry/Masonry.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,32 +31,25 @@ describe('<Masonry />', () => {

describe('render', () => {
it('should render with correct default styles', function test() {
if (/jsdom/.test(window.navigator.userAgent)) {
this.skip();
}
const columns = 4;
const spacing = 1;
const { getByTestId } = render(
<Masonry data-testid="container" sx={{ width: 500 }}>
<div data-testid="child" style={{ height: 100 }} />
<div style={{ height: 50 }} />
<div style={{ height: 50 }} />
<div style={{ height: 50 }} />
<Masonry data-testid="container">
<div data-testid="child" />
</Masonry>,
);
const columnHeight = 100 + parseToNumber(theme.spacing(spacing));
expect(getByTestId('container')).toHaveComputedStyle({
width: '100%',
display: 'flex',
flexFlow: 'column wrap',
alignContent: 'space-between',
boxSizing: 'border-box',
margin: `${-(parseToNumber(theme.spacing(spacing)) / 2)}px`,
height: `${columnHeight + parseToNumber(theme.spacing(spacing))}px`,
});
expect(getByTestId('child')).toHaveComputedStyle({
boxSizing: 'border-box',
margin: `${parseToNumber(theme.spacing(spacing)) / 2}px`,
width: `calc(${(100 / columns).toFixed(2)}% - ${theme.spacing(spacing)}px)`,
width: `calc(${(100 / columns).toFixed(2)}% - ${theme.spacing(spacing)})`,
});
});
});
Expand All @@ -75,6 +68,7 @@ describe('<Masonry />', () => {
theme,
}),
).to.deep.equal({
width: '100%',
display: 'flex',
flexFlow: 'column wrap',
alignContent: 'space-between',
Expand Down Expand Up @@ -102,6 +96,7 @@ describe('<Masonry />', () => {
theme,
}),
).to.deep.equal({
width: '100%',
display: 'flex',
flexFlow: 'column wrap',
alignContent: 'space-between',
Expand Down Expand Up @@ -150,6 +145,7 @@ describe('<Masonry />', () => {
theme,
}),
).to.deep.equal({
width: '100%',
display: 'flex',
flexFlow: 'column wrap',
alignContent: 'space-between',
Expand Down Expand Up @@ -195,6 +191,7 @@ describe('<Masonry />', () => {
theme,
}),
).to.deep.equal({
width: '100%',
display: 'flex',
flexFlow: 'column wrap',
alignContent: 'space-between',
Expand Down

0 comments on commit 9341378

Please sign in to comment.