Skip to content
This repository was archived by the owner on Dec 26, 2023. It is now read-only.

Commit a86d601

Browse files
authored
Merge pull request #169 from theprojectcode/orlundos-branch
responsive navbar
2 parents defabb7 + 9c3a386 commit a86d601

File tree

3 files changed

+113
-32
lines changed

3 files changed

+113
-32
lines changed

frontend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"react": "^17.0.2",
2525
"react-confetti": "^6.0.1",
2626
"react-dom": "^17.0.2",
27+
"react-icons": "^4.3.1",
2728
"use-nft": "^0.10.1",
2829
"web-vitals": "^1.0.1",
2930
"web3": "^1.5.3",

frontend/src/components/Nav/index.tsx

Lines changed: 107 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,34 @@
11
import React from 'react';
2-
import { chakra, Flex, HStack } from '@chakra-ui/react';
2+
3+
import {
4+
chakra,
5+
Box,
6+
Flex,
7+
useColorModeValue,
8+
HStack,
9+
useDisclosure,
10+
VStack,
11+
IconButton,
12+
CloseButton,
13+
} from '@chakra-ui/react';
14+
import { AiOutlineMenu } from 'react-icons/ai';
15+
import Logo from '../Logo';
16+
import { IconGitHub } from '../Icons';
317
import Link from 'next/link';
418
import { useTranslation } from 'react-i18next';
5-
import { IconGitHub } from '../Icons';
6-
import Logo from '../Logo';
719

8-
function Nav() {
20+
export default function Nav() {
21+
const bg = useColorModeValue('white', 'gray.800');
22+
const mobileNav = useDisclosure();
923
const { t } = useTranslation();
1024

1125
return (
1226
<chakra.nav borderBottom="1px solid" borderColor="gray.200">
1327
<Flex
14-
justify="space-between"
15-
align="center"
28+
alignItems="center"
29+
justifyContent="space-between"
1630
mx="auto"
1731
maxW="7xl"
18-
minW="xl"
1932
py={3}
2033
px={5}
2134
>
@@ -25,42 +38,104 @@ function Nav() {
2538
<chakra.span
2639
fontWeight="bold"
2740
fontSize="sm"
28-
color="gray.600"
2941
transition="color 300ms ease-in-out"
3042
_hover={{ color: 'black' }}
3143
>
3244
{t('title')}
3345
</chakra.span>
3446
</HStack>
3547
</Link>
36-
<HStack spacing={{ base: 3, sm: 10 }}>
37-
<Link href="/" passHref>
38-
{t('home')}
39-
</Link>
40-
<Link href="/mint" passHref>
41-
{t('mintTokenText')}
42-
</Link>
43-
<Link href="/projects" passHref>
44-
{t('projects')}
45-
</Link>
46-
<chakra.a
47-
href="https://github.com/Developer-DAO/developer-dao"
48-
target="_blank"
49-
rel="noreferrer"
50-
title={t('daoGithubRepo')}
48+
<HStack display="flex" alignItems="center" spacing={1}>
49+
<HStack
50+
spacing={{ base: 3, sm: 10 }}
51+
display={{ base: 'none', md: 'inline-flex' }}
5152
>
52-
<IconGitHub
53-
h={7}
54-
w={7}
55-
opacity={0.6}
56-
transition="opacity 300ms ease-in-out"
57-
_hover={{ opacity: 1 }}
53+
<Link href="/" passHref>
54+
<a>{t('home')}</a>
55+
</Link>
56+
<Link href="/mint" passHref>
57+
<a>{t('mintTokenText')}</a>
58+
</Link>
59+
<Link href="/projects" passHref>
60+
<a>{t('projects')}</a>
61+
</Link>
62+
<chakra.a
63+
href="https://github.com/Developer-DAO/developer-dao"
64+
target="_blank"
65+
rel="noreferrer"
66+
title={t('daoGithubRepo')}
67+
>
68+
<IconGitHub
69+
h={7}
70+
w={7}
71+
opacity={0.6}
72+
transition="opacity 300ms ease-in-out"
73+
_hover={{ opacity: 1 }}
74+
/>
75+
</chakra.a>
76+
</HStack>
77+
78+
<Box display={{ base: 'inline-flex', md: 'none' }}>
79+
<IconButton
80+
display={{ base: 'flex', md: 'none' }}
81+
aria-label="Open menu"
82+
fontSize="20px"
83+
color={useColorModeValue('grey.800', 'inherit')}
84+
variant="ghost"
85+
icon={<AiOutlineMenu />}
86+
onClick={mobileNav.onOpen}
5887
/>
59-
</chakra.a>
88+
89+
<VStack
90+
pos="absolute"
91+
top={0}
92+
left={0}
93+
right={0}
94+
display={mobileNav.isOpen ? 'flex' : 'none'}
95+
flexDirection="column"
96+
pt={7}
97+
pb={7}
98+
m={0}
99+
bg={bg}
100+
spacing={3}
101+
rounded="sm"
102+
shadow="sm"
103+
>
104+
<CloseButton
105+
aria-label="Close menu"
106+
onClick={mobileNav.onClose}
107+
/>
108+
109+
<Link href="/" passHref>
110+
<a>{t('home')}</a>
111+
</Link>
112+
113+
<Link href="/mint" passHref>
114+
<a>{t('mintTokenText')}</a>
115+
</Link>
116+
117+
<Link href="/projects" passHref>
118+
<a>{t('projects')}</a>
119+
</Link>
120+
121+
<chakra.a
122+
href="https://github.com/Developer-DAO/developer-dao"
123+
target="_blank"
124+
rel="noreferrer"
125+
title={t('daoGithubRepo')}
126+
>
127+
<IconGitHub
128+
h={7}
129+
w={7}
130+
opacity={0.6}
131+
transition="opacity 300ms ease-in-out"
132+
_hover={{ opacity: 1 }}
133+
/>
134+
</chakra.a>
135+
</VStack>
136+
</Box>
60137
</HStack>
61138
</Flex>
62139
</chakra.nav>
63140
);
64141
}
65-
66-
export default Nav;

frontend/yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8495,6 +8495,11 @@ react-i18next@^11.8.13:
84958495
"@babel/runtime" "^7.14.5"
84968496
html-parse-stringify "^3.0.1"
84978497

8498+
react-icons@^4.3.1:
8499+
version "4.3.1"
8500+
resolved "https://registry.yarnpkg.com/react-icons/-/react-icons-4.3.1.tgz#2fa92aebbbc71f43d2db2ed1aed07361124e91ca"
8501+
integrity sha512-cB10MXLTs3gVuXimblAdI71jrJx8njrJZmNMEMC+sQu5B/BIOmlsAjskdqpn81y8UBVEGuHODd7/ci5DvoSzTQ==
8502+
84988503
[email protected], react-is@^17.0.1:
84998504
version "17.0.2"
85008505
resolved "https://registry.npmjs.org/react-is/-/react-is-17.0.2.tgz"

0 commit comments

Comments
 (0)