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

[ImageList] Refactor using CSS grid & React context #22395

Merged
merged 40 commits into from
Sep 12, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
c136a7e
ImageList] use CSS grid
mbrookes Aug 28, 2020
ea3a542
Use context
mbrookes Aug 28, 2020
aa16e1e
ImageListItem - No fragement child
mbrookes Aug 29, 2020
54702ea
No IE11
mbrookes Aug 29, 2020
54cd5c4
grid -> image
mbrookes Aug 29, 2020
436e0a8
remove legacy tests
mbrookes Aug 29, 2020
db7ff55
proptypes
mbrookes Aug 29, 2020
d1dadd0
even more tile -> item
mbrookes Aug 29, 2020
3a2ebd0
lint & prettier
mbrookes Aug 29, 2020
86b9cfd
docs:api
mbrookes Aug 29, 2020
facb776
Update demos
mbrookes Aug 30, 2020
057ee9f
Woven image list demo
mbrookes Aug 30, 2020
408e94b
masonry image list
mbrookes Aug 30, 2020
fa7e8bf
Clean up demos
mbrookes Aug 30, 2020
f3e9644
docs:api
mbrookes Aug 30, 2020
1dfb130
lint
mbrookes Aug 30, 2020
e9e594d
Fix woven
mbrookes Aug 30, 2020
532677b
refine image chice
mbrookes Aug 30, 2020
fdf1364
Image order
mbrookes Aug 30, 2020
0f77775
Title bar below image
mbrookes Sep 2, 2020
8249046
tests
mbrookes Sep 5, 2020
76bb54d
Update IE11 error message
mbrookes Sep 6, 2020
e3d4507
Olivier's review
mbrookes Sep 6, 2020
8561fc1
spacing -> gap
mbrookes Sep 7, 2020
ac99c3d
Apply suggestions from code review
mbrookes Sep 7, 2020
04cebaf
Use imagesplash for non-"peer" item data
mbrookes Sep 7, 2020
3f26171
Use unsplash for "peer" images
mbrookes Sep 7, 2020
a12ccfa
image order
mbrookes Sep 7, 2020
69b75c9
lint, remove dead images
mbrookes Sep 8, 2020
f01de28
skip jsdom in tests for computed styles
mbrookes Sep 8, 2020
31fbba6
don't hide edit button
mbrookes Sep 8, 2020
889b3e4
skip?
mbrookes Sep 8, 2020
93938dd
Update packages/material-ui/src/ImageList/ImageList.d.ts
mbrookes Sep 8, 2020
ade0ef8
remove contentious tests
mbrookes Sep 8, 2020
622741e
Merge branch 'imagelist-use-grid' of https://github.com/mbrookes/mate…
mbrookes Sep 9, 2020
f6aa905
Use padding for title alignment
mbrookes Sep 9, 2020
5dc4251
remove redundant tests
mbrookes Sep 9, 2020
8a3581c
revert px/pixels
mbrookes Sep 10, 2020
c37046a
Update migration guide
mbrookes Sep 11, 2020
adb9d62
prettier
mbrookes Sep 11, 2020
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
2 changes: 0 additions & 2 deletions docs/pages/api-docs/image-list-item-bar.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,9 @@ Any other props supplied will be provided to the root element (native element).
| Rule name | Global class | Description |
|:-----|:-------------|:------------|
| <span class="prop-name">root</span> | <span class="prop-name">.MuiImageListItemBar-root</span> | Styles applied to the root element.
| <span class="prop-name">rootSubtitle</span> | <span class="prop-name">.MuiImageListItemBar-rootSubtitle</span> | Styles applied to the root element if a `subtitle` is provided.
| <span class="prop-name">positionBottom</span> | <span class="prop-name">.MuiImageListItemBar-positionBottom</span> | Styles applied to the root element if `position="bottom"`.
| <span class="prop-name">positionTop</span> | <span class="prop-name">.MuiImageListItemBar-positionTop</span> | Styles applied to the root element if `position="top"`.
| <span class="prop-name">positionBelow</span> | <span class="prop-name">.MuiImageListItemBar-positionBelow</span> | Styles applied to the root element if `position="below"`.
| <span class="prop-name">positionBelowSubtitle</span> | <span class="prop-name">.MuiImageListItemBar-positionBelowSubtitle</span> | Styles applied to the root element if `position="below"` and a `subtitle` is provided.
| <span class="prop-name">titleWrap</span> | <span class="prop-name">.MuiImageListItemBar-titleWrap</span> | Styles applied to the title and subtitle container element.
| <span class="prop-name">titleWrapBelow</span> | <span class="prop-name">.MuiImageListItemBar-titleWrapBelow</span> | Styles applied to the title and subtitle container element if `position="below"`.
| <span class="prop-name">titleWrapActionPosLeft</span> | <span class="prop-name">.MuiImageListItemBar-titleWrapActionPosLeft</span> | Styles applied to the container element if `actionPosition="left"`.
Expand Down
4 changes: 2 additions & 2 deletions docs/pages/api-docs/image-list.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ The `MuiImageList` name can be used for providing [default props](/customization
| <span class="prop-name">classes</span> | <span class="prop-type">object</span> | | Override or extend the styles applied to the component. See [CSS API](#css) below for more details. |
| <span class="prop-name">cols</span> | <span class="prop-type">number</span> | <span class="prop-default">2</span> | Number of columns. |
| <span class="prop-name">component</span> | <span class="prop-type">elementType</span> | <span class="prop-default">'ul'</span> | The component used for the root node. Either a string to use a HTML element or a component. |
| <span class="prop-name">gap</span> | <span class="prop-type">number</span> | <span class="prop-default">4</span> | The gap between items in px. |
| <span class="prop-name">rowHeight</span> | <span class="prop-type">'auto'<br>&#124;&nbsp;number</span> | <span class="prop-default">'auto'</span> | The height of one row in px. |
| <span class="prop-name">gap</span> | <span class="prop-type">number</span> | <span class="prop-default">4</span> | The gap between items in pixels. |
| <span class="prop-name">rowHeight</span> | <span class="prop-type">'auto'<br>&#124;&nbsp;number</span> | <span class="prop-default">'auto'</span> | The height of one row in pixels. |
| <span class="prop-name">variant</span> | <span class="prop-type">'masonry'<br>&#124;&nbsp;'quilted'<br>&#124;&nbsp;'standard'<br>&#124;&nbsp;'woven'<br>&#124;&nbsp;string</span> | <span class="prop-default">'standard'</span> | The variant to use. |

The `ref` is forwarded to the root element.
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/image-list/TitlebarImageList.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default function TitlebarImageList() {
/>
<ImageListItemBar
title={item.title}
subtitle={<span>by: {item.author}</span>}
subtitle={item.author}
actionIcon={
<IconButton
aria-label={`info about ${item.title}`}
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/image-list/TitlebarImageList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default function TitlebarImageList() {
/>
<ImageListItemBar
title={item.title}
subtitle={<span>by: {item.author}</span>}
subtitle={item.author}
actionIcon={
<IconButton
aria-label={`info about ${item.title}`}
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/components/image-list/image-list.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Image lists represent a collection of items in a repeated pattern. They help imp

## Standard image list

Standard image lists are best for items of equal importance. They have a uniform container size, ratio, and padding.
Standard image lists are best for items of equal importance. They have a uniform container size, ratio, and spacing.

{{"demo": "pages/components/image-list/StandardImageList.js"}}

Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/ImageList/ImageList.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export interface ImageListTypeMap<P = {}, D extends React.ElementType = 'ul'> {
*/
gap?: number;
/**
* The height of one row in px.
* The height of one row in pixels.
* @default 'auto'
*/
rowHeight?: number | 'auto';
Expand Down
4 changes: 2 additions & 2 deletions packages/material-ui/src/ImageList/ImageList.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,12 @@ ImageList.propTypes = {
*/
component: PropTypes.elementType,
/**
* The gap between items in px.
* The gap between items in pixels.
mbrookes marked this conversation as resolved.
Show resolved Hide resolved
* @default 4
*/
gap: PropTypes.number,
/**
* The height of one row in px.
* The height of one row in pixels.
* @default 'auto'
*/
rowHeight: PropTypes.oneOfType([PropTypes.oneOf(['auto']), PropTypes.number]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,12 @@ export interface ImageListItemBarProps
classes?: {
/** Styles applied to the root element. */
root?: string;
/** Styles applied to the root element if a `subtitle` is provided. */
rootSubtitle?: string;
/** Styles applied to the root element if `position="bottom"`. */
positionBottom?: string;
/** Styles applied to the root element if `position="top"`. */
positionTop?: string;
/** Styles applied to the root element if `position="below"`. */
positionBelow?: string;
/** Styles applied to the root element if `position="below"` and a `subtitle` is provided. */
positionBelowSubtitle?: string;
/** Styles applied to the title and subtitle container element. */
titleWrap?: string;
/** Styles applied to the title and subtitle container element if `position="below"`. */
Expand Down
22 changes: 4 additions & 18 deletions packages/material-ui/src/ImageListItemBar/ImageListItemBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,11 @@ export const styles = (theme) => ({
position: 'absolute',
left: 0,
right: 0,
height: 48,
background: 'rgba(0, 0, 0, 0.5)',
display: 'flex',
alignItems: 'center',
fontFamily: theme.typography.fontFamily,
},
/* Styles applied to the root element if a `subtitle` is provided. */
rootSubtitle: {
height: 68,
},
/* Styles applied to the root element if `position="bottom"`. */
positionBottom: {
bottom: 0,
Expand All @@ -29,36 +24,29 @@ export const styles = (theme) => ({
},
/* Styles applied to the root element if `position="below"`. */
positionBelow: {
height: 40,
position: 'relative',
background: 'transparent',
alignItems: 'normal',
},
/* Styles applied to the root element if `position="below"` and a `subtitle` is provided. */
positionBelowSubtitle: {
height: 60,
},
/* Styles applied to the title and subtitle container element. */
titleWrap: {
flexGrow: 1,
marginLeft: 16,
marginRight: 16,
padding: '12px 16px',
color: theme.palette.common.white,
overflow: 'hidden',
},
/* Styles applied to the title and subtitle container element if `position="below"`. */
titleWrapBelow: {
marginTop: 4,
marginLeft: 0,
padding: '6px 0 12px',
color: 'inherit',
},
/* Styles applied to the container element if `actionPosition="left"`. */
titleWrapActionPosLeft: {
marginLeft: 0,
paddingLeft: 0,
},
/* Styles applied to the container element if `actionPosition="right"`. */
titleWrapActionPosRight: {
marginRight: 0,
paddingRight: 0,
},
/* Styles applied to the title container element. */
title: {
Expand Down Expand Up @@ -103,9 +91,7 @@ const ImageListItemBar = React.forwardRef(function ImageListItemBar(props, ref)
className={clsx(
classes.root,
{
[classes.rootSubtitle]: subtitle,
[classes.positionBelow]: position === 'below',
[classes.positionBelowSubtitle]: position === 'below' && subtitle,
[classes.positionBottom]: position === 'bottom',
[classes.positionTop]: position === 'top',
},
Expand Down
15 changes: 0 additions & 15 deletions packages/material-ui/src/ImageListItemBar/ImageListItemBar.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,20 +107,5 @@ describe('<ImageListItemBar />', () => {
expect(container.querySelector('div')).to.have.class(classes.root);
expect(container.querySelector('div')).to.have.class(classes.positionBottom);
});

it('should render a child div with the titleWrap class by default', () => {
const { container } = render(<ImageListItemBar title="text" />);

expect(container.firstChild.querySelector('div')).to.have.class(classes.titleWrap);
});

it('should render a child div with the titleWrapActionPosRight class', () => {
const { container } = render(<ImageListItemBar title="text" actionIcon={<div />} />);

expect(container.firstChild.querySelector('div')).to.have.class(classes.titleWrap);
expect(container.firstChild.querySelector('div')).to.have.class(
classes.titleWrapActionPosRight,
);
});
});
});