Skip to content

Commit

Permalink
Merge pull request #490 from starknet-id/feat/submenu-dropdown
Browse files Browse the repository at this point in the history
feat: submenu dropdown
  • Loading branch information
fricoben authored Nov 15, 2023
2 parents 18b4661 + 23efb7e commit 22119ff
Show file tree
Hide file tree
Showing 5 changed files with 224 additions and 4 deletions.
88 changes: 88 additions & 0 deletions components/UI/desktopNav.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import React, { FunctionComponent, MouseEvent, useEffect } from "react";
import styles from "../../styles/components/desktopNav.module.css";
import Link from "next/link";
import { FaDiscord, FaGithub, FaTwitter } from "react-icons/fa";
import theme from "../../styles/theme";

type DesktopNavProps = {
close: () => void;
};

const DesktopNav: FunctionComponent<DesktopNavProps> = ({ close }) => {
const handleClick = (e: MouseEvent) => {
e.stopPropagation();
};

// Close when clicking outside the nav
useEffect(() => {
const handleClickOutside: EventListener = (e) => {
const burger = document.getElementById("burger");
if (burger && !burger.contains(e.target as Node)) {
close();
}
};
// Bind the event listener
document.addEventListener("mousedown", handleClickOutside);
return () => {
// Unbind the event listener on clean up
document.removeEventListener("mousedown", handleClickOutside);
};
}, []);

return (
<nav onClick={handleClick} className={styles.navContainer}>
<div className={styles.columns}>
<div className={styles.column}>
<Link
href={process.env.NEXT_PUBLIC_STARKNET_ID as string}
target="_blank"
>
<li className={styles.burgerItem}>Website</li>
</Link>
<Link href="https://www.starknet.id/pdfs/Terms.pdf" target="_blank">
<li className={styles.burgerItem}>Term of use</li>
</Link>
<Link href="https://docs.starknet.id/" target="_blank">
<li className={styles.burgerItem}>Documentation</li>
</Link>
</div>
<div className={styles.column}>
<Link
href={`${
process.env.NEXT_PUBLIC_STARKNET_ID as string
}/affiliates/individual-program`}
target="_blank"
>
<li className={styles.burgerItem}>Affiliation</li>
</Link>
<Link
href="https://starknet.id/pdfs/PrivacyPolicy.pdf"
target="_blank"
>
<li className={styles.burgerItem}>Privacy policy</li>
</Link>
</div>
</div>
<hr className={styles.hr} />
<div className={styles.socials}>
<div className="rounded-full shadow-gray-400 p-3 cursor-pointer hover:scale-105 ease-in duration-300">
<Link href="https://twitter.com/Starknet_id" target="_blank">
<FaTwitter size={24} color={theme.palette.secondary.main} />
</Link>
</div>
<div className="rounded-full shadow-gray-400 p-3 cursor-pointer hover:scale-105 ease-in duration-300">
<Link href="https://discord.com/invite/8uS2Mgcsza" target="_blank">
<FaDiscord size={24} color={theme.palette.secondary.main} />
</Link>
</div>
<div className="rounded-full shadow-gray-400 p-3 cursor-pointer hover:scale-105 ease-in duration-300">
<Link href="https://github.com/starknet-id" target="_blank">
<FaGithub size={24} color={theme.palette.secondary.main} />
</Link>
</div>
</div>
</nav>
);
};

export default DesktopNav;
58 changes: 54 additions & 4 deletions components/UI/navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import React, {
useCallback,
} from "react";
import { AiOutlineClose, AiOutlineMenu } from "react-icons/ai";
import { FaDiscord, FaTwitter } from "react-icons/fa";
import { FaDiscord, FaGithub, FaTwitter } from "react-icons/fa";
import styles from "../../styles/components/navbar.module.css";
import Button from "./button";
import {
Expand All @@ -24,6 +24,7 @@ import ModalWallet from "./modalWallet";
import { constants } from "starknet";
import { useTheme } from "@mui/material/styles";
import ProfilFilledIcon from "./iconsComponents/icons/profilFilledIcon";
import DesktopNav from "./desktopNav";

const Navbar: FunctionComponent = () => {
const theme = useTheme();
Expand Down Expand Up @@ -144,6 +145,15 @@ const Navbar: FunctionComponent = () => {
{/* <Link href="/jointhetribe">
<li className={styles.menuItem}>Join the tribe</li>
</Link> */}
<div
onClick={handleNav}
className={styles.menuBurger}
aria-expanded={nav}
id="burger"
>
<AiOutlineMenu color={theme.palette.secondary.main} size={25} />
{nav ? <DesktopNav close={handleNav} /> : null}
</div>
<div className="text-beige mx-5">
<Button
onClick={
Expand Down Expand Up @@ -200,7 +210,7 @@ const Navbar: FunctionComponent = () => {
<div
className={
nav
? "fixed left-0 top-0 w-full sm:w-[60%] lg:w-[45%] h-screen bg-background px-5 ease-in duration-500 flex justify-between flex-col"
? "fixed left-0 top-0 w-full sm:w-[60%] lg:w-[45%] h-screen bg-background px-5 ease-in duration-500 flex justify-between flex-col overflow-auto"
: "fixed left-[-100%] top-0 p-10 ease-in h-screen flex justify-between flex-col"
}
>
Expand Down Expand Up @@ -247,6 +257,38 @@ const Navbar: FunctionComponent = () => {
Domains
</li>
</Link>
<Link
href={process.env.NEXT_PUBLIC_STARKNET_ID as string}
target="_blank"
>
<li
onClick={() => setNav(false)}
className={styles.menuItemSmall}
>
Website
</li>
</Link>
<Link href="https://docs.starknet.id/" target="_blank">
<li
onClick={() => setNav(false)}
className={styles.menuItemSmall}
>
Documentation
</li>
</Link>
<Link
href={`${
process.env.NEXT_PUBLIC_STARKNET_ID as string
}/affiliates/individual-program`}
target="_blank"
>
<li
onClick={() => setNav(false)}
className={styles.menuItemSmall}
>
Affiliation
</li>
</Link>
</ul>
</div>
</div>
Expand All @@ -258,15 +300,23 @@ const Navbar: FunctionComponent = () => {
</div>
<div className="flex">
<div className="rounded-full shadow-gray-400 p-3 cursor-pointer hover:scale-105 ease-in duration-300 mt-2">
<Link href="https://twitter.com/Starknet_id">
<Link href="https://twitter.com/Starknet_id" target="_blank">
<FaTwitter size={28} color={theme.palette.secondary.main} />
</Link>
</div>
<div className="rounded-full shadow-gray-400 p-3 cursor-pointer hover:scale-105 ease-in duration-300 mt-2">
<Link href="https://discord.com/invite/8uS2Mgcsza">
<Link
href="https://discord.com/invite/8uS2Mgcsza"
target="_blank"
>
<FaDiscord size={28} color={theme.palette.secondary.main} />
</Link>
</div>
<div className="rounded-full shadow-gray-400 p-3 cursor-pointer hover:scale-105 ease-in duration-300 mt-2">
<Link href="https://github.com/starknet-id" target="_blank">
<FaGithub size={28} color={theme.palette.secondary.main} />
</Link>
</div>
</div>
</div>
</div>
Expand Down
58 changes: 58 additions & 0 deletions styles/components/desktopNav.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
.navContainer {
position: absolute;
justify-content: space-between;
background-color: #fff;
right: 0;
top: 38px;
border-radius: 8px;
border: 1px solid var(--light-tertiary-300, #f5f0eb);
background: var(--background-light, #fffcf8);
/* Small Shadow */
box-shadow: 0px 2px 30px 0px rgba(0, 0, 0, 0.06);
display: inline-flex;
flex-direction: column;
align-items: flex-start;
width: 312px;
cursor: default;
}

.columns {
display: flex;
width: 100%;
}

.column {
width: 50%;
}

.burgerItem {
text-transform: none;
color: var(--dark-content, #454545);
/* Body/default/medium */
font-family: Poppins-Regular;
font-size: 16px;
font-style: normal;
font-weight: 500;
line-height: 20px; /* 125% */
display: flex;
padding: 16px;
gap: 10px;
}

.burgerItem:hover {
background-color: var(--light-tertiary);
}

.hr {
width: 100%;
height: 1px;
background-color: var(--light-tertiary);
}

.socials {
display: flex;
gap: 1rem;
align-items: center;
justify-content: center;
width: 100%;
}
22 changes: 22 additions & 0 deletions styles/components/navbar.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,28 @@
color: var(--secondary);
text-transform: underline;
transition: 0.3s ease-in-out;
position: relative;
}

.menuBurger {
margin-left: 2.5rem /* 40px */;
cursor: pointer;
position: relative;
}

.menuBurger[aria-expanded="true"]::before,
.menuBurger:hover::before {
content: "";
position: absolute;
top: 50%;
left: 50%;
width: 40px;
height: 40px;
transform: translate(-50%, -50%);
background-color: red;
z-index: -1;
border-radius: 100px;
background: var(--light-tertiary);
}

.menuItem:hover {
Expand Down
2 changes: 2 additions & 0 deletions styles/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@
--secondary: #402d28;
--secondary300: #eae0d5;
--tertiary: #bf9e7b;
--light-tertiary: #f5f0eb;
--background: #fff9f0;
--background-light: #fffcf8;
--dark-content: #454545;
--nimiq-ease: cubic-bezier(0.25, 0, 0, 1);
--small-shadow: 0px 2px 30px 0px rgba(0, 0, 0, 0.06);
--large-shadow: 0px 2px 30px 0px rgba(0, 0, 0, 0.1);
Expand Down

1 comment on commit 22119ff

@vercel
Copy link

@vercel vercel bot commented on 22119ff Nov 15, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.