-
-
Notifications
You must be signed in to change notification settings - Fork 109
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
Navbar mobile refactored design #1568
Merged
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6287291
basic layout
mertbagt 6a5955b
set up shared collapse menu
mertbagt 2d40fbf
added x's for open menus
mertbagt 7864744
100vh
mertbagt c1984cd
clean up
mertbagt f8cabec
clean up
mertbagt 00c2132
close dropdowns when logo is clicked
mertbagt File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
clean up
- Loading branch information
commit c1984cd6f2c79bfadde3e063219324115b73d4f9
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
import { useTranslation } from "next-i18next" | ||
import React, { FC, 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 { Col, Nav, Navbar, NavDropdown } from "./bootstrap" | ||
import { useProfile } from "./db" | ||
import { | ||
Avatar, | ||
|
@@ -20,37 +22,87 @@ import { | |
NavbarLinkWhyUse | ||
} from "./NavbarComponents" | ||
|
||
const NavBarBoxContainer: FC< | ||
React.PropsWithChildren<{ className?: string }> | ||
> = ({ children, className }) => { | ||
return ( | ||
<div | ||
className={`d-flex flex-row align-items-start justify-content-between w-100`} | ||
> | ||
{children} | ||
</div> | ||
) | ||
} | ||
export const MobileNav: React.FC<React.PropsWithChildren<unknown>> = () => { | ||
const BlackCollapse = styled(() => { | ||
return ( | ||
<Navbar.Collapse id="basic-navbar-nav" className="bg-black mt-2 ps-4"> | ||
{/* while MAPLE is trying to do away with inline styling * | ||
* both styled-components and bootstrap class have been * | ||
* ignoring height properties for some reason */} | ||
<div style={{ height: "100vh" }}> | ||
{whichMenu == "site" ? <SiteLinks /> : <ProfileLinks />} | ||
</div> | ||
</Navbar.Collapse> | ||
) | ||
})` | ||
.bg-black { | ||
background-color: black; | ||
} | ||
` | ||
|
||
const NavBarBox: FC<React.PropsWithChildren<{ className?: string }>> = ({ | ||
children, | ||
className | ||
}) => { | ||
return ( | ||
<div | ||
className={`col d-flex justify-content-start align-items-center ${className}`} | ||
> | ||
{children} | ||
</div> | ||
) | ||
} | ||
const ProfileLinks = () => { | ||
return ( | ||
<Nav className="my-4 d-flex align-items-start"> | ||
<NavbarLinkViewProfile /> | ||
<NavbarLinkEditProfile | ||
handleClick={() => { | ||
closeNav() | ||
}} | ||
/> | ||
<NavbarLinkSignOut | ||
handleClick={() => { | ||
closeNav() | ||
void signOutAndRedirectToHome() | ||
}} | ||
/> | ||
</Nav> | ||
) | ||
} | ||
|
||
const SiteLinks = () => { | ||
return ( | ||
<Nav className="my-4"> | ||
<NavbarLinkBills handleClick={closeNav} /> | ||
<NavbarLinkTestimony handleClick={closeNav} /> | ||
<NavDropdown className={"navLink-primary"} title={t("about")}> | ||
<NavbarLinkGoals handleClick={closeNav} /> | ||
<NavbarLinkTeam handleClick={closeNav} /> | ||
<NavbarLinkSupport handleClick={closeNav} /> | ||
<NavbarLinkFAQ handleClick={closeNav} /> | ||
</NavDropdown> | ||
|
||
<NavDropdown className={"navLink-primary"} title={t("learn")}> | ||
<NavbarLinkEffective handleClick={closeNav} /> | ||
<NavbarLinkProcess handleClick={closeNav} /> | ||
<NavbarLinkWhyUse handleClick={closeNav} /> | ||
</NavDropdown> | ||
</Nav> | ||
) | ||
} | ||
|
||
export const MobileNav: React.FC<React.PropsWithChildren<unknown>> = () => { | ||
const { authenticated } = useAuth() | ||
const [isExpanded, setIsExpanded] = useState(false) | ||
const [whichMenu, setWhichMenu] = useState("site") | ||
const { t } = useTranslation(["common", "auth"]) | ||
|
||
const toggleNav = () => setIsExpanded(!isExpanded) | ||
const toggleSite = () => { | ||
if (isExpanded && whichMenu == "profile") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: for these toggles, if we're setting |
||
setWhichMenu("site") | ||
} else { | ||
setWhichMenu("site") | ||
setIsExpanded(!isExpanded) | ||
} | ||
} | ||
|
||
const toggleAvatar = () => { | ||
if (isExpanded && whichMenu == "site") { | ||
setWhichMenu("profile") | ||
} else { | ||
setWhichMenu("profile") | ||
setIsExpanded(!isExpanded) | ||
} | ||
} | ||
|
||
const closeNav = () => setIsExpanded(false) | ||
|
||
const result = useProfile() | ||
|
@@ -59,83 +111,50 @@ export const MobileNav: React.FC<React.PropsWithChildren<unknown>> = () => { | |
return ( | ||
<Navbar | ||
bg="secondary" | ||
variant="dark" | ||
sticky="top" | ||
expand={false} | ||
expanded={isExpanded} | ||
className={`w-100 ${isExpanded ? "pb-0" : ""}`} | ||
data-bs-theme="dark" | ||
expand="lg" | ||
expanded={isExpanded} | ||
> | ||
<Container fluid> | ||
<NavBarBoxContainer> | ||
<NavBarBox> | ||
<Navbar expand={false} expanded={isExpanded}> | ||
<Navbar.Brand> | ||
<Navbar.Toggle aria-controls="topnav" onClick={toggleNav} /> | ||
</Navbar.Brand> | ||
<Navbar.Collapse id="topnav"> | ||
<Nav className="me-auto"> | ||
<NavbarLinkBills handleClick={closeNav} /> | ||
<NavbarLinkTestimony handleClick={closeNav} /> | ||
|
||
<NavDropdown className={"navLink-primary"} title={t("about")}> | ||
<NavbarLinkGoals handleClick={closeNav} /> | ||
<NavbarLinkTeam handleClick={closeNav} /> | ||
<NavbarLinkSupport handleClick={closeNav} /> | ||
<NavbarLinkFAQ handleClick={closeNav} /> | ||
</NavDropdown> | ||
|
||
<NavDropdown className={"navLink-primary"} title={t("learn")}> | ||
<NavbarLinkEffective handleClick={closeNav} /> | ||
<NavbarLinkProcess handleClick={closeNav} /> | ||
<NavbarLinkWhyUse handleClick={closeNav} /> | ||
</NavDropdown> | ||
</Nav> | ||
</Navbar.Collapse> | ||
</Navbar> | ||
</NavBarBox> | ||
|
||
<Col className="ms-3 ps-2"> | ||
<Navbar.Brand onClick={toggleSite}> | ||
{isExpanded && whichMenu == "site" ? ( | ||
<Image | ||
src="/Union.svg" | ||
alt="x" | ||
width="35" | ||
height="35" | ||
className="ms-2" | ||
/> | ||
) : ( | ||
<Navbar.Toggle aria-controls="basic-navbar-nav" /> | ||
)} | ||
</Navbar.Brand> | ||
</Col> | ||
<Col> | ||
<div className="d-flex justify-content-center"> | ||
<NavbarLinkLogo /> | ||
</div> | ||
</Col> | ||
<Col className="d-flex justify-content-end me-3 pe-2"> | ||
{authenticated ? ( | ||
<> | ||
<Navbar.Brand onClick={toggleAvatar}> | ||
<Nav.Link className="p-0 text-white"> | ||
{isExpanded && whichMenu == "profile" ? ( | ||
<Image src="/Union.svg" alt="x" width="35" height="35" /> | ||
) : ( | ||
<Avatar isOrg={isOrg} /> | ||
)} | ||
</Nav.Link> | ||
</Navbar.Brand> | ||
</> | ||
) : ( | ||
<SignInWithButton /> | ||
)} | ||
</Col> | ||
|
||
<NavBarBox className={`justify-content-end`}> | ||
<Navbar | ||
expand={false} | ||
expanded={isExpanded} | ||
variant="dark" | ||
bg="secondary" | ||
collapseOnSelect={true} | ||
className="d-flex justify-content-end" | ||
> | ||
{authenticated ? ( | ||
<> | ||
<Navbar.Brand onClick={toggleNav}> | ||
<Nav.Link className="p-0 text-white"> | ||
<Avatar isOrg={isOrg} /> | ||
</Nav.Link> | ||
</Navbar.Brand> | ||
<Navbar.Collapse id="profile-nav"> | ||
<Nav className="me-4 d-flex align-items-end"> | ||
<NavbarLinkViewProfile /> | ||
<NavbarLinkEditProfile | ||
handleClick={() => { | ||
closeNav() | ||
}} | ||
/> | ||
<NavbarLinkSignOut | ||
handleClick={() => { | ||
closeNav() | ||
void signOutAndRedirectToHome() | ||
}} | ||
/> | ||
</Nav> | ||
</Navbar.Collapse> | ||
</> | ||
) : ( | ||
<SignInWithButton /> | ||
)} | ||
</Navbar> | ||
</NavBarBox> | ||
</NavBarBoxContainer> | ||
</Container> | ||
<BlackCollapse /> | ||
</Navbar> | ||
) | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Could this just use the bootstrap provided
bg-dark
and save some boilerplate? IMO we should probably start pushing designs to standardize on our bootstrap theme colors anyway.