Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

NavItem.tsx 2.1KB

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