Skip to content

[CW2-9] Add navbar / hamburger menu to mobile #8

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

Merged
merged 6 commits into from
Jun 4, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions components/Hamburger.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import React from 'react';
import { AnimatePresence, motion, useCycle } from 'framer-motion';
import Link from 'next/link';

export default function Hamburger() {
const [isOpen, toggleOpen] = useCycle(false, true);

return (
<button
onClick={() => {
toggleOpen();
}}
className="focus:outline-none"
>
<svg
className="w-6 h-6"
fill="none"
stroke="currentColor"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
>
<path
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth={2}
d="M4 6h16M4 12h16m-7 6h7"
/>
</svg>
<AnimatePresence>
{isOpen && (
<motion.div
initial={{ opacity: 0, y: -10 }}
animate={{ opacity: 1, y: 0 }}
exit={{ opacity: 0, y: -10 }}
transition={{ duration: 0.2 }}
className="absolute top-16 right-0 bg-[#3977F9] p-4 shadow-lg w-40 rounded-2xl"
style={{ height: '85vh' }}
>
<ul>
<li className="py-2">
<Link href={'#about'}>About Us</Link>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should all be href={'about'}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now all the fancy CSS animation is gone. It should be functional now.

</li>
<li className="py-2">
<Link href={'#events'}>Events</Link>
</li>
<li className="py-2">
<Link href={'/resources'}>Resources</Link>
</li>
<li className="py-2">
<Link href={'#sponsors'}>Sponsors</Link>
</li>
</ul>
</motion.div>
)}
</AnimatePresence>
</button>
);
}
6 changes: 5 additions & 1 deletion components/Navbar.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Image from 'next/image';
import Link from 'next/link';
import { useEffect, useState } from 'react';
import Hamburger from './Hamburger';

const Navbar = () => {
const [path, setPath] = useState<string>('');
Expand Down Expand Up @@ -28,7 +29,7 @@ const Navbar = () => {
<p className="text-[0.6rem] text-[#C4C5C8]">01</p>
<div>{'//'} about us</div>
</Link>
<Link href="events">
<Link href="#events">
<p className="text-[0.6rem] text-[#C4C5C8]">02</p>
<div>{'//'} events</div>
</Link>
Expand All @@ -41,6 +42,9 @@ const Navbar = () => {
<div>{'//'} sponsors</div>
</Link>
</div>
<div className="md:hidden xl:hidden lg:hidden text-right font-bold block">
<Hamburger />
</div>
</div>
</nav>
);
Expand Down
5 changes: 4 additions & 1 deletion components/Sponsors/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@
'xl:p-16 p-10 flex justify-center items-center xl:col-span-3 sm:col-span-5 col-span-10 xl:row-start-2 xl:row-end-3 sm:row-start-4 sm:row-end-5 sm:h-auto h-36';

return (
<section className="flex flex-col min-h-screen py-8 xl:px-24 sm:px-10 px-8 relative mt-20">
<section
className="flex flex-col min-h-screen py-8 xl:px-24 sm:px-10 px-8 relative mt-20"
id="sponsors"
>
<div className="text-center">
<p className="text-[#3977F8] font-game text-xl">04</p>
<h2 className="font-bold text-6xl">SUPPORT CSESOC</h2>
Expand All @@ -33,24 +36,24 @@
</div>
</div>
<div className={`${firstRowBoxesStyling} bg-[rgba(0, 71, 255, 0.33)]`}>
<img src="assets/atlassian_logo.svg" alt="Atlassian logo" />

Check warning on line 39 in components/Sponsors/index.tsx

View workflow job for this annotation

GitHub Actions / build

Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element
</div>
<div className={`${firstRowBoxesStyling} bg-[rgba(82, 130, 255, 0.47)]`}>
<img src="assets/google_logo.svg" alt="Google logo" />

Check warning on line 42 in components/Sponsors/index.tsx

View workflow job for this annotation

GitHub Actions / build

Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element
</div>
<div className={`${secondRowBoxesStyling} bg-[rgba(48, 93, 255, 0.2)]`}>
<img src="assets/freelancer_logo.svg" alt="Freelancer logo" />

Check warning on line 45 in components/Sponsors/index.tsx

View workflow job for this annotation

GitHub Actions / build

Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element
</div>
<div className={`${secondRowBoxesStyling} bg-[rgba(122, 137, 236, 0.27)]`}>
<img src="assets/microsoft_logo.svg" alt="Microsoft logo" />

Check warning on line 48 in components/Sponsors/index.tsx

View workflow job for this annotation

GitHub Actions / build

Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element
</div>
</div>
</div>
<div className="sm:flex justify-between">
<div className="flex items-center">
<img src="assets/csesoc_logo_white.svg" alt="CSESoc Logo" />

Check warning on line 54 in components/Sponsors/index.tsx

View workflow job for this annotation

GitHub Actions / build

Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element
<Link href="/flag/ollie_is_hiding.png" target="_blank" className="sm:hidden block">
<img

Check warning on line 56 in components/Sponsors/index.tsx

View workflow job for this annotation

GitHub Actions / build

Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element
src="/flag/ollie_is_hiding.png"
alt="Ollie"
draggable="false"
Expand All @@ -59,7 +62,7 @@
className="ml-10"
/>
</Link>
<img

Check warning on line 65 in components/Sponsors/index.tsx

View workflow job for this annotation

GitHub Actions / build

Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element
src="/flag/ollie_is_hiding.png"
alt="Ollie"
draggable="false"
Expand All @@ -73,7 +76,7 @@
<p>© 2021 — CSESoc UNSW</p>
</div>
</div>
<img

Check warning on line 79 in components/Sponsors/index.tsx

View workflow job for this annotation

GitHub Actions / build

Using `<img>` could result in slower LCP and higher bandwidth. Consider using `<Image />` from `next/image` to automatically optimize images. This may incur additional usage or cost from your provider. See: https://nextjs.org/docs/messages/no-img-element
src="assets/sponsors_backdrop.svg"
alt="Sponsors backdrop"
className="absolute bottom-0 left-0 w-screen -z-10"
Expand Down
40 changes: 40 additions & 0 deletions components/styles.css
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this? I think try to keep consistent to tailwind (for better or for worse)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah sorry, the animation css I got from somewhere else. I'll try and make it "proper" by Thursday!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay committed

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
body {
background-color: #1a0554;
font-family: "Roboto", sans-serif;
}

main {
display: flex;
}

aside {
background-color: #c4a8ff;
width: 18.75rem;
height: 100vh;
}

.container {
margin: 4.5rem 1.4rem;
}

.btn-container {
position: fixed;
}

.container a {
color: #f9fafb;
text-decoration: none;
font-size: 1.75rem;
font-weight: 600;
display: block;
margin: 20px;
}

button {
cursor: pointer;
margin: 1.25rem;
border: none;
padding: 0.5rem 1rem;
background-color: #f9fafb;
}

33 changes: 33 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@types/react-dom": "18.2.7",
"autoprefixer": "10.4.15",
"eslint-config-next": "13.4.19",
"framer-motion": "^11.1.2",
"next": "13.4.19",
"postcss": "8.4.29",
"react": "18.2.0",
Expand Down
Loading