Skip to content

Commit

Permalink
Merge pull request #7 from leslieyip02/add-navbar
Browse files Browse the repository at this point in the history
Add navigation bar
  • Loading branch information
Respirayson authored Jan 24, 2024
2 parents d382e27 + c672b90 commit d65b12b
Show file tree
Hide file tree
Showing 19 changed files with 197 additions and 92 deletions.
2 changes: 2 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ module.exports = {
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist'],
parser: '@typescript-eslint/parser',
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
settings: { react: { version: '18.2' } },
plugins: [
Expand Down
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<html lang='en'>
<head>
<meta charset='UTF-8'>
<link rel='icon' type='image/svg+xml' href='/vite.svg'>
<link rel='icon' type='image/png' href='/comclub_logo.png'>
<meta name='viewport' content='width=device-width, initial-scale=1.0'>
<title>Vite + React</title>
<title>NUS Students' Computing Club</title>
</head>
<body>
<div id='root'></div>
Expand Down
9 changes: 9 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 @@ -12,6 +12,7 @@
"dependencies": {
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-icons": "^5.0.1",
"react-router-dom": "^6.21.1"
},
"devDependencies": {
Expand Down
3 changes: 0 additions & 3 deletions public/close.svg

This file was deleted.

Binary file added public/comclub_logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 0 additions & 3 deletions public/menu.svg

This file was deleted.

1 change: 0 additions & 1 deletion public/vite.svg

This file was deleted.

4 changes: 2 additions & 2 deletions src/App.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#root {
/* #root {
max-width: 1280px;
margin: 0 auto;
padding: 2rem;
text-align: center;
}
} */

.logo {
height: 6em;
Expand Down
82 changes: 5 additions & 77 deletions src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,87 +1,15 @@
import { useState } from 'react';
import './App.css';
import { Routes, Route, Link } from 'react-router-dom';
import menu from '/menu.svg';
import close from '/close.svg';
import { Routes, Route } from 'react-router-dom';
import { Home } from './pages';
import NavigationBar from './layout/NavigationBar';
import './App.css';

function App() {
const [toggle, setToggle] = useState(false);

return (
<>
{/* Header */}
<header>
{/* Navigation bar */}
<div className='w-full flex justify-between items-center'>
{/* Logo */}
<div className='text-white font-bold text-2xl'>
<Link to='/'>
<h1>NUSComputing</h1>
</Link>
</div>

{/* Navigation Links */}
<div className={`
relativez-20
text-white
md:flex
hidden
list-none
flex-row
justify-between
items-center
flex-initial
text-xl
`}>
<Link to='' className='mx-6 hover:scale-[1.1]'>
Foo
</Link>
<Link to='' className='mx-6 hover:scale-[1.1]'>
Foo
</Link>
<Link to='' className='mx-6 hover:scale-[1.1]'>
Bar
</Link>
</div>

{/* Mobile Navigation */}
<div className='md:hidden flex flex-1 items-end justify-end'>
<img
src={toggle ? close : menu}
alt='menu'
className='w-[28px] h-[28px] object-contain cursor-pointer'
onClick={() => setToggle(!toggle)}
/>
<div className={`
${!toggle ? 'hidden' : 'flex'}
p-6 mx-4 my-2 top-20 right-0 absolute z-20 rounded-xl`
}>
<div className={`
flex
justify-end
items-centerflex-1
flex-col
gap-4
text-white
`}>
<Link to='' className='mx-6 hover:scale-[1.1]'>
Foo
</Link>
<Link to='' className='mx-6 hover:scale-[1.1]'>
Foo
</Link>
<Link to='' className='mx-6 hover:scale-[1.1]'>
Bar
</Link>
</div>
</div>
</div>
</div>
</header>
<NavigationBar />

{/* Main content */}
<main className='w-full min-h-[100vh] overflow-hidden'>
<main className='w-full min-h-[100vh]'>
<Routes>
<Route path='/' element={<Home />} />
</Routes>
Expand Down
1 change: 0 additions & 1 deletion src/assets/react.svg

This file was deleted.

5 changes: 3 additions & 2 deletions src/index.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@import url('https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap');
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:[email protected]&family=Lexend&family=Quicksand&display=swap');

@tailwind base;
@tailwind components;
Expand All @@ -7,8 +8,8 @@

html, body {
font-family: 'Montserrat', sans-serif;
background-color: #4a69bd;
color: #ffffff;
/* background-color: #4a69bd; */
/* color: #ffffff; */
}

a {
Expand Down
13 changes: 13 additions & 0 deletions src/layout/NavigationBar.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.navigation-bar {
@apply
fixed
flex
items-center
justify-between
w-full
px-8
md:px-20
py-4
bg-white
;
}
18 changes: 18 additions & 0 deletions src/layout/NavigationBar.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Link } from 'react-router-dom';
import NavigationMenu from './NavigationMenu';
import './NavigationBar.css';

function NavigationBar() {
return (
<header className='w-full h-20'>
<div className='navigation-bar'>
<Link to='/'>
<img src='comclub_logo.png' className='h-12 p-2'></img>
</Link>
<NavigationMenu />
</div>
</header>
);
}

export default NavigationBar;
38 changes: 38 additions & 0 deletions src/layout/NavigationMenu.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
.navigation-menu-container {
@apply
flex-initial
flex-row
space-x-8
justify-between
items-center
text-xl
hidden
md:block
;
}

.navigation-menu-icon {
@apply
object-contain
cursor-pointer
p-1
text-primary
hover:rounded-3xl
hover:bg-gray-100
;
}

.navigation-menu-dropdown {
@apply
absolute
top-12
right-0
flex
flex-col
rounded-md
ring-1
ring-outline/5
bg-white
shadow-lg
;
}
61 changes: 61 additions & 0 deletions src/layout/NavigationMenu.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { useState } from 'react';
import { IoMenu, IoClose } from 'react-icons/io5';
import NavigationMenuItem from './NavigationMenuItem';
import './NavigationMenu.css';

function NavigationMenu() {
const [isOpen, setIsOpen] = useState(false);

const navigationLinks = {
'Home': '/',
'About': '/about',
'Events': '/events',
'Resources': '/resources',
'Photos': '/photos',
};

return (
<>
<div className='navigation-menu-container'>
{
Object.entries(navigationLinks)
.map(([label, link], key) => {
return <NavigationMenuItem
label={label}
link={link}
key={key}
/>;
})
}
</div>

<div className='md:hidden relative'>
<div
className='navigation-menu-icon'
onClick={() => setIsOpen(!isOpen)}
>
{
!isOpen
? <IoMenu className='h-10 w-auto' />
: <IoClose className='h-10 w-auto' />
}
</div>
<div className={`navigation-menu-dropdown ${!isOpen ? 'hidden' : ''}`}>
{
Object.entries(navigationLinks)
.map(([label, link], key) => {
return <NavigationMenuItem
label={label}
link={link}
dropdown={true}
key={key}
/>;
})
}
</div>
</div>
</>
);
}

export default NavigationMenu;
13 changes: 13 additions & 0 deletions src/layout/NavigationMenuItem.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.navigation-menu-item {
@apply
relative
font-heading
p-4
md:px-0
text-black
hover:scale-[1.1]
hover:rounded-md
hover:bg-gray-100
md:hover:bg-transparent
;
}
25 changes: 25 additions & 0 deletions src/layout/NavigationMenuItem.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import React from 'react';
import { Link } from 'react-router-dom';
import './NavigationMenuItem.css';

interface NavigationMenuItemProps {
link: string;
label: string;
dropdown: boolean;
}

function NavigationMenuItem(props: NavigationMenuItemProps) {
return (
<Link
to={props.link}
className={`
navigation-menu-item
${props.dropdown ? 'p-4 hover:rounded-md hover:bg-gray-100' : ''}
`}
>
{props.label}
</Link>
);
}

export default NavigationMenuItem;
6 changes: 5 additions & 1 deletion tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ module.exports = {
theme: {
extend: {
colors: {
primary: '#4a69bd',
primary: '#365486',
outline: '#333333',
},
transitionTimingFunction: {
'out-flex': 'cubic-bezier(0.05, 0.6, 0.4, 0.9)',
Expand All @@ -15,6 +16,9 @@ module.exports = {
},
fontFamily: {
inter: ['Inter var', 'sans-serif'],
subheading: ['Quicksand', 'sans-serif'],
heading: ['"DM Sans"', 'sans-serif'],
body: ['Lexend', 'sans-serif'],
},
boxShadow: {
card: `
Expand Down

0 comments on commit d65b12b

Please sign in to comment.