Skip to content

Commit

Permalink
[List] Update to match the specification
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviertassinari committed Apr 13, 2019
1 parent 1e86a1c commit bc5b77d
Show file tree
Hide file tree
Showing 28 changed files with 250 additions and 242 deletions.
25 changes: 16 additions & 9 deletions docs/src/pages/demos/dividers/InsetDividers.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { withStyles } from '@material-ui/core/styles';
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import ListItemText from '@material-ui/core/ListItemText';
import ListItemAvatar from '@material-ui/core/ListItemAvatar';
import Avatar from '@material-ui/core/Avatar';
import ImageIcon from '@material-ui/icons/Image';
import WorkIcon from '@material-ui/icons/Work';
Expand All @@ -23,25 +24,31 @@ function InsetDividers(props) {
return (
<List className={classes.root}>
<ListItem>
<Avatar>
<ImageIcon />
</Avatar>
<ListItemAvatar>
<Avatar>
<ImageIcon />
</Avatar>
</ListItemAvatar>
<ListItemText primary="Photos" secondary="Jan 9, 2014" />
</ListItem>
<li>
<Divider variant="inset" />
</li>
<ListItem>
<Avatar>
<WorkIcon />
</Avatar>
<ListItemAvatar>
<Avatar>
<WorkIcon />
</Avatar>
</ListItemAvatar>
<ListItemText primary="Work" secondary="Jan 7, 2014" />
</ListItem>
<Divider variant="inset" component="li" />
<ListItem>
<Avatar>
<BeachAccessIcon />
</Avatar>
<ListItemAvatar>
<Avatar>
<BeachAccessIcon />
</Avatar>
</ListItemAvatar>
<ListItemText primary="Vacation" secondary="July 20, 2014" />
</ListItem>
</List>
Expand Down
25 changes: 16 additions & 9 deletions docs/src/pages/demos/dividers/InsetDividers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { withStyles, Theme, WithStyles, WithTheme, createStyles } from '@materia
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import ListItemText from '@material-ui/core/ListItemText';
import ListItemAvatar from '@material-ui/core/ListItemAvatar';
import Avatar from '@material-ui/core/Avatar';
import ImageIcon from '@material-ui/icons/Image';
import WorkIcon from '@material-ui/icons/Work';
Expand All @@ -26,25 +27,31 @@ function InsetDividers(props: Props) {
return (
<List className={classes.root}>
<ListItem>
<Avatar>
<ImageIcon />
</Avatar>
<ListItemAvatar>
<Avatar>
<ImageIcon />
</Avatar>
</ListItemAvatar>
<ListItemText primary="Photos" secondary="Jan 9, 2014" />
</ListItem>
<li>
<Divider variant="inset" />
</li>
<ListItem>
<Avatar>
<WorkIcon />
</Avatar>
<ListItemAvatar>
<Avatar>
<WorkIcon />
</Avatar>
</ListItemAvatar>
<ListItemText primary="Work" secondary="Jan 7, 2014" />
</ListItem>
<Divider variant="inset" component="li" />
<ListItem>
<Avatar>
<BeachAccessIcon />
</Avatar>
<ListItemAvatar>
<Avatar>
<BeachAccessIcon />
</Avatar>
</ListItemAvatar>
<ListItemText primary="Vacation" secondary="July 20, 2014" />
</ListItem>
</List>
Expand Down
9 changes: 6 additions & 3 deletions docs/src/pages/demos/dividers/SubheaderDividers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
import { withStyles } from '@material-ui/core/styles';
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import ListItemAvatar from '@material-ui/core/ListItemAvatar';
import ListItemText from '@material-ui/core/ListItemText';
import Avatar from '@material-ui/core/Avatar';
import BeachAccessIcon from '@material-ui/icons/BeachAccess';
Expand Down Expand Up @@ -56,9 +57,11 @@ function SubheaderDividers(props) {
</Typography>
</li>
<ListItem>
<Avatar>
<BeachAccessIcon />
</Avatar>
<ListItemAvatar>
<Avatar>
<BeachAccessIcon />
</Avatar>
</ListItemAvatar>
<ListItemText primary="Vacation" secondary="July 20, 2014" />
</ListItem>
</List>
Expand Down
9 changes: 6 additions & 3 deletions docs/src/pages/demos/dividers/SubheaderDividers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
import { withStyles, WithStyles, WithTheme, Theme } from '@material-ui/core/styles';
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import ListItemAvatar from '@material-ui/core/ListItemAvatar';
import ListItemText from '@material-ui/core/ListItemText';
import Avatar from '@material-ui/core/Avatar';
import BeachAccessIcon from '@material-ui/icons/BeachAccess';
Expand Down Expand Up @@ -58,9 +59,11 @@ function SubheaderDividers(props: Props) {
</Typography>
</li>
<ListItem>
<Avatar>
<BeachAccessIcon />
</Avatar>
<ListItemAvatar>
<Avatar>
<BeachAccessIcon />
</Avatar>
</ListItemAvatar>
<ListItemText primary="Vacation" secondary="July 20, 2014" />
</ListItem>
</List>
Expand Down
7 changes: 7 additions & 0 deletions docs/src/pages/demos/lists/AlignItemsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
import { withStyles } from '@material-ui/core/styles';
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import Divider from '@material-ui/core/Divider';
import ListItemText from '@material-ui/core/ListItemText';
import ListItemAvatar from '@material-ui/core/ListItemAvatar';
import Avatar from '@material-ui/core/Avatar';
Expand Down Expand Up @@ -44,6 +45,9 @@ function AlignItemsList(props) {
}
/>
</ListItem>
<li>
<Divider variant="inset" />
</li>
<ListItem alignItems="flex-start">
<ListItemAvatar>
<Avatar alt="Remy Sharp" src="/static/images/avatar/2.jpg" />
Expand All @@ -65,6 +69,9 @@ function AlignItemsList(props) {
}
/>
</ListItem>
<li>
<Divider variant="inset" />
</li>
<ListItem alignItems="flex-start">
<ListItemAvatar>
<Avatar alt="Remy Sharp" src="/static/images/avatar/3.jpg" />
Expand Down
12 changes: 10 additions & 2 deletions docs/src/pages/demos/lists/CheckboxList.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React from 'react';
import { makeStyles } from '@material-ui/core/styles';
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import ListItemIcon from '@material-ui/core/ListItemIcon';
import ListItemSecondaryAction from '@material-ui/core/ListItemSecondaryAction';
import ListItemText from '@material-ui/core/ListItemText';
import Checkbox from '@material-ui/core/Checkbox';
Expand Down Expand Up @@ -37,10 +38,17 @@ function CheckboxList() {
<List className={classes.root}>
{[0, 1, 2, 3].map(value => (
<ListItem key={value} role={undefined} dense button onClick={handleToggle(value)}>
<Checkbox checked={checked.indexOf(value) !== -1} tabIndex={-1} disableRipple />
<ListItemIcon>
<Checkbox
edge="start"
checked={checked.indexOf(value) !== -1}
tabIndex={-1}
disableRipple
/>
</ListItemIcon>
<ListItemText primary={`Line item ${value + 1}`} />
<ListItemSecondaryAction>
<IconButton aria-label="Comments">
<IconButton edge="end" aria-label="Comments">
<CommentIcon />
</IconButton>
</ListItemSecondaryAction>
Expand Down
8 changes: 6 additions & 2 deletions docs/src/pages/demos/lists/CheckboxListSecondary.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,19 @@ function CheckboxListSecondary() {
};

return (
<List dense className={classes.root}>
<List className={classes.root}>
{[0, 1, 2, 3].map(value => (
<ListItem key={value} button>
<ListItemAvatar>
<Avatar alt={`Avatar n°${value + 1}`} src={`/static/images/avatar/${value + 1}.jpg`} />
</ListItemAvatar>
<ListItemText primary={`Line item ${value + 1}`} />
<ListItemSecondaryAction>
<Checkbox onChange={handleToggle(value)} checked={checked.indexOf(value) !== -1} />
<Checkbox
edge="end"
onChange={handleToggle(value)}
checked={checked.indexOf(value) !== -1}
/>
</ListItemSecondaryAction>
</ListItem>
))}
Expand Down
25 changes: 16 additions & 9 deletions docs/src/pages/demos/lists/FolderList.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { withStyles } from '@material-ui/core/styles';
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import ListItemText from '@material-ui/core/ListItemText';
import ListItemAvatar from '@material-ui/core/ListItemAvatar';
import Avatar from '@material-ui/core/Avatar';
import ImageIcon from '@material-ui/icons/Image';
import WorkIcon from '@material-ui/icons/Work';
Expand All @@ -22,21 +23,27 @@ function FolderList(props) {
return (
<List className={classes.root}>
<ListItem>
<Avatar>
<ImageIcon />
</Avatar>
<ListItemAvatar>
<Avatar>
<ImageIcon />
</Avatar>
</ListItemAvatar>
<ListItemText primary="Photos" secondary="Jan 9, 2014" />
</ListItem>
<ListItem>
<Avatar>
<WorkIcon />
</Avatar>
<ListItemAvatar>
<Avatar>
<WorkIcon />
</Avatar>
</ListItemAvatar>
<ListItemText primary="Work" secondary="Jan 7, 2014" />
</ListItem>
<ListItem>
<Avatar>
<BeachAccessIcon />
</Avatar>
<ListItemAvatar>
<Avatar>
<BeachAccessIcon />
</Avatar>
</ListItemAvatar>
<ListItemText primary="Vacation" secondary="July 20, 2014" />
</ListItem>
</List>
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/demos/lists/InsetList.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function InsetList(props) {
<ListItemIcon>
<StarIcon />
</ListItemIcon>
<ListItemText inset primary="Chelsea Otakan" />
<ListItemText primary="Chelsea Otakan" />
</ListItem>
<ListItem button>
<ListItemText inset primary="Eric Hoffman" />
Expand Down
2 changes: 1 addition & 1 deletion docs/src/pages/demos/lists/InteractiveList.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ function InteractiveList() {
secondary={secondary ? 'Secondary text' : null}
/>
<ListItemSecondaryAction>
<IconButton aria-label="Delete">
<IconButton edge="end" aria-label="Delete">
<DeleteIcon />
</IconButton>
</ListItemSecondaryAction>
Expand Down
8 changes: 4 additions & 4 deletions docs/src/pages/demos/lists/NestedList.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,19 +42,19 @@ function NestedList() {
<ListItemIcon>
<SendIcon />
</ListItemIcon>
<ListItemText inset primary="Sent mail" />
<ListItemText primary="Sent mail" />
</ListItem>
<ListItem button>
<ListItemIcon>
<DraftsIcon />
</ListItemIcon>
<ListItemText inset primary="Drafts" />
<ListItemText primary="Drafts" />
</ListItem>
<ListItem button onClick={handleClick}>
<ListItemIcon>
<InboxIcon />
</ListItemIcon>
<ListItemText inset primary="Inbox" />
<ListItemText primary="Inbox" />
{open ? <ExpandLess /> : <ExpandMore />}
</ListItem>
<Collapse in={open} timeout="auto" unmountOnExit>
Expand All @@ -63,7 +63,7 @@ function NestedList() {
<ListItemIcon>
<StarBorder />
</ListItemIcon>
<ListItemText inset primary="Starred" />
<ListItemText primary="Starred" />
</ListItem>
</List>
</Collapse>
Expand Down
7 changes: 6 additions & 1 deletion docs/src/pages/demos/lists/SwitchListSecondary.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ function SwitchListSecondary() {
</ListItemIcon>
<ListItemText primary="Wi-Fi" />
<ListItemSecondaryAction>
<Switch onChange={handleToggle('wifi')} checked={checked.indexOf('wifi') !== -1} />
<Switch
edge="end"
onChange={handleToggle('wifi')}
checked={checked.indexOf('wifi') !== -1}
/>
</ListItemSecondaryAction>
</ListItem>
<ListItem>
Expand All @@ -53,6 +57,7 @@ function SwitchListSecondary() {
<ListItemText primary="Bluetooth" />
<ListItemSecondaryAction>
<Switch
edge="end"
onChange={handleToggle('bluetooth')}
checked={checked.indexOf('bluetooth') !== -1}
/>
Expand Down
1 change: 1 addition & 0 deletions packages/material-ui/src/IconButton/IconButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ IconButton.propTypes = {
IconButton.defaultProps = {
color: 'default',
disabled: false,
edge: false,
size: 'medium',
};

Expand Down
9 changes: 3 additions & 6 deletions packages/material-ui/src/List/List.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,8 @@ export const styles = {
paddingTop: 8,
paddingBottom: 8,
},
/* Styles applied to the root element if `dense={true}` & `disablePadding={false}`. */
dense: {
paddingTop: 4,
paddingBottom: 4,
},
/* Styles applied to the root element if dense */
dense: {},
/* Styles applied to the root element if a `subheader` is provided. */
subheader: {
paddingTop: 0,
Expand All @@ -47,7 +44,7 @@ const List = React.forwardRef(function List(props, ref) {
className={clsx(
classes.root,
{
[classes.dense]: dense && !disablePadding,
[classes.dense]: dense,
[classes.padding]: !disablePadding,
[classes.subheader]: subheader,
},
Expand Down
Loading

0 comments on commit bc5b77d

Please sign in to comment.