|
1 |
| -import styles from "./navbar.module.scss"; |
| 1 | +import React, { useState } from 'react'; |
| 2 | +import { Drawer, Button } from 'antd'; |
| 3 | +import { MenuOutlined, CloseOutlined } from '@ant-design/icons'; |
| 4 | +import styles from './navbar.module.scss'; |
| 5 | + |
| 6 | +function Navbar({ children, title }: { children?: React.ReactNode; title?: string }) { |
| 7 | + const [isDrawerOpen, setIsDrawerOpen] = useState(false); |
| 8 | + |
| 9 | + const toggleDrawer = () => { |
| 10 | + setIsDrawerOpen(!isDrawerOpen); |
| 11 | + }; |
2 | 12 |
|
3 |
| -function Navbar({ children, title }: { children?: React.ReactNode, title?: string }) { |
4 | 13 | return (
|
5 | 14 | <nav className={styles.navbar}>
|
6 |
| - <a className={styles.logo} href="/frontend-mini-challenges/"> |
| 15 | + <div className={styles.logo}> |
7 | 16 | <img
|
8 | 17 | src="https://github.com/sadanandpai/frontend-mini-challenges/raw/main/shared/assets/logo.png"
|
9 | 18 | alt="logo"
|
| 19 | + className={styles.logoImage} |
10 | 20 | />
|
11 | 21 | <span>{title ?? 'Frontend Mini Challenges'}</span>
|
12 |
| - </a> |
13 |
| - |
| 22 | + </div> |
14 | 23 | <div className={styles.right}>
|
15 | 24 | <div className={styles.links}>{children}</div>
|
16 |
| - |
17 | 25 | <a
|
18 | 26 | href="https://github.com/sadanandpai/frontend-mini-challenges/"
|
19 | 27 | target="blank"
|
20 | 28 | className={styles.github}
|
21 | 29 | >
|
22 |
| - <svg |
23 |
| - xmlns="http://www.w3.org/2000/svg" |
24 |
| - width="24" |
25 |
| - height="24" |
26 |
| - viewBox="0 0 24 24" |
27 |
| - > |
| 30 | + <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24"> |
28 | 31 | <path
|
29 | 32 | fill="currentColor"
|
30 | 33 | d="M12 2A10 10 0 0 0 2 12c0 4.42 2.87 8.17 6.84 9.5c.5.08.66-.23.66-.5v-1.69c-2.77.6-3.36-1.34-3.36-1.34c-.46-1.16-1.11-1.47-1.11-1.47c-.91-.62.07-.6.07-.6c1 .07 1.53 1.03 1.53 1.03c.87 1.52 2.34 1.07 2.91.83c.09-.65.35-1.09.63-1.34c-2.22-.25-4.55-1.11-4.55-4.92c0-1.11.38-2 1.03-2.71c-.1-.25-.45-1.29.1-2.64c0 0 .84-.27 2.75 1.02c.79-.22 1.65-.33 2.5-.33c.85 0 1.71.11 2.5.33c1.91-1.29 2.75-1.02 2.75-1.02c.55 1.35.2 2.39.1 2.64c.65.71 1.03 1.6 1.03 2.71c0 3.82-2.34 4.66-4.57 4.91c.36.31.69.92.69 1.85V21c0 .27.16.59.67.5C19.14 20.16 22 16.42 22 12A10 10 0 0 0 12 2Z"
|
31 | 34 | />
|
32 | 35 | </svg>
|
33 | 36 | </a>
|
34 | 37 | </div>
|
| 38 | + <div className={styles.hamburger}> |
| 39 | + <Button type="text" icon={<MenuOutlined />} onClick={toggleDrawer} /> |
| 40 | + </div> |
| 41 | + |
| 42 | + <Drawer |
| 43 | + title="Menu" |
| 44 | + placement="right" |
| 45 | + closable={true} |
| 46 | + onClose={toggleDrawer} |
| 47 | + visible={isDrawerOpen} |
| 48 | + width="50%" |
| 49 | + > |
| 50 | + <div className={styles.drawerContent}> |
| 51 | + <ul className={styles.drawerList}> |
| 52 | + {React.Children.map(children, (child, index) => ( |
| 53 | + <li key={index} className={styles.drawerListItem}> |
| 54 | + {child} |
| 55 | + </li> |
| 56 | + ))} |
| 57 | + </ul> |
| 58 | + </div> |
| 59 | + </Drawer> |
35 | 60 | </nav>
|
36 | 61 | );
|
37 | 62 | }
|
|
0 commit comments