diff --git a/components/DesktopNav.tsx b/components/DesktopNav.tsx index 12b2b589c..2ef2e580d 100644 --- a/components/DesktopNav.tsx +++ b/components/DesktopNav.tsx @@ -2,7 +2,6 @@ import { useTranslation } from "next-i18next" import React from "react" import { SignInWithButton, signOutAndRedirectToHome, useAuth } from "./auth" import { Container, Dropdown, Nav, NavDropdown } from "./bootstrap" -import { useProfile } from "./db" import { Avatar, @@ -25,9 +24,6 @@ export const DesktopNav: React.FC> = () => { const { authenticated } = useAuth() const { t } = useTranslation(["common", "auth"]) - const result = useProfile() - let isOrg = result?.profile?.role === "organization" - return ( @@ -81,7 +77,7 @@ export const DesktopNav: React.FC> = () => {
- + diff --git a/components/MobileNav.tsx b/components/MobileNav.tsx index 06b4ea341..96fc32cf7 100644 --- a/components/MobileNav.tsx +++ b/components/MobileNav.tsx @@ -1,8 +1,9 @@ import { useTranslation } from "next-i18next" -import React, { FC, useState } from "react" +import React, { useState } from "react" +import Image from "react-bootstrap/Image" +import styled from "styled-components" import { SignInWithButton, signOutAndRedirectToHome, useAuth } from "./auth" -import { Container, Nav, Navbar, NavDropdown } from "./bootstrap" -import { useProfile } from "./db" +import { Col, Nav, Navbar, NavDropdown } from "./bootstrap" import { Avatar, NavbarLinkBills, @@ -20,122 +21,132 @@ import { NavbarLinkWhyUse } from "./NavbarComponents" -const NavBarBoxContainer: FC< - React.PropsWithChildren<{ className?: string }> -> = ({ children, className }) => { - return ( -
- {children} -
- ) -} +export const MobileNav: React.FC> = () => { + const BlackCollapse = styled(() => { + return ( + + {/* while MAPLE is trying to do away with inline styling, * + * both styled-components and bootstrap classes have been * + * ignoring height properties for some reason */} +
+ {whichMenu == "site" ? : } +
+
+ ) + })` + .bg-black { + background-color: black; + } + ` -const NavBarBox: FC> = ({ - children, - className -}) => { - return ( -
- {children} -
- ) -} + const ProfileLinks = () => { + return ( + + ) + } + + const SiteLinks = () => { + return ( + + ) + } -export const MobileNav: React.FC> = () => { const { authenticated } = useAuth() const [isExpanded, setIsExpanded] = useState(false) + const [whichMenu, setWhichMenu] = useState("site") const { t } = useTranslation(["common", "auth"]) - const toggleNav = () => setIsExpanded(!isExpanded) - const closeNav = () => setIsExpanded(false) + const toggleSite = () => { + if (isExpanded && whichMenu == "profile") { + setWhichMenu("site") + } else { + setWhichMenu("site") + setIsExpanded(!isExpanded) + } + } + + const toggleAvatar = () => { + if (isExpanded && whichMenu == "site") { + setWhichMenu("profile") + } else { + setWhichMenu("profile") + setIsExpanded(!isExpanded) + } + } - const result = useProfile() - let isOrg = result?.profile?.role === "organization" + const closeNav = () => setIsExpanded(false) return ( - - - - - - - - - - - - - - - - - - {authenticated ? ( - <> - - - - - - - - - + + + {isExpanded && whichMenu == "site" ? ( + x + ) : ( + + )} + + + + + + + {authenticated ? ( + + + {isExpanded && whichMenu == "profile" ? ( + x ) : ( - + )} - - - - + + + ) : ( + + )} + + + ) } diff --git a/components/NavbarComponents.tsx b/components/NavbarComponents.tsx index 8740033b3..12485b4e1 100644 --- a/components/NavbarComponents.tsx +++ b/components/NavbarComponents.tsx @@ -3,9 +3,13 @@ import Image from "react-bootstrap/Image" import { useMediaQuery } from "usehooks-ts" import { useAuth } from "./auth" import { Nav, NavDropdown } from "./bootstrap" +import { useProfile } from "./db" import { NavLink } from "./Navlink" -export const Avatar = ({ isOrg }: { isOrg: boolean }) => { +export const Avatar = () => { + const result = useProfile() + let isOrg = result?.profile?.role === "organization" + return ( <> {isOrg ? ( @@ -134,9 +138,10 @@ export const NavbarLinkGoals: React.FC< export const NavbarLinkLogo: React.FC< React.PropsWithChildren<{ + handleClick?: any other?: any }> -> = ({ other }) => { +> = ({ handleClick, other }) => { const isMobile = useMediaQuery("(max-width: 768px)") const { t } = useTranslation(["common", "auth"]) return ( @@ -144,6 +149,7 @@ export const NavbarLinkLogo: React.FC< className={ isMobile ? "" : "align-items-center justify-content-start me-3" } + onClick={handleClick} > + +