I am currently utilizing Material UI and in the process of converting regular CSS classes into a JavaScript file.
.nav {
list-style-type: none;
margin: 0;
padding: 0;
overflow: hidden;
}
.navItem {
float: left;
flex: 1;
}
.navLink {
color: white;
text-decoration: none;
display: block;
font-size: '1 rem';
font-weight: 500;
line-height: 1.6;
letter-spacing: '0.0075em';
opacity: 1;
text-transform: 'none';
min-width: 0;
padding: 10px;
margin-left: 10px;
margin-right: 10px;
}
.navLink-static {
color: white;
text-decoration: none;
display: block;
font-size: '1rem';
font-weight: 500;
line-height: 1.6;
letter-spacing: '0.0075em';
opacity: 1;
text-transform: 'none';
padding: 10px;
margin-left: 10px;
margin-right: 10px;
}
.navLink:hover {
border-bottom: 2px solid mediumvioletred;
background: #8DB8DD;
cursor: pointer;
}
.navLink:hover > div:hover {
border-bottom: none;
}
.navLink.active {
font-weight: 600;
border-radius: 0;
border-color: transparent;
border-bottom: 3px solid orange;
padding-bottom: 10px;
}
<ul className={classes.nav}>
<li className={classes.navItem}>
<NavLink className={classes.navLink} to="/" exact>
abc
</NavLink>
</li>
<li className={classes.navItem}>
<NavLink className={classes.navLink} to="/def" exact>
def
</NavLink>
</li>
<li className={classes.navItem}>
<NavLink className={classes.navLink} to="/ghi">
ghi
</NavLink>
</li>
</ul>
How do I convert these CSS styles into a material UI pattern? I am struggling with setting an 'active' state and implementing nested hover styles for elements. Additional documentation on advanced scenarios like this would be greatly helpful.
This is my current progress:
const styles = theme => ({
nav: {
listStyleType: 'none',
margin: 0,
padding: 0,
overflow: 'hidden'
},
navItem: {
float: 'left',
flex: 1
},
navLink: {
color: 'white',
textDecoration: 'none',
display: 'block',
fontSize: '1rem',
fontWeight: 500,
lineHeight: 1.6,
letterSpacing: '0.0075em',
opacity: 1,
textTransform: 'none',
minWidth: 0,
padding: '10px',
marginLeft: '10px',
marginRight: '10px',
'&:hover': {
borderBottom: '2px solid mediumvioletred',
background: '#8DB8DD',
cursor: 'pointer',
'&> div &:hover': {
borderBottom: 'none',
}
},
},
navLinkStatic: {
color: 'white',
textDecoration: 'none',
display: 'block',
fontSize: '1rem',
fontWeight: 500,
lineHeight: 1.6,
letterSpacing: '0.0075em',
opacity: 1,
textTransform: 'none',
padding: '10px',
marginLeft: '10px',
marginRight: '10px',
}
});
My attempt to convert .navLink:hover > div:hover {:
Things I have tried.
navLink: {
'&:hover': {
borderBottom: '2px solid mediumvioletred',
background: '#8DB8DD',
cursor: 'pointer',
'&> div &:hover': {
borderBottom: 'none',
}
},
'&:hover > div:hover': {
borderBottom: 'none'
}
},
Any assistance would be welcomed.