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

Migrate menu and menuitem #150

Draft
wants to merge 2 commits into
base: playground
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
22 changes: 16 additions & 6 deletions src/menu/menu-item.component.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
import React from 'react';

import { styled } from '@mui/material/styles';

import { MenuItem as MuiMenuItem } from '@mui/material';
import { makeStyles } from '@mui/styles';
const PREFIX = 'menu-item';

const classes = {
root: `${PREFIX}-root`,
};

const menuItemStyles = makeStyles(theme => ({
root: {
padding: theme.spacing(0.5),
const StyledMuiMenuItem = styled(MuiMenuItem)(({ theme }) => ({
[`&.${classes.root}`]: {
padding: '0.2rem 0.5rem',
margin: '0.1rem 0.15rem',
backgroundColor: '#5d666e',
':hover' : {
backgroundColor: 'rgb(71, 82, 90)',
},
'& + &': {
borderTop: `1px solid ${theme.palette.divider}`,
},
Expand All @@ -26,8 +37,7 @@ const menuItemStyles = makeStyles(theme => ({
*/

const MenuItem = (props, ref) => {
const menuItemClasses = menuItemStyles(props);
return <MuiMenuItem classes={menuItemClasses} {...props} ref={ref} />;
return <StyledMuiMenuItem className={classes.root} {...props} ref={ref} />;
};

export default React.forwardRef(MenuItem);
11 changes: 6 additions & 5 deletions src/menu/menu.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@ import { styled } from '@mui/material/styles';

import { Menu as MuiMenu } from '@mui/material';

const PREFIX = 'MarkMenu';
const PREFIX = 'Menu';

const classes = {
list: `${PREFIX}-list`,
};

const StyledMuiMenu = styled(MuiMenu)(({ theme }) => ({
[`&.${classes.list}`]: {
marginLeft: theme.spacing(1),
marginRight: theme.spacing(1),
[`& .${classes.list}`]: {
backgroundColor: '#5d666e',
marginLeft: theme.spacing(-0.25),
marginRight: theme.spacing(-0.5),
marginTop: '-10px',
padding: '5rem',
},
}));
Expand All @@ -25,7 +27,6 @@ const StyledMuiMenu = styled(MuiMenu)(({ theme }) => ({

const Menu = (props, ref) => {
return <StyledMuiMenu className={classes.list} {...props} ref={ref} />;
// return <StyledMuiMenu classes={classes} {...props} ref={ref} />;
};

export default React.forwardRef(Menu);
11 changes: 10 additions & 1 deletion src/themes/dark.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,20 @@ const dark = {
// },
// },
// },
MuiMenu: {
styleOverrides: {
list: {
backgroundColor: '#5d666e',
},
},
},
MuiMenuItem: {
styleOverrides: {
root: {
backgroundColor: '#5d666e',
'&:hover': {
backgroundColor: lighten(coreTheme.palette.background.default, 0.1),
// backgroundColor: lighten(coreTheme.palette.background.default, 0.1),
backgroundColor: 'rgb(71, 82, 90)',
},
},
},
Expand Down