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

[Menu] Use ButtonBase in MenuItem #26591

Merged
merged 67 commits into from
Jun 16, 2021
Merged
Show file tree
Hide file tree
Changes from 63 commits
Commits
Show all changes
67 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
2db70c3
use classes from ListItemButton
siriwatknp Jun 4, 2021
47e9310
replace ListItem with ListItemButton
siriwatknp Jun 4, 2021
ef9ac53
update Menu demos
siriwatknp Jun 4, 2021
c80254e
removed deprecated tests
siriwatknp Jun 4, 2021
aa6f764
fix spec
siriwatknp Jun 4, 2021
0cbb7af
run proptypes and docs:api
siriwatknp Jun 4, 2021
5af296d
pass dense to children
siriwatknp Jun 4, 2021
7ca9341
add account menu demo
siriwatknp Jun 4, 2021
692950c
run proptypes
siriwatknp Jun 4, 2021
5c784ba
Merge branch 'next' of https://github.com/mui-org/material-ui into me…
siriwatknp Jun 8, 2021
0a35893
fix style and demos
siriwatknp Jun 8, 2021
9f24af1
remove min-width
siriwatknp Jun 8, 2021
884ec77
replace ListItemClasses
siriwatknp Jun 8, 2021
6fda99b
Merge branch 'next' of https://github.com/mui-org/material-ui into me…
siriwatknp Jun 10, 2021
23790db
replace ListItemButton with ButtonBase
siriwatknp Jun 10, 2021
c6480b0
fix tests
siriwatknp Jun 10, 2021
6febdaf
bring back divider prop
siriwatknp Jun 10, 2021
c680455
run prettier
siriwatknp Jun 10, 2021
2ab4564
fix default anchorOrigin
siriwatknp Jun 10, 2021
22b4e61
Update packages/material-ui/src/MenuItem/menuItemClasses.ts
siriwatknp Jun 11, 2021
04d0336
Update docs/src/pages/components/menus/DenseMenu.tsx
siriwatknp Jun 11, 2021
fbb3db4
Update packages/material-ui/src/MenuItem/menuItemClasses.ts
siriwatknp Jun 11, 2021
907847d
Update docs/src/pages/components/menus/menus.md
siriwatknp Jun 11, 2021
9ba402b
Update docs/src/pages/components/menus/IconMenu.tsx
siriwatknp Jun 11, 2021
7ae4c03
Update docs/src/pages/components/menus/IconMenu.tsx
siriwatknp Jun 11, 2021
79f9b55
Update docs/src/pages/components/menus/DenseMenu.tsx
siriwatknp Jun 11, 2021
6f6f588
Update docs/src/pages/components/menus/AccountMenu.tsx
siriwatknp Jun 11, 2021
fc22985
update demos
siriwatknp Jun 11, 2021
6165408
remove arrow from demo
siriwatknp Jun 11, 2021
82152bb
Apply suggestions from code review
siriwatknp Jun 11, 2021
99fafc0
Apply suggestions from code review
siriwatknp Jun 11, 2021
fea2336
bring disableGutters back
siriwatknp Jun 11, 2021
dabad8d
fix migration
siriwatknp Jun 11, 2021
5f85ac8
prettier
oliviertassinari Jun 12, 2021
e8622f0
polish changelog
oliviertassinari Jun 12, 2021
90a99cc
use same terminology as in the demo
oliviertassinari Jun 12, 2021
a1efeb8
fix import
oliviertassinari Jun 12, 2021
8a6d04a
Merge branch 'next' into HEAD
oliviertassinari Jun 12, 2021
a92b817
Apply suggestions from code review
siriwatknp Jun 14, 2021
e941a0c
Update packages/material-ui/src/MenuItem/menuItemClasses.ts
siriwatknp Jun 16, 2021
8b90383
update migration
siriwatknp Jun 16, 2021
19d0eb8
Apply suggestions from code review
siriwatknp Jun 16, 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
2 changes: 1 addition & 1 deletion docs/pages/api-docs/list-item-button.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
"spread": true,
"forwardsRefTo": "HTMLDivElement",
"filename": "/packages/material-ui/src/ListItemButton/ListItemButton.js",
"inheritance": null,
"inheritance": { "component": "ButtonBase", "pathname": "/api/button-base/" },
"demos": "<ul><li><a href=\"/components/lists/\">Lists</a></li></ul>",
"styledComponent": true,
"cssComponent": false
Expand Down
14 changes: 10 additions & 4 deletions docs/pages/api-docs/menu-item.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
{
"props": {
"autoFocus": { "type": { "name": "bool" } },
"children": { "type": { "name": "node" } },
"classes": { "type": { "name": "object" } },
"component": { "type": { "name": "elementType" } },
"dense": { "type": { "name": "bool" } },
"disableGutters": { "type": { "name": "bool" } },
"ListItemClasses": { "type": { "name": "object" } },
"divider": { "type": { "name": "bool" } },
"focusVisibleClassName": { "type": { "name": "string" } },
"sx": { "type": { "name": "object" } }
},
"name": "MenuItem",
"styles": {
"classes": ["root", "gutters", "selected", "dense"],
"globalClasses": { "selected": "Mui-selected" },
"classes": ["root", "focusVisible", "dense", "disabled", "divider", "gutters", "selected"],
"globalClasses": {
"focusVisible": "Mui-focusVisible",
"disabled": "Mui-disabled",
"selected": "Mui-selected"
},
"name": "MuiMenuItem"
},
"spread": true,
"forwardsRefTo": "HTMLLIElement",
"filename": "/packages/material-ui/src/MenuItem/MenuItem.js",
"inheritance": { "component": "ListItem", "pathname": "/api/list-item/" },
"inheritance": { "component": "ButtonBase", "pathname": "/api/button-base/" },
"demos": "<ul><li><a href=\"/components/menus/\">Menus</a></li></ul>",
"styledComponent": true,
"cssComponent": false
Expand Down
97 changes: 97 additions & 0 deletions docs/src/pages/components/menus/AccountMenu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import * as React from 'react';
import Box from '@material-ui/core/Box';
import Avatar from '@material-ui/core/Avatar';
import Menu from '@material-ui/core/Menu';
import MenuItem from '@material-ui/core/MenuItem';
import ListItemIcon from '@material-ui/core/ListItemIcon';
import Divider from '@material-ui/core/Divider';
import IconButton from '@material-ui/core/IconButton';
import Typography from '@material-ui/core/Typography';
import Tooltip from '@material-ui/core/Tooltip';
import PersonAdd from '@material-ui/icons/PersonAdd';
import Settings from '@material-ui/icons/Settings';
import Logout from '@material-ui/icons/Logout';

export default function AccountMenu() {
const [anchorEl, setAnchorEl] = React.useState(null);
const open = Boolean(anchorEl);
const handleClick = (event) => {
setAnchorEl(event.currentTarget);
};
const handleClose = () => {
setAnchorEl(null);
};
return (
<React.Fragment>
<Box sx={{ display: 'flex', alignItems: 'center', textAlign: 'center' }}>
<Typography sx={{ minWidth: 100 }}>Contact</Typography>
<Typography sx={{ minWidth: 100 }}>Profile</Typography>
<Tooltip title="Account settings">
<IconButton onClick={handleClick} size="small" sx={{ ml: 2 }}>
<Avatar sx={{ width: 32, height: 32 }}>M</Avatar>
</IconButton>
</Tooltip>
</Box>
<Menu
anchorEl={anchorEl}
open={open}
onClose={handleClose}
onClick={handleClose}
PaperProps={{
elevation: 0,
sx: {
overflow: 'visible',
filter: 'drop-shadow(0px 2px 8px rgba(0,0,0,0.32))',
mt: 1.5,
'& .MuiAvatar-root': {
width: 32,
height: 32,
ml: -0.5,
mr: 1,
},
'&:before': {
content: '""',
display: 'block',
position: 'absolute',
top: 0,
right: 14,
width: 10,
height: 10,
bgcolor: 'background.paper',
transform: 'translateY(-50%) rotate(45deg)',
zIndex: 0,
},
},
}}
transformOrigin={{ horizontal: 'right', vertical: 'top' }}
anchorOrigin={{ horizontal: 'right', vertical: 'bottom' }}
>
<MenuItem>
<Avatar /> Profile
</MenuItem>
<MenuItem>
<Avatar /> My account
</MenuItem>
<Divider />
<MenuItem>
<ListItemIcon>
<PersonAdd fontSize="small" />
</ListItemIcon>
Add another account
</MenuItem>
<MenuItem>
<ListItemIcon>
<Settings fontSize="small" />
</ListItemIcon>
Settings
</MenuItem>
<MenuItem>
<ListItemIcon>
<Logout fontSize="small" />
</ListItemIcon>
Logout
</MenuItem>
</Menu>
</React.Fragment>
);
}
97 changes: 97 additions & 0 deletions docs/src/pages/components/menus/AccountMenu.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import * as React from 'react';
import Box from '@material-ui/core/Box';
import Avatar from '@material-ui/core/Avatar';
import Menu from '@material-ui/core/Menu';
import MenuItem from '@material-ui/core/MenuItem';
import ListItemIcon from '@material-ui/core/ListItemIcon';
import Divider from '@material-ui/core/Divider';
import IconButton from '@material-ui/core/IconButton';
import Typography from '@material-ui/core/Typography';
import Tooltip from '@material-ui/core/Tooltip';
import PersonAdd from '@material-ui/icons/PersonAdd';
import Settings from '@material-ui/icons/Settings';
import Logout from '@material-ui/icons/Logout';

export default function AccountMenu() {
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
const open = Boolean(anchorEl);
const handleClick = (event: React.MouseEvent<HTMLElement>) => {
setAnchorEl(event.currentTarget);
};
const handleClose = () => {
setAnchorEl(null);
};
return (
<React.Fragment>
<Box sx={{ display: 'flex', alignItems: 'center', textAlign: 'center' }}>
<Typography sx={{ minWidth: 100 }}>Contact</Typography>
<Typography sx={{ minWidth: 100 }}>Profile</Typography>
<Tooltip title="Account settings">
<IconButton onClick={handleClick} size="small" sx={{ ml: 2 }}>
<Avatar sx={{ width: 32, height: 32 }}>M</Avatar>
</IconButton>
</Tooltip>
</Box>
<Menu
anchorEl={anchorEl}
open={open}
onClose={handleClose}
onClick={handleClose}
PaperProps={{
elevation: 0,
sx: {
overflow: 'visible',
filter: 'drop-shadow(0px 2px 8px rgba(0,0,0,0.32))',
mt: 1.5,
'& .MuiAvatar-root': {
width: 32,
height: 32,
ml: -0.5,
mr: 1,
},
'&:before': {
content: '""',
display: 'block',
position: 'absolute',
top: 0,
right: 14,
width: 10,
height: 10,
bgcolor: 'background.paper',
transform: 'translateY(-50%) rotate(45deg)',
zIndex: 0,
},
},
}}
transformOrigin={{ horizontal: 'right', vertical: 'top' }}
anchorOrigin={{ horizontal: 'right', vertical: 'bottom' }}
>
<MenuItem>
<Avatar /> Profile
</MenuItem>
<MenuItem>
<Avatar /> My account
</MenuItem>
<Divider />
<MenuItem>
<ListItemIcon>
<PersonAdd fontSize="small" />
</ListItemIcon>
Add another account
</MenuItem>
<MenuItem>
<ListItemIcon>
<Settings fontSize="small" />
</ListItemIcon>
Settings
</MenuItem>
<MenuItem>
<ListItemIcon>
<Logout fontSize="small" />
</ListItemIcon>
Logout
</MenuItem>
</Menu>
</React.Fragment>
);
}
5 changes: 2 additions & 3 deletions docs/src/pages/components/menus/CustomizedMenus.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@ const StyledMenu = styled((props) => (
theme.palette.mode === 'light' ? 'rgb(55, 65, 81)' : theme.palette.grey[300],
boxShadow:
'rgb(255, 255, 255) 0px 0px 0px 0px, rgba(0, 0, 0, 0.05) 0px 0px 0px 1px, rgba(0, 0, 0, 0.1) 0px 10px 15px -3px, rgba(0, 0, 0, 0.05) 0px 4px 6px -2px',
'& .MuiList-root': {
'& .MuiMenu-list': {
padding: '4px 0',
},
'& .MuiListItem-root': {
...theme.typography.body1,
'& .MuiMenuItem-root': {
'& .MuiSvgIcon-root': {
fontSize: 18,
color: theme.palette.text.secondary,
Expand Down
5 changes: 2 additions & 3 deletions docs/src/pages/components/menus/CustomizedMenus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,10 @@ const StyledMenu = styled((props: MenuProps) => (
theme.palette.mode === 'light' ? 'rgb(55, 65, 81)' : theme.palette.grey[300],
boxShadow:
'rgb(255, 255, 255) 0px 0px 0px 0px, rgba(0, 0, 0, 0.05) 0px 0px 0px 1px, rgba(0, 0, 0, 0.1) 0px 10px 15px -3px, rgba(0, 0, 0, 0.05) 0px 4px 6px -2px',
'& .MuiList-root': {
'& .MuiMenu-list': {
padding: '4px 0',
},
'& .MuiListItem-root': {
...theme.typography.body1,
'& .MuiMenuItem-root': {
'& .MuiSvgIcon-root': {
fontSize: 18,
color: theme.palette.text.secondary,
Expand Down
43 changes: 43 additions & 0 deletions docs/src/pages/components/menus/DenseMenu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import * as React from 'react';
import Paper from '@material-ui/core/Paper';
import Divider from '@material-ui/core/Divider';
import MenuList from '@material-ui/core/MenuList';
import MenuItem from '@material-ui/core/MenuItem';
import ListItemIcon from '@material-ui/core/ListItemIcon';
import ListItemText from '@material-ui/core/ListItemText';
import Check from '@material-ui/icons/Check';

export default function DenseMenu() {
return (
<Paper sx={{ width: 320 }}>
<MenuList dense>
<MenuItem>
<ListItemText inset>Single</ListItemText>
</MenuItem>
<MenuItem>
<ListItemText inset>1.15</ListItemText>
</MenuItem>
<MenuItem>
<ListItemText inset>Double</ListItemText>
</MenuItem>
<MenuItem>
<ListItemIcon>
<Check />
</ListItemIcon>
Custom: 1.2
</MenuItem>
<Divider />
<MenuItem>
<ListItemText>Add space before paragraph</ListItemText>
</MenuItem>
<MenuItem>
<ListItemText>Add space after paragraph</ListItemText>
</MenuItem>
<Divider />
<MenuItem>
<ListItemText>Custom spacing...</ListItemText>
</MenuItem>
</MenuList>
</Paper>
);
}
43 changes: 43 additions & 0 deletions docs/src/pages/components/menus/DenseMenu.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import * as React from 'react';
import Paper from '@material-ui/core/Paper';
import Divider from '@material-ui/core/Divider';
import MenuList from '@material-ui/core/MenuList';
import MenuItem from '@material-ui/core/MenuItem';
import ListItemIcon from '@material-ui/core/ListItemIcon';
import ListItemText from '@material-ui/core/ListItemText';
import Check from '@material-ui/icons/Check';

export default function DenseMenu() {
return (
<Paper sx={{ width: 320 }}>
<MenuList dense>
<MenuItem>
<ListItemText inset>Single</ListItemText>
</MenuItem>
<MenuItem>
<ListItemText inset>1.15</ListItemText>
</MenuItem>
<MenuItem>
<ListItemText inset>Double</ListItemText>
</MenuItem>
<MenuItem>
<ListItemIcon>
<Check />
</ListItemIcon>
Custom: 1.2
</MenuItem>
<Divider />
<MenuItem>
<ListItemText>Add space before paragraph</ListItemText>
</MenuItem>
<MenuItem>
<ListItemText>Add space after paragraph</ListItemText>
</MenuItem>
<Divider />
<MenuItem>
<ListItemText>Custom spacing...</ListItemText>
</MenuItem>
</MenuList>
</Paper>
);
}
Loading