選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

Navbar.jsx 4.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. import AppBar from '@mui/material/AppBar';
  2. import Box from '@mui/material/Box';
  3. import Typography from '@mui/material/Typography';
  4. import Image from 'next/image';
  5. import Link from 'next/link';
  6. import { useRouter } from 'next/router';
  7. import {
  8. BASE_PAGE,
  9. CART_PAGE,
  10. PRODUCTS_PAGE,
  11. PROFILE_PAGE,
  12. } from '../../../constants/pages';
  13. const Navbar = () => {
  14. const router = useRouter();
  15. return (
  16. <AppBar
  17. position="absolute"
  18. sx={{
  19. zIndex: 100,
  20. top: 20,
  21. width: '100%',
  22. backgroundColor: 'transparent',
  23. boxShadow: 'none',
  24. height: 40,
  25. }}
  26. >
  27. <Box sx={{ display: 'flex', width: '100%' }}>
  28. <Box
  29. sx={{
  30. flexGrow: 1,
  31. maxWidth: '50%',
  32. height: 30,
  33. display: { xs: 'none', md: 'flex' },
  34. px: 10,
  35. }}
  36. >
  37. <Link key="home" href={BASE_PAGE}>
  38. <Typography
  39. textAlign="center"
  40. sx={{
  41. mx: 'auto',
  42. fontSize: 20,
  43. fontWeight: 500,
  44. color: router.pathname === '/' ? 'white' : 'black',
  45. textDecoration: 'none',
  46. cursor: 'pointer',
  47. }}
  48. >
  49. Home
  50. </Typography>
  51. </Link>
  52. <Link key="menu" href={BASE_PAGE}>
  53. <Typography
  54. textAlign="center"
  55. sx={{
  56. mx: 'auto',
  57. fontSize: 20,
  58. fontWeight: 500,
  59. color: router.pathname === '/' ? 'white' : 'black',
  60. textDecoration: 'none',
  61. cursor: 'pointer',
  62. }}
  63. >
  64. Menu
  65. </Typography>
  66. </Link>
  67. <Link key="about" href={BASE_PAGE}>
  68. <Typography
  69. textAlign="center"
  70. sx={{
  71. mx: 'auto',
  72. fontSize: 20,
  73. fontWeight: 500,
  74. color: router.pathname === '/' ? 'white' : 'black',
  75. textDecoration: 'none',
  76. cursor: 'pointer',
  77. }}
  78. >
  79. About
  80. </Typography>
  81. </Link>
  82. <Link key="store" href={PRODUCTS_PAGE}>
  83. <Typography
  84. textAlign="center"
  85. sx={{
  86. mx: 'auto',
  87. fontSize: 20,
  88. fontWeight: 500,
  89. color: router.pathname === '/' ? 'white' : 'black',
  90. textDecoration: 'none',
  91. cursor: 'pointer',
  92. }}
  93. >
  94. Store
  95. </Typography>
  96. </Link>
  97. <Link key="contact" href={BASE_PAGE}>
  98. <Typography
  99. textAlign="center"
  100. sx={{
  101. mx: 'auto',
  102. fontSize: 20,
  103. fontWeight: 500,
  104. color: router.pathname === '/' ? 'white' : 'black',
  105. textDecoration: 'none',
  106. cursor: 'pointer',
  107. }}
  108. >
  109. Contact
  110. </Typography>
  111. </Link>
  112. </Box>
  113. <Box
  114. sx={{
  115. flexGrow: 1,
  116. maxWidth: '50%',
  117. height: 30,
  118. display: { xs: 'none', md: 'flex' },
  119. justifyContent: 'right',
  120. pt: 0.5,
  121. mr: 4,
  122. }}
  123. >
  124. <Box
  125. sx={{
  126. mx: 2,
  127. cursor: 'pointer',
  128. }}
  129. >
  130. <Link key="home" href={PROFILE_PAGE}>
  131. <Image
  132. src="/images/profile.svg"
  133. alt="profile"
  134. width={24}
  135. height={24}
  136. />
  137. </Link>
  138. </Box>
  139. <Box
  140. sx={{
  141. mr: 6,
  142. ml: 2,
  143. cursor: 'pointer',
  144. }}
  145. >
  146. <Link key="home" href={CART_PAGE}>
  147. <Image src="/images/cart.svg" alt="cart" width={24} height={24} />
  148. </Link>
  149. ,
  150. </Box>
  151. </Box>
  152. </Box>
  153. </AppBar>
  154. );
  155. };
  156. export default Navbar;