Files
Web-Frontend/client/src/pages/home/Home.jsx
T

64 lines
2.4 KiB
React
Raw Normal View History

import { HStack, Flex, Box } from "@chakra-ui/react";
import { NavLink, Outlet, useLocation } from "react-router-dom";
2026-06-10 14:00:37 -07:00
import { SearchBar } from "../../components/dashboard/SearchBar.jsx";
import { SettingsButton } from "../../components/dashboard/SettingsButton.jsx";
2025-08-06 16:27:08 -07:00
2026-06-04 15:30:01 -07:00
export default function Home() {
const location = useLocation();
const isPersonalDashboard = location.pathname === "/home" || location.pathname === "/home/";
2026-06-04 15:30:01 -07:00
// 1. CSS making this look like how we want it, TODO turn to theme?
const tabStyles = {
fontSize: "lg",
fontWeight: "bold",
color: "fg.muted",
px: 2, // Horizontal padding
// py: 2, // Vertical padding
borderBottom: "1px solid transparent",
transition: "all 0.2s",
_hover: { color: "fg" },
"&.active": { // Target the active class applied by React Router NavLink
color: "fg",
borderColor: "fg",
2026-06-04 15:30:01 -07:00
}
};
2025-07-24 08:52:20 -07:00
return (
<Flex direction="column" height="100%" width="100%">
{/* 2. 🛠️ SUB HEADER: Matches your original padding and background */}
2026-07-22 14:58:59 -07:00
<Flex as="header" position="sticky" top="0" zIndex="dropdown" bg="transparent" p={5} align="center" justify="space-between" width="100%">
{/* TABS CONTAINER - Replicates the Tabs.List line container */}
<Flex borderBottom="1px solid" borderColor="fg.muted" gap={2}>
<Box as={NavLink} to="/home" end css={tabStyles}>My Dashboard</Box>
<Box as={NavLink} to="/home/daily" css={tabStyles}>Daily Activity</Box>
<Box as={NavLink} to="/home/gas" css={tabStyles}>Gas</Box>
<Box as={NavLink} to="/home/remote" css={tabStyles}>Remote Sensing</Box>
<Box as={NavLink} to="/home/seismic" css={tabStyles}>Seismic</Box>
</Flex>
{/* EDIT MODE BUTTONS & CONTROLS */}
<HStack width="258px" justifyContent="flex-end">
{isPersonalDashboard ? (
<>
<SearchBar placeholder="Enter a volcano to search" size="sm" width="210px" />
{/* This will eventually trigger your Zustand store's edit mode! */}
<SettingsButton />
</>
) : (
2026-07-22 14:58:59 -07:00
<SettingsButton />
)}
</HStack>
</Flex>
{/* 3. 🛠️ CANVAS AREA */}
<Flex flex="1" overflow="auto">
<Outlet />
</Flex>
2026-06-04 15:30:01 -07:00
2025-07-24 08:52:20 -07:00
</Flex>
);
}