Skip to content

Commit

Permalink
Mobile nav dropdown fixes and committee images (#302)
Browse files Browse the repository at this point in the history
* fixed navbar staying when link changes

* fix mobile nav dropdown push content

* also fix committee images not showing up on mobile
  • Loading branch information
firmianaw authored Sep 9, 2024
1 parent 64e60aa commit 0c1971e
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 55 deletions.
18 changes: 13 additions & 5 deletions src/sections/Navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Link from 'next/link';
import { useRouter } from 'next/router';

import NavbarMobile from './NavbarMobile';
// import {Navbar} from 'react-bootstrap';

import styles from '@/styles/sections/Navbar.module.css';

function NavLink({ href, label }) {
Expand All @@ -21,6 +21,8 @@ function NavLink({ href, label }) {

export default function WCSNavbar() {
const [isMenuOpen, setIsMenuOpen] = useState(false);
const router = useRouter();
const { pathname } = router;

const toggleMenu = () => {
setIsMenuOpen(!isMenuOpen);
Expand All @@ -41,6 +43,10 @@ export default function WCSNavbar() {
};
}, []);

useEffect(() => {
setIsMenuOpen(false);
}, [pathname]);

return (
<div className={styles.container}>
<Link className={styles.logo} href="/">
Expand All @@ -53,18 +59,15 @@ export default function WCSNavbar() {
<NavLink
href="https://points.illinoiswcs.org/"
label="points"
onClick={handleLinkClick}
/>
<NavLink href="/officers" label="officers" onClick={handleLinkClick} />
<NavLink
href="/committees"
label="committees"
onClick={handleLinkClick}
/>
<NavLink
href="/resources"
label="resources"
onClick={handleLinkClick}
/>
</div>

Expand All @@ -74,7 +77,12 @@ export default function WCSNavbar() {
<div className={`${styles.bar} ${isMenuOpen ? styles.open3 : ''}`} />
</button>

{isMenuOpen && <NavbarMobile />}
{isMenuOpen
&& (
<NavbarMobile
handleLinkClick={handleLinkClick}
/>
)}
</div>
);
}
64 changes: 27 additions & 37 deletions src/sections/NavbarMobile.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React, { useState } from 'react';

import Link from 'next/link';
import { useRouter } from 'next/router';

Expand All @@ -16,41 +14,33 @@ function NavLink({ href, label }) {
);
}

export default function NavbarMobile() {
const [isMenuOpen, setIsMenuOpen] = useState(true);

const handleLinkClick = () => {
setIsMenuOpen(false); // Close the dropdown menu when link is clicked
};

export default function NavbarMobile({ handleLinkClick }) {
return (
isMenuOpen && (
<div className={styles.hamburger}>
<NavLink
className={styles.burger}
href="https://points.illinoiswcs.org/"
label="points"
onClick={handleLinkClick}
/>
<NavLink
className={styles.burger}
href="/officers"
label="officers"
onClick={handleLinkClick}
/>
<NavLink
className={styles.burger}
href="/committees"
label="committees"
onClick={handleLinkClick}
/>
<NavLink
className={styles.burger}
href="/resources"
label="resources"
onClick={handleLinkClick}
/>
</div>
)
<div className={styles.hamburger}>
<NavLink
className={styles.burger}
href="https://points.illinoiswcs.org/"
label="points"
onClick={handleLinkClick}
/>
<NavLink
className={styles.burger}
href="/officers"
label="officers"
onClick={handleLinkClick}
/>
<NavLink
className={styles.burger}
href="/committees"
label="committees"
onClick={handleLinkClick}
/>
<NavLink
className={styles.burger}
href="/resources"
label="resources"
onClick={handleLinkClick}
/>
</div>
);
}
3 changes: 2 additions & 1 deletion src/styles/sections/CommitteesSection.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
.mobileImage {
display: none;
flex: 0;
height: auto;
}

@media (max-width: 875px) {
Expand Down Expand Up @@ -96,7 +97,7 @@

.window {
flex: 1;
width:;
width: auto;
}

.windowImage {
Expand Down
17 changes: 12 additions & 5 deletions src/styles/sections/Navbar.module.css
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
.container {
background-image: linear-gradient(
to bottom,
rgba(255, 143, 205, 1),
rgba(253, 176, 218, 1)
);
display: flex;
flex-direction: row;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: 2rem;
width: 100%;
float: top;
}

.logo {
Expand All @@ -22,6 +24,7 @@
gap: 4rem;
padding-right: 50px;
padding: 15px 25px 15px 25px;
position: relative;
}

.linksContainer h3:hover {
Expand All @@ -30,7 +33,7 @@
}

.hamburger {
display: none; /* Initially hidden */
display: none;
cursor: pointer;
padding: 15px 25px 15px 25px;
background-color: transparent;
Expand Down Expand Up @@ -59,20 +62,24 @@
}

.show {
display: flex; /* Show the links when menu is open */
display: flex;
}

@media (max-width: 1000px) {
.linksContainer {
display: none; /* Hide links in mobile view */
display: none;
position: absolute;
}

.hamburger {
display: block; /* Show hamburger menu */
display: block;
}
}

.navBarSticky {
position: static;
}

.activeLink {
text-decoration: underline;
}
Expand Down
9 changes: 2 additions & 7 deletions src/styles/sections/NavbarMobile.module.css
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
.hamburger {
position: absolute;
position: static;
width: 100%;
z-index: 1;
top: 76.66px;
background-image: linear-gradient(
rgba(253, 176, 218, 1),
rgba(255, 143, 205, 1)
);
padding-left: 30px;
padding-bottom: 10px;
padding-bottom: 20px;
}

0 comments on commit 0c1971e

Please sign in to comment.