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

[docs] Migrate Menu demos to emotion #25554

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 18 additions & 18 deletions docs/src/pages/components/menus/CustomizedMenus.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { withStyles, alpha } from '@material-ui/core/styles';
import { experimentalStyled as styled, alpha } from '@material-ui/core/styles';
import Button from '@material-ui/core/Button';
import Menu from '@material-ui/core/Menu';
import MenuItem from '@material-ui/core/MenuItem';
Expand All @@ -10,8 +10,22 @@ import FileCopyIcon from '@material-ui/icons/FileCopy';
import MoreHorizIcon from '@material-ui/icons/MoreHoriz';
import KeyboardArrowDownIcon from '@material-ui/icons/KeyboardArrowDown';

const StyledMenu = withStyles((theme) => ({
paper: {
const StyledMenu = styled((props) => (
<Menu
elevation={0}
getContentAnchorEl={null}
anchorOrigin={{
vertical: 'bottom',
horizontal: 'right',
}}
transformOrigin={{
vertical: 'top',
horizontal: 'right',
}}
{...props}
/>
))(({ theme }) => ({
'& .MuiPaper-root': {
borderRadius: 6,
marginTop: theme.spacing(1),
minWidth: 180,
Expand All @@ -37,21 +51,7 @@ const StyledMenu = withStyles((theme) => ({
},
},
},
}))((props) => (
<Menu
elevation={0}
getContentAnchorEl={null}
anchorOrigin={{
vertical: 'bottom',
horizontal: 'right',
}}
transformOrigin={{
vertical: 'top',
horizontal: 'right',
}}
{...props}
/>
));
}));

export default function CustomizedMenus() {
const [anchorEl, setAnchorEl] = React.useState(null);
Expand Down
63 changes: 31 additions & 32 deletions docs/src/pages/components/menus/CustomizedMenus.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import { withStyles, createStyles, alpha } from '@material-ui/core/styles';
import { experimentalStyled as styled, alpha } from '@material-ui/core/styles';
import Button from '@material-ui/core/Button';
import Menu, { MenuProps } from '@material-ui/core/Menu';
import MenuItem from '@material-ui/core/MenuItem';
Expand All @@ -9,37 +9,9 @@ import ArchiveIcon from '@material-ui/icons/Archive';
import FileCopyIcon from '@material-ui/icons/FileCopy';
import MoreHorizIcon from '@material-ui/icons/MoreHoriz';
import KeyboardArrowDownIcon from '@material-ui/icons/KeyboardArrowDown';
import * as CSS from 'csstype';

const StyledMenu = withStyles((theme) =>
createStyles({
paper: {
borderRadius: 6,
marginTop: theme.spacing(1),
minWidth: 180,
color:
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': {
padding: '4px 0',
},
'& .MuiListItem-root': {
...theme.typography.body1,
'& .MuiSvgIcon-root': {
fontSize: 18,
color: theme.palette.text.secondary,
marginRight: theme.spacing(1.5),
},
'&:active': {
backgroundColor: alpha(
theme.palette.primary.main,
theme.palette.action.selectedOpacity,
),
},
},
},
}),
)((props: MenuProps) => (
const StyledMenu = styled((props: MenuProps) => (
<Menu
elevation={0}
getContentAnchorEl={null}
Expand All @@ -53,7 +25,34 @@ const StyledMenu = withStyles((theme) =>
}}
{...props}
/>
));
))(({ theme }) => ({
'& .MuiPaper-root': {
borderRadius: 6,
marginTop: theme.spacing(1),
minWidth: 180,
color:
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': {
padding: '4px 0',
},
'& .MuiListItem-root': {
...(theme.typography.body1 as CSS.Properties),
'& .MuiSvgIcon-root': {
fontSize: 18,
color: theme.palette.text.secondary,
marginRight: theme.spacing(1.5),
},
'&:active': {
backgroundColor: alpha(
theme.palette.primary.main,
theme.palette.action.selectedOpacity,
),
},
},
},
}));

export default function CustomizedMenus() {
const [anchorEl, setAnchorEl] = React.useState<null | HTMLElement>(null);
Expand Down
11 changes: 7 additions & 4 deletions docs/src/pages/components/menus/SimpleListMenu.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as React from 'react';
import Box from '@material-ui/core/Box';
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import ListItemText from '@material-ui/core/ListItemText';
Expand Down Expand Up @@ -31,8 +30,12 @@ export default function SimpleListMenu() {
};

return (
<Box sx={{ bgcolor: 'background.paper' }}>
<List component="nav" aria-label="Device settings">
<div>
<List
component="nav"
aria-label="Device settings"
sx={{ bgcolor: 'background.paper' }}
>
<ListItem
button
id="lock-button"
Expand Down Expand Up @@ -69,6 +72,6 @@ export default function SimpleListMenu() {
</MenuItem>
))}
</Menu>
</Box>
</div>
);
}
11 changes: 7 additions & 4 deletions docs/src/pages/components/menus/SimpleListMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import * as React from 'react';
import Box from '@material-ui/core/Box';
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import ListItemText from '@material-ui/core/ListItemText';
Expand Down Expand Up @@ -34,8 +33,12 @@ export default function SimpleListMenu() {
};

return (
<Box sx={{ bgcolor: 'background.paper' }}>
<List component="nav" aria-label="Device settings">
<div>
<List
component="nav"
aria-label="Device settings"
sx={{ bgcolor: 'background.paper' }}
>
<ListItem
button
id="lock-button"
Expand Down Expand Up @@ -72,6 +75,6 @@ export default function SimpleListMenu() {
</MenuItem>
))}
</Menu>
</Box>
</div>
);
}