Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: left side bar section #100

Merged
merged 9 commits into from
Jul 22, 2024
1 change: 1 addition & 0 deletions tracknow/web/src/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export interface identity {
export interface identityProfile {
name: string; // username
pp: string; // profile_pic
onOpen: () => void;
}

export interface EditUser {
Expand Down
74 changes: 62 additions & 12 deletions tracknow/web/src/components/Home/Home.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,79 @@
import { NavbarLoggedIn } from "../Navbar/Navbar";
import { HomePost } from "../Post/Post";

import { useLaptimes } from "../../hooks/useLaptimes";
import { useUsers } from "../../hooks/useUsers";
import { LoadingSpinner } from "../Loading/LoadingSpinner";
import {
Box,
Flex,
useBreakpointValue,
useDisclosure,
} from "@chakra-ui/react";

import MobileDrawer from "../../misc/MobileDrawer";
import LeftSideBar from "../SideBar/LeftSideBar";
import RightSideBar from "../SideBar/RightSideBar";

export const Home = () => {

const { laptime, fetchMoreData, hasMore, laptime_loading } = useLaptimes();
const { username, profilePic, loading, } = useUsers();
const { username, profilePic, loading } = useUsers();

const { isOpen, onOpen, onClose } = useDisclosure();
const isMobile = useBreakpointValue({ base: true, md: false });

return (
<>
<NavbarLoggedIn name={username} pp={profilePic} onOpen={onOpen} />

<Flex mt={10} bg="dark" height="calc(100vh - 45px)"> {/* Adjust height to fit the viewport */}
{/* Left section */}
{isMobile ? (
<MobileDrawer isOpen={isOpen} onClose={onClose}>
<LeftSideBar />
</MobileDrawer>
) : (
<Box
flex="1"
borderRight="1px solid #323536"
overflowY="auto"
height="full"
>
<LeftSideBar />
</Box>
)}

<NavbarLoggedIn name={username} pp={profilePic} />
{loading && laptime_loading ? (
<LoadingSpinner />
) : (
<HomePost laptimes={laptime} fetchMoreData={fetchMoreData} hasMore={hasMore} />
)}

{/* Middle section */}
<Box
flex="3"
rounded={"sm"}
my={1}
mx={[0, 5]}
overflow={"hidden"}
borderRadius={"1px"}
overflowY="auto"
height="full"
>
{loading && laptime_loading ? (
<LoadingSpinner />
) : (
<HomePost
laptimes={laptime}
fetchMoreData={fetchMoreData}
hasMore={hasMore}
/>
)}
</Box>

{/* Right section */}
<Box
flex="1"
overflowY="auto"
display={["none", "none", "block"]}
height="full"
>
<RightSideBar /> {/* right sidebar content*/}
</Box>
</Flex>
</>
)
};
);
};
25 changes: 17 additions & 8 deletions tracknow/web/src/components/Navbar/Navbar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import * as React from "react";
import {
Box,
Flex,
Expand All @@ -13,9 +12,11 @@ import {
MenuButton,
MenuDivider,
MenuItem,
MenuList
MenuList,
IconButton
} from "@chakra-ui/react";
import { AddIcon } from '@chakra-ui/icons'
import { AddIcon } from '@chakra-ui/icons';
import { FiMenu } from "react-icons/fi";
import { Link as ReactRouterLink } from 'react-router-dom';
import { identityProfile } from "../../Types";
import useMiscFunctions from "../../misc/miscFunctions";
Expand Down Expand Up @@ -67,7 +68,7 @@ export const Navbar = () => (
);


export const NavbarLoggedIn = ({ name, pp }: identityProfile) => {
export const NavbarLoggedIn = ({ name, pp, onOpen }: identityProfile) => {
const { handleLogout } = useMiscFunctions();
return (
<Box
Expand All @@ -83,13 +84,21 @@ export const NavbarLoggedIn = ({ name, pp }: identityProfile) => {
borderColor={useColorModeValue("#323536", "white")}
>
<Flex h={10} alignItems={"center"} justifyContent={'space-between'}>
<Box>
<Link as={ReactRouterLink} to="/home" variant={'navbarLink'}>
<IconButton
icon={<FiMenu />}
aria-label="Open Menu"
variant="ghost"
onClick={onOpen}
display={{ base: "flex", md: "none" }}
/>
<Flex alignItems={"center"} justifyContent={{ base: "center", md: "flex-start" }} marginLeft={{ base: 8, md: 0 }}>
<Link as={ReactRouterLink} to="/home" variant={"navbarLink"}>
<Text fontSize="xl" as="b">
tracknow
</Text>
</Link>
</Box>
</Flex>


<Flex alignItems={"center"}>
<Stack direction={"row"} spacing={1}>
Expand All @@ -99,7 +108,7 @@ export const NavbarLoggedIn = ({ name, pp }: identityProfile) => {
as={ReactRouterLink}
to={`/user/${name}/create-moments`}
leftIcon={<AddIcon />}>
Create
<Text display={{ base: "none", md: "inline" }}>Create</Text>
</Button>
<Menu>
<MenuButton
Expand Down
Loading
Loading