Download src/components/layout/BottomNav/BottomNav.jsx from TA-PangandaranAI/PangandaranAI_FE: direct link, hf CLI and curl.
- Browser
- Download file 1.86 kB
-
https://huggingface.co/spaces/TA-PangandaranAI/PangandaranAI_FE/resolve/main/src/components/layout/BottomNav/BottomNav.jsx
- Command line
-
hf download hf://spaces/TA-PangandaranAI/PangandaranAI_FE/src/components/layout/BottomNav/BottomNav.jsx
-
curl -L -o BottomNav.jsx https://huggingface.co/spaces/TA-PangandaranAI/PangandaranAI_FE/resolve/main/src/components/layout/BottomNav/BottomNav.jsx
1.86 kB
| "use client"; | |
| import { useRouter, usePathname } from "next/navigation"; | |
| import { useDispatch, useSelector } from "react-redux"; | |
| import { setActiveTab } from "@/store/uiSlice"; | |
| import styles from "./BottomNav.module.css"; | |
| const tabs = [ | |
| { | |
| id: "home", | |
| label: "Home", | |
| path: "/home", | |
| iconLight: "/images/home-light.svg", | |
| iconTeal: "/images/home-teal.svg", | |
| }, | |
| { | |
| id: "search", | |
| label: "Saved", | |
| path: "/search", | |
| iconLight: "/images/bookmark-light.svg", | |
| iconTeal: "/images/bookmark-teal.svg", | |
| }, | |
| { | |
| id: "chatbot", | |
| label: "Chatbot", | |
| path: "/chatbot", | |
| iconLight: "/images/chatbot-light.svg", | |
| iconTeal: "/images/chatbot-teal.svg", | |
| }, | |
| ]; | |
| export default function BottomNav() { | |
| const router = useRouter(); | |
| const pathname = usePathname(); | |
| const dispatch = useDispatch(); | |
| const activeTab = useSelector((state) => state.ui.activeTab); | |
| const handleTabClick = (tab) => { | |
| dispatch(setActiveTab(tab.id)); | |
| router.push(tab.path); | |
| }; | |
| // Determine active tab from pathname | |
| const currentTab = | |
| tabs.find((t) => pathname.startsWith(t.path))?.id || activeTab; | |
| return ( | |
| <nav className={styles.bottomNav}> | |
| {tabs.map((tab) => { | |
| const isActive = currentTab === tab.id; | |
| return ( | |
| <button | |
| key={tab.id} | |
| className={`${styles.tab} ${isActive ? styles.active : ""}`} | |
| onClick={() => handleTabClick(tab)} | |
| aria-label={tab.label} | |
| > | |
| <span className={styles.icon}> | |
| <img | |
| src={isActive ? tab.iconTeal : tab.iconLight} | |
| alt={tab.label} | |
| width={24} | |
| height={24} | |
| /> | |
| </span> | |
| <span className={styles.label}>{tab.label}</span> | |
| </button> | |
| ); | |
| })} | |
| </nav> | |
| ); | |
| } | |