|
1 | | -import ChatIcon from "@mui/icons-material/Chat"; |
2 | | -import HomeIcon from "@mui/icons-material/Home"; |
3 | | -import PeopleIcon from "@mui/icons-material/People"; |
4 | | -import SettingsIcon from "@mui/icons-material/Settings"; |
5 | | -import { BottomNavigation, BottomNavigationAction, Box } from "@mui/material"; |
6 | 1 | import Link from "next/link"; |
| 2 | +import { MdHome } from "react-icons/md"; |
| 3 | +import { MdPeople } from "react-icons/md"; |
| 4 | +import { MdChat } from "react-icons/md"; |
| 5 | +import { MdSettings } from "react-icons/md"; |
7 | 6 |
|
8 | 7 | type Props = { |
9 | 8 | activeTab: "0_home" | "1_friends" | "2_chat" | "3_settings"; |
10 | 9 | }; |
11 | 10 |
|
| 11 | +function BottomBarCell({ |
| 12 | + label, |
| 13 | + href, |
| 14 | + iconComponent, |
| 15 | + isActive, |
| 16 | +}: { |
| 17 | + label: string; |
| 18 | + href: string; |
| 19 | + iconComponent: React.ReactNode; |
| 20 | + isActive: boolean; |
| 21 | +}) { |
| 22 | + return ( |
| 23 | + <Link |
| 24 | + href={href} |
| 25 | + className={`focus:bg-gray-300 ${isActive ? "active text-primary" : "text-secondary"}`} |
| 26 | + > |
| 27 | + {iconComponent} |
| 28 | + <span |
| 29 | + className={`text-xs ${isActive ? "text-primary" : "text-gray-500"}`} |
| 30 | + > |
| 31 | + {label} |
| 32 | + </span> |
| 33 | + </Link> |
| 34 | + ); |
| 35 | +} |
| 36 | + |
12 | 37 | export default function BottomBar(props: Props) { |
13 | 38 | const { activeTab } = props; |
14 | 39 | return ( |
15 | | - <Box sx={{ position: "fixed", bottom: 0, left: 0, right: 0 }}> |
16 | | - {/* TODO: 単に Viewer として BottomNavigation を使用しているので Box 等で置き換える */} |
17 | | - <BottomNavigation |
18 | | - showLabels |
19 | | - value={activeTab} |
20 | | - sx={{ |
21 | | - width: "100%", |
22 | | - bottom: 0, |
23 | | - borderTop: "1px solid", |
24 | | - borderColor: "primary.main", |
25 | | - }} |
26 | | - > |
27 | | - <BottomNavigationAction |
28 | | - component={Link} |
29 | | - href="/home" |
30 | | - label="Home" |
31 | | - icon={ |
32 | | - <HomeIcon |
33 | | - sx={{ |
34 | | - color: |
35 | | - activeTab === "0_home" ? "primary.main" : "secondary.main", |
36 | | - }} |
37 | | - /> |
38 | | - } |
39 | | - /> |
40 | | - <BottomNavigationAction |
41 | | - component={Link} |
42 | | - href="/friends" |
43 | | - label="Friends" |
44 | | - icon={ |
45 | | - <PeopleIcon |
46 | | - sx={{ |
47 | | - color: |
48 | | - activeTab === "1_friends" ? "primary.main" : "secondary.main", |
49 | | - }} |
50 | | - /> |
51 | | - } |
52 | | - /> |
53 | | - <BottomNavigationAction |
54 | | - component={Link} |
55 | | - href="/chat" |
56 | | - label="Chat" |
57 | | - icon={ |
58 | | - <ChatIcon |
59 | | - sx={{ |
60 | | - color: |
61 | | - activeTab === "2_chat" ? "primary.main" : "secondary.main", |
62 | | - }} |
63 | | - /> |
64 | | - } |
65 | | - /> |
66 | | - <BottomNavigationAction |
67 | | - component={Link} |
68 | | - href="/settings" |
69 | | - label="Settings" |
70 | | - icon={ |
71 | | - <SettingsIcon |
72 | | - sx={{ |
73 | | - color: |
74 | | - activeTab === "3_settings" |
75 | | - ? "primary.main" |
76 | | - : "secondary.main", |
77 | | - }} |
78 | | - /> |
79 | | - } |
80 | | - /> |
81 | | - </BottomNavigation> |
82 | | - </Box> |
| 40 | + <div className="btm-nav flex max-h-14 w-full flex-row"> |
| 41 | + <BottomBarCell |
| 42 | + label="Home" |
| 43 | + href="/home" |
| 44 | + isActive={activeTab === "0_home"} |
| 45 | + iconComponent={<MdHome className="text-2xl" />} |
| 46 | + /> |
| 47 | + <BottomBarCell |
| 48 | + label="Friends" |
| 49 | + href="/friends" |
| 50 | + isActive={activeTab === "1_friends"} |
| 51 | + iconComponent={<MdPeople className="text-2xl" />} |
| 52 | + /> |
| 53 | + <BottomBarCell |
| 54 | + label="Chat" |
| 55 | + href="/chat" |
| 56 | + isActive={activeTab === "2_chat"} |
| 57 | + iconComponent={<MdChat className="text-2xl" />} |
| 58 | + /> |
| 59 | + <BottomBarCell |
| 60 | + label="Settings" |
| 61 | + href="/settings" |
| 62 | + isActive={activeTab === "3_settings"} |
| 63 | + iconComponent={<MdSettings className="text-2xl" />} |
| 64 | + /> |
| 65 | + </div> |
83 | 66 | ); |
84 | 67 | } |
0 commit comments