Skip to content

Commit

Permalink
feat: create menu item component
Browse files Browse the repository at this point in the history
  • Loading branch information
Artur Santiago committed Oct 14, 2021
1 parent 104d445 commit 8779c4f
Showing 1 changed file with 68 additions and 6 deletions.
74 changes: 68 additions & 6 deletions src/components/MenuItem/MenuItem.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,69 @@
import React from 'react';
import { ListItem, ListItemIcon, ListItemText } from '@material-ui/core';
import { SvgIconComponent } from '@material-ui/icons';
import { makeStyles } from '@material-ui/styles';
import clsx from 'clsx';

export const MenuItem = (): JSX.Element => (
<div>
MenuItem
</div>
);
const useStyles = makeStyles({
menuItem: {
display: 'flex',
justifyContent: 'center',
minHeight: 44,
},
menuItemActive: {
backgroundColor: '#EBEBEC',
},
icon: {
justifyContent: 'center',
},
iconActive: {
color: '#6EC177',
},
primaryText: {
whiteSpace: 'nowrap',
},
primaryTextActive: {
color: '#6EC177',
fontWeight: 500,
},
});

type Props = {
icon: SvgIconComponent
small?: boolean
path: string
primaryText: string
onClick: () => void
}

export const MenuItem = ({
icon: Icon,
small,
path,
primaryText,
onClick,
}: Props): JSX.Element => {
const classes = useStyles();
const isActive = path === '/dashboard';

function handleOnClick() {
onClick?.();
}

return (
<ListItem
button
className={clsx(classes.menuItem, isActive && classes.menuItemActive)}
onClick={handleOnClick}
>
<ListItemIcon className={clsx(classes.icon, isActive && classes.iconActive)}>
<Icon />
</ListItemIcon>
{/* {!small && ( */}
<ListItemText
primary={!small && primaryText}
primaryTypographyProps={{ variant: 'body2', className: clsx(classes.primaryText, isActive && classes.primaryTextActive) }}
/>
{/* )} */}
</ListItem>
);
};

0 comments on commit 8779c4f

Please sign in to comment.