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

[List] extract button from ListItem to ListItemButton #26446

Merged
merged 44 commits into from
Jun 7, 2021
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
e4f684d
add wip ListItemButton
siriwatknp May 25, 2021
a0d6928
update lists docs to use ListItemButton
siriwatknp May 25, 2021
41b248b
run proptypes and docs
siriwatknp May 25, 2021
ae4db46
fix typo name
siriwatknp May 25, 2021
f047a2c
minor fix
siriwatknp May 25, 2021
8fb85ca
mark button related prop as deprecated
siriwatknp May 26, 2021
3f46f02
fix description
siriwatknp May 26, 2021
4f385a9
add usage guide to docs
siriwatknp May 26, 2021
83eadf9
add dense note
siriwatknp May 26, 2021
1678d53
Update docs/src/pages/components/lists/lists.md
siriwatknp May 27, 2021
8941802
Merge branch 'next' of https://github.com/mui-org/material-ui into fe…
siriwatknp Jun 3, 2021
43a0f75
add `action` prop and update demos
siriwatknp Jun 3, 2021
aeb3eb3
run proptypes, docs:api, docs:typescript
siriwatknp Jun 3, 2021
4edef7d
add customized demo and theme component props
siriwatknp Jun 3, 2021
4f931d0
update demo
siriwatknp Jun 3, 2021
9c49711
refactor ListItem.d.ts
siriwatknp Jun 3, 2021
6b1e037
add disablePadding prop
siriwatknp Jun 3, 2021
7040bcc
update demo to use disablePadding
siriwatknp Jun 3, 2021
0884aa6
follow disablePadding in List
siriwatknp Jun 3, 2021
36ff3d1
rename `action` to `secondaryAction` due to type conflict with Button…
siriwatknp Jun 3, 2021
fce2d50
minor fix
siriwatknp Jun 3, 2021
7613961
Merge branch 'next' of https://github.com/mui-org/material-ui into fe…
siriwatknp Jun 3, 2021
eb95812
cleanup
siriwatknp Jun 3, 2021
c26f233
Merge branch 'next' of https://github.com/mui-org/material-ui into fe…
siriwatknp Jun 4, 2021
3ee7f40
fix types
siriwatknp Jun 4, 2021
2584c80
fix
siriwatknp Jun 4, 2021
ba68a1b
fix markdown contrast color
siriwatknp Jun 4, 2021
cbf07f6
Update docs/src/pages/components/lists/CustomizedList.tsx
siriwatknp Jun 6, 2021
adda4fe
Update packages/material-ui/src/ListItemButton/listItemButtonClasses.ts
siriwatknp Jun 6, 2021
5cbbb72
Update packages/material-ui/src/ListItemButton/ListItemButton.js
siriwatknp Jun 6, 2021
5c6928f
Update packages/material-ui/src/ListItem/ListItem.js
siriwatknp Jun 6, 2021
b151863
revert the code
siriwatknp Jun 6, 2021
e7cad0a
sort props
siriwatknp Jun 6, 2021
01b7c69
fix li semantic error
siriwatknp Jun 6, 2021
9bf7c49
Merge branch 'feat/list-item-improvement' of github.com:siriwatknp/ma…
siriwatknp Jun 6, 2021
d76b830
run prettier
siriwatknp Jun 6, 2021
002dd5f
run docs:formatted
siriwatknp Jun 6, 2021
c8f8990
run docs:api
siriwatknp Jun 6, 2021
84c3766
fix Inset demo
siriwatknp Jun 6, 2021
0f13f5f
Update packages/material-ui/src/ListItemButton/ListItemButton.js
siriwatknp Jun 7, 2021
6e8431a
Update packages/material-ui/src/ListItemButton/listItemButtonClasses.ts
siriwatknp Jun 7, 2021
4ba8d1c
move role undefined to ListItemButton
siriwatknp Jun 7, 2021
e0bffb4
run docs:api
siriwatknp Jun 7, 2021
0195818
fix as suggested
siriwatknp Jun 7, 2021
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
23 changes: 23 additions & 0 deletions docs/pages/api-docs/list-item-button.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import * as React from 'react';
import ApiPage from 'docs/src/modules/components/ApiPage';
import mapApiPageTranslations from 'docs/src/modules/utils/mapApiPageTranslations';
import jsonPageContent from './list-item-button.json';

export default function Page(props) {
const { descriptions, pageContent } = props;
return <ApiPage descriptions={descriptions} pageContent={pageContent} />;
}

Page.getInitialProps = () => {
const req = require.context(
'docs/translations/api-docs/list-item-button',
false,
/list-item-button.*.json$/,
);
const descriptions = mapApiPageTranslations(req);

return {
descriptions,
pageContent: jsonPageContent,
};
};
45 changes: 45 additions & 0 deletions docs/pages/api-docs/list-item-button.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"props": {
"alignItems": {
"type": { "name": "enum", "description": "'center'<br>&#124;&nbsp;'flex-start'" },
"default": "'center'"
},
"autoFocus": { "type": { "name": "bool" } },
"children": { "type": { "name": "node" } },
"classes": { "type": { "name": "object" } },
"component": { "type": { "name": "elementType" } },
"dense": { "type": { "name": "bool" } },
"disabled": { "type": { "name": "bool" } },
"disableGutters": { "type": { "name": "bool" } },
"divider": { "type": { "name": "bool" } },
"focusVisibleClassName": { "type": { "name": "string" } },
"selected": { "type": { "name": "bool" } },
"sx": { "type": { "name": "object" } }
},
"name": "ListItemButton",
"styles": {
"classes": [
"root",
"focusVisible",
"dense",
"alignItemsFlexStart",
"disabled",
"divider",
"gutters",
"selected"
],
"globalClasses": {
"focusVisible": "Mui-focusVisible",
"disabled": "Mui-disabled",
"selected": "Mui-selected"
},
"name": "MuiListItemButton"
},
"spread": true,
"forwardsRefTo": "HTMLDivElement",
"filename": "/packages/material-ui/src/ListItemButton/ListItemButton.js",
"inheritance": null,
"demos": "<ul><li><a href=\"/components/lists/\">Lists</a></li></ul>",
"styledComponent": true,
"cssComponent": false
}
3 changes: 3 additions & 0 deletions docs/pages/api-docs/list-item.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@
"dense": { "type": { "name": "bool" } },
"disabled": { "type": { "name": "bool" } },
"disableGutters": { "type": { "name": "bool" } },
"disablePadding": { "type": { "name": "bool" } },
"divider": { "type": { "name": "bool" } },
"secondaryAction": { "type": { "name": "node" } },
"selected": { "type": { "name": "bool" } },
"sx": { "type": { "name": "object" } }
},
Expand All @@ -37,6 +39,7 @@
"disabled",
"divider",
"gutters",
"padding",
"button",
"secondaryAction",
"selected"
Expand Down
34 changes: 17 additions & 17 deletions docs/src/pages/components/lists/CheckboxList.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as React from 'react';
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import ListItemButton from '@material-ui/core/ListItemButton';
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';
import IconButton from '@material-ui/core/IconButton';
Expand Down Expand Up @@ -33,25 +33,25 @@ export default function CheckboxList() {
<ListItem
key={value}
role={undefined}
dense
button
onClick={handleToggle(value)}
>
<ListItemIcon>
<Checkbox
edge="start"
checked={checked.indexOf(value) !== -1}
tabIndex={-1}
disableRipple
inputProps={{ 'aria-labelledby': labelId }}
/>
</ListItemIcon>
<ListItemText id={labelId} primary={`Line item ${value + 1}`} />
<ListItemSecondaryAction>
secondaryAction={
<IconButton edge="end" aria-label="comments">
<CommentIcon />
</IconButton>
</ListItemSecondaryAction>
}
disablePadding
>
<ListItemButton onClick={handleToggle(value)} dense>
<ListItemIcon>
<Checkbox
edge="start"
checked={checked.indexOf(value) !== -1}
tabIndex={-1}
disableRipple
inputProps={{ 'aria-labelledby': labelId }}
/>
</ListItemIcon>
<ListItemText id={labelId} primary={`Line item ${value + 1}`} />
</ListItemButton>
</ListItem>
);
})}
Expand Down
34 changes: 17 additions & 17 deletions docs/src/pages/components/lists/CheckboxList.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as React from 'react';
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import ListItemButton from '@material-ui/core/ListItemButton';
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';
import IconButton from '@material-ui/core/IconButton';
Expand Down Expand Up @@ -33,25 +33,25 @@ export default function CheckboxList() {
<ListItem
key={value}
role={undefined}
Copy link
Member

@oliviertassinari oliviertassinari Jun 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dense
button
onClick={handleToggle(value)}
>
<ListItemIcon>
<Checkbox
edge="start"
checked={checked.indexOf(value) !== -1}
tabIndex={-1}
disableRipple
inputProps={{ 'aria-labelledby': labelId }}
/>
</ListItemIcon>
<ListItemText id={labelId} primary={`Line item ${value + 1}`} />
<ListItemSecondaryAction>
secondaryAction={
<IconButton edge="end" aria-label="comments">
<CommentIcon />
</IconButton>
</ListItemSecondaryAction>
}
disablePadding
>
<ListItemButton onClick={handleToggle(value)} dense>
<ListItemIcon>
<Checkbox
edge="start"
checked={checked.indexOf(value) !== -1}
tabIndex={-1}
disableRipple
inputProps={{ 'aria-labelledby': labelId }}
/>
</ListItemIcon>
<ListItemText id={labelId} primary={`Line item ${value + 1}`} />
</ListItemButton>
</ListItem>
);
})}
Expand Down
27 changes: 16 additions & 11 deletions docs/src/pages/components/lists/CheckboxListSecondary.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import ListItemSecondaryAction from '@material-ui/core/ListItemSecondaryAction';
import ListItemButton from '@material-ui/core/ListItemButton';
import ListItemText from '@material-ui/core/ListItemText';
import ListItemAvatar from '@material-ui/core/ListItemAvatar';
import Checkbox from '@material-ui/core/Checkbox';
Expand All @@ -28,22 +28,27 @@ export default function CheckboxListSecondary() {
{[0, 1, 2, 3].map((value) => {
const labelId = `checkbox-list-secondary-label-${value}`;
return (
<ListItem key={value} button>
<ListItemAvatar>
<Avatar
alt={`Avatar n°${value + 1}`}
src={`/static/images/avatar/${value + 1}.jpg`}
/>
</ListItemAvatar>
<ListItemText id={labelId} primary={`Line item ${value + 1}`} />
<ListItemSecondaryAction>
<ListItem
key={value}
secondaryAction={
<Checkbox
edge="end"
onChange={handleToggle(value)}
checked={checked.indexOf(value) !== -1}
inputProps={{ 'aria-labelledby': labelId }}
/>
</ListItemSecondaryAction>
}
disablePadding
>
<ListItemButton>
<ListItemAvatar>
<Avatar
alt={`Avatar n°${value + 1}`}
src={`/static/images/avatar/${value + 1}.jpg`}
/>
</ListItemAvatar>
<ListItemText id={labelId} primary={`Line item ${value + 1}`} />
</ListItemButton>
</ListItem>
);
})}
Expand Down
27 changes: 16 additions & 11 deletions docs/src/pages/components/lists/CheckboxListSecondary.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as React from 'react';
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import ListItemSecondaryAction from '@material-ui/core/ListItemSecondaryAction';
import ListItemButton from '@material-ui/core/ListItemButton';
import ListItemText from '@material-ui/core/ListItemText';
import ListItemAvatar from '@material-ui/core/ListItemAvatar';
import Checkbox from '@material-ui/core/Checkbox';
Expand All @@ -28,22 +28,27 @@ export default function CheckboxListSecondary() {
{[0, 1, 2, 3].map((value) => {
const labelId = `checkbox-list-secondary-label-${value}`;
return (
<ListItem key={value} button>
<ListItemAvatar>
<Avatar
alt={`Avatar n°${value + 1}`}
src={`/static/images/avatar/${value + 1}.jpg`}
/>
</ListItemAvatar>
<ListItemText id={labelId} primary={`Line item ${value + 1}`} />
<ListItemSecondaryAction>
<ListItem
key={value}
secondaryAction={
<Checkbox
edge="end"
onChange={handleToggle(value)}
checked={checked.indexOf(value) !== -1}
inputProps={{ 'aria-labelledby': labelId }}
/>
</ListItemSecondaryAction>
}
disablePadding
>
<ListItemButton>
<ListItemAvatar>
<Avatar
alt={`Avatar n°${value + 1}`}
src={`/static/images/avatar/${value + 1}.jpg`}
/>
</ListItemAvatar>
<ListItemText id={labelId} primary={`Line item ${value + 1}`} />
</ListItemButton>
</ListItem>
);
})}
Expand Down
Loading