You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

NavItem.jsx 1.8KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import { Box, ListItemButton, ListItemText, Typography } from '@mui/material';
  2. import Link from 'next/link';
  3. export const NavItemMobile = ({
  4. toggleDrawer,
  5. icon,
  6. name,
  7. url,
  8. totalQuantity,
  9. }) => {
  10. return (
  11. <ListItemButton>
  12. <Link href={url}>
  13. <ListItemText
  14. onClick={toggleDrawer(false)}
  15. primary={
  16. <Box sx={{ display: 'flex' }}>
  17. <Box sx={{ mt: 0.4, mr: 4 }}>{icon}</Box>
  18. <Typography
  19. sx={{ fontSize: '22px' }}
  20. style={{ color: 'primary.main' }}
  21. >
  22. {name}
  23. </Typography>
  24. {name === 'Cart' && totalQuantity !== 0 && (
  25. <Box
  26. sx={{
  27. color: 'white',
  28. width: 20,
  29. height: 20,
  30. borderRadius: 20,
  31. textAlign: 'center',
  32. ml: 2.6,
  33. mt: '-7px',
  34. fontSize: 15,
  35. position: 'absolute',
  36. backgroundColor: 'primary.main',
  37. }}
  38. >
  39. {totalQuantity}
  40. </Box>
  41. )}
  42. </Box>
  43. }
  44. />
  45. </Link>
  46. </ListItemButton>
  47. );
  48. };
  49. export const NavItemDesktop = ({ url, router, name }) => {
  50. return (
  51. <Box sx={{ width: 150, mr: 3, ml: 3 }}>
  52. <Link href={url}>
  53. <Typography
  54. textAlign="center"
  55. sx={{
  56. mx: 'auto',
  57. width: '100%',
  58. fontSize: { md: 24, lg: 24 },
  59. mt: -1,
  60. fontWeight: 500,
  61. color: router.pathname === '/' ? 'white' : 'primary.main',
  62. textDecoration: 'none',
  63. cursor: 'pointer',
  64. }}
  65. >
  66. {name}
  67. </Typography>
  68. </Link>
  69. </Box>
  70. );
  71. };