-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/navbar #35
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
Open
GladwynChua
wants to merge
12
commits into
main
Choose a base branch
from
feature/navbar
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+166
−0
Open
Feature/navbar #35
Changes from 5 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
490e490
feat(navbar): create nav bar
GladwynChua 3f13f9f
chore: code formatting and linting
GladwynChua 231e366
chore: added packages in workspace
GladwynChua be23889
chore: added prettier ignore file
GladwynChua 3d593f8
chore: fix workspace file
GladwynChua 9b25995
feat(navbar): changed hovering
GladwynChua d000938
feat(navbar): changed hovering
GladwynChua 5bfe166
feat(navbar): adjusted padding
GladwynChua 895397e
feat(navbar): address PR review comments
GladwynChua 4f832ac
chore: pass CI checks
GladwynChua 5db326b
fix: initialise navbar hidden state from scoll position on load
GladwynChua 3fb89df
fix: initialise navbar hidden state from scroll position on load
GladwynChua File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| **/*.yaml |
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| allowBuilds: | ||
| sharp: true | ||
| unrs-resolver: true | ||
|
|
||
| packages: | ||
| - src |
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,149 @@ | ||
| 'use client' | ||
|
|
||
| import { useEffect, useState } from 'react' | ||
| import Link from 'next/link' | ||
| import Image from 'next/image' | ||
|
|
||
| export default function Navbar() { | ||
| const [hidden, setHidden] = useState(false) | ||
| const [scrolled, setScrolled] = useState(false) | ||
|
GladwynChua marked this conversation as resolved.
Outdated
|
||
| const [menuOpen, setMenuOpen] = useState(false) | ||
|
|
||
| useEffect(() => { | ||
|
GladwynChua marked this conversation as resolved.
|
||
| let lastY = window.scrollY | ||
| const handleScroll = () => { | ||
| const y = window.scrollY | ||
| setHidden(y > lastY && y > 80) | ||
| setScrolled(y > 10) | ||
| lastY = y | ||
| } | ||
| window.addEventListener('scroll', handleScroll, { passive: true }) | ||
| return () => window.removeEventListener('scroll', handleScroll) | ||
| }, []) | ||
|
|
||
| useEffect(() => { | ||
| const handleResize = () => { | ||
| if (window.innerWidth >= 768) setMenuOpen(false) | ||
| } | ||
| window.addEventListener('resize', handleResize) | ||
| return () => window.removeEventListener('resize', handleResize) | ||
| }, []) | ||
|
|
||
| const links = [ | ||
| { label: 'Home', href: '/' }, | ||
| { label: 'About Us', href: '/about' }, | ||
| { label: 'Events', href: '/events' }, | ||
| { label: 'Sponsors', href: '/sponsors' }, | ||
| { label: 'Join SSA!', href: '/contact' }, | ||
| ] | ||
|
|
||
| return ( | ||
| <> | ||
| {/* ── NAVBAR ── */} | ||
| <nav | ||
| className={` | ||
| fixed top-0 left-0 right-0 z-50 | ||
|
GladwynChua marked this conversation as resolved.
Outdated
|
||
| h-[72px] bg-ssa-red | ||
| flex items-center | ||
| px-4 sm:px-6 lg:px-10 | ||
| transition-all duration-400 | ||
| ${hidden ? '-translate-y-full' : 'translate-y-0'} | ||
| ${scrolled ? 'shadow-lg' : ''} | ||
| `} | ||
| > | ||
| <div className="w-full flex items-center gap-4"> | ||
| {/* Logo */} | ||
| <Link href="/" className="shrink-0" aria-label="SSA Home"> | ||
| <Image | ||
| src="/mascot.png" | ||
| alt="SSA Mascot" | ||
| width={50} | ||
| height={50} | ||
| className="object-contain w-[40px] h-[40px] sm:w-[50px] sm:h-[50px]" | ||
| /> | ||
| </Link> | ||
|
|
||
| {/* Desktop links */} | ||
| <ul className="hidden md:flex items-center gap-1"> | ||
| {links.slice(0, 4).map(({ label, href }) => ( | ||
| <li key={href}> | ||
| <Link | ||
| href={href} | ||
| className="font-[family-name:var(--font-averia)] text-ssa-black font-bold text-xl px-4 py-2 rounded hover:bg-white/20 hover:text-ssa-yellow transition-colors whitespace-nowrap" | ||
| > | ||
| {label} | ||
| </Link> | ||
| </li> | ||
| ))} | ||
| </ul> | ||
|
|
||
| {/* Desktop Join SSA Button */} | ||
| <div className="hidden md:flex items-center ml-auto"> | ||
| <Link | ||
| href="/contact" | ||
| className="font-[family-name:var(--font-averia)] font-bold text-xl text-ssa-black bg-ssa-yellow-light px-5 py-2 rounded-full hover:bg-ssa-yellow transition-colors shrink-0" | ||
|
GladwynChua marked this conversation as resolved.
Outdated
|
||
| > | ||
| Join SSA! | ||
| </Link> | ||
| </div> | ||
|
|
||
| {/* Hamburger */} | ||
| <button | ||
|
GladwynChua marked this conversation as resolved.
|
||
| className="md:hidden ml-auto flex flex-col justify-center gap-[5px] w-10 h-10 p-1 shrink-0" | ||
| onClick={() => setMenuOpen(!menuOpen)} | ||
| aria-label="Toggle menu" | ||
| aria-expanded={menuOpen} | ||
| > | ||
|
GladwynChua marked this conversation as resolved.
|
||
| <span | ||
| className={`block h-[3px] w-6 bg-ssa-black rounded transition-all duration-300 ${menuOpen ? 'translate-y-[8px] rotate-45' : ''}`} | ||
| /> | ||
| <span | ||
| className={`block h-[3px] w-6 bg-ssa-black rounded transition-all duration-300 ${menuOpen ? 'opacity-0 scale-x-0' : ''}`} | ||
| /> | ||
| <span | ||
| className={`block h-[3px] w-6 bg-ssa-black rounded transition-all duration-300 ${menuOpen ? '-translate-y-[8px] -rotate-45' : ''}`} | ||
| /> | ||
| </button> | ||
| </div> | ||
| </nav> | ||
|
|
||
| {/* ── MOBILE MENU ── */} | ||
| <div | ||
|
GladwynChua marked this conversation as resolved.
|
||
| className={` | ||
| fixed top-[72px] left-0 right-0 z-40 | ||
| bg-ssa-red | ||
| border-t border-white/20 | ||
| transition-all duration-300 ease-in-out | ||
| md:hidden | ||
| ${ | ||
| menuOpen | ||
| ? 'opacity-100 translate-y-0 pointer-events-auto' | ||
| : 'opacity-0 -translate-y-2 pointer-events-none' | ||
| } | ||
| `} | ||
| > | ||
| <ul className="flex flex-col"> | ||
| {links.map(({ label, href }) => ( | ||
| <li key={href}> | ||
| <Link | ||
| href={href} | ||
| onClick={() => setMenuOpen(false)} | ||
| className="block font-[family-name:var(--font-averia)] font-bold text-lg text-ssa-black px-6 py-4 border-b border-white/10 hover:text-ssa-yellow hover:bg-white/10 transition-colors" | ||
| > | ||
| {label} | ||
| </Link> | ||
| </li> | ||
| ))} | ||
| </ul> | ||
| </div> | ||
|
|
||
| {/* Overlay */} | ||
| {menuOpen && ( | ||
| <div | ||
| className="fixed inset-0 z-30 md:hidden" | ||
| onClick={() => setMenuOpen(false)} | ||
| /> | ||
| )} | ||
| </> | ||
| ) | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.