Skip to content

Instantly share code, notes, and snippets.

@sibelius
Created July 16, 2019 14:54
Show Gist options
  • Save sibelius/85ffcd79ef6513c00410fdb321126a08 to your computer and use it in GitHub Desktop.
Save sibelius/85ffcd79ef6513c00410fdb321126a08 to your computer and use it in GitHub Desktop.
how to use styled-components instead of clsx
const styles = theme => ({
drawer: {
position: 'absolute',
overflowX: 'hidden',
zIndex: theme.zIndex.drawer + 2,
[theme.breakpoints.up('sm')]: {
position: 'relative',
width: drawerWidth,
flexShrink: 0,
zIndex: theme.zIndex.drawer,
},
whiteSpace: 'nowrap',
},
drawerOpen: {
width: drawerWidth,
transition: theme.transitions.create('width', {
easing: theme.transitions.easing.sharp,
duration: theme.transitions.duration.enteringScreen,
}),
},
drawerClose: {
transition: theme.transitions.create('width', {
easing: theme.transitions.easing.sharp,
duration: theme.transitions.duration.leavingScreen,
}),
overflowX: 'hidden',
width: 0,
[theme.breakpoints.up('sm')]: {
width: theme.spacing.unit * 9 + 1,
},
},
});
<Drawer
variant="permanent"
open={isOpen}
className={clsx(classes.drawer, {
[classes.drawerOpen]: isOpen,
[classes.drawerClose]: !isOpen,
})}
classes={{
paper: clsx({
[classes.drawerOpen]: isOpen,
[classes.drawerClose]: !isOpen,
}),
}}
>
</Drawer>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment