-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Menu] Use ButtonBase in MenuItem (#26591)
- Loading branch information
1 parent
25a37ee
commit 1406f51
Showing
25 changed files
with
768 additions
and
164 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | ||
); | ||
} |
Oops, something went wrong.