-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
improve dir structure and fix imports
- Loading branch information
1 parent
54d36e8
commit afcb091
Showing
14 changed files
with
1,595 additions
and
1,600 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
/* eslint-disable jsx-a11y/anchor-is-valid */ | ||
import React, { useEffect, useRef } from 'react'; | ||
|
||
const Navbar = () => { | ||
useEffect(() => { | ||
const btns = document.getElementsByClassName('nav-item'); | ||
for (let i = 0; i < btns.length; i += 1) { | ||
btns[i].addEventListener('click', function handelNavLink() { | ||
const current = document.getElementsByClassName('active'); | ||
current[0].className = current[0].className.replace('active', 'nav-link'); | ||
// eslint-disable-next-line react/no-this-in-sfc | ||
this.children[0].className = 'active btn-sm px-3'; | ||
}); | ||
} | ||
}); | ||
const navRef = useRef(null); | ||
|
||
function toggleNav() { | ||
document.querySelector('.navbar-collapse').classList.toggle('show'); | ||
} | ||
window.onscroll = () => { | ||
if (window.scrollY > 0) { | ||
navRef.current.classList.add('navbar-shadow'); | ||
} else { | ||
navRef.current.classList.remove('navbar-shadow'); | ||
} | ||
if (window.scrollY > 500) { | ||
navRef.current.classList.remove('navbar-light'); | ||
navRef.current.classList.add('navbar-dark'); | ||
navRef.current.classList.add('navbar-shadow'); | ||
} else { | ||
navRef.current.classList.remove('navbar-dark'); | ||
navRef.current.classList.add('navbar-light'); | ||
navRef.current.classList.add('navbar-shadow'); | ||
} | ||
}; | ||
return ( | ||
<nav | ||
className="relative navbar navbar-expand-md fixed-top flex justify-between items-center py-6 z-10 navbar-light navbar-shadow" | ||
ref={navRef} | ||
> | ||
<div className="relative container px-4 mx-auto"> | ||
<a className="navbar-brand" href="#"> | ||
Turing Cup | ||
</a> | ||
<button | ||
className="navbar-toggler" | ||
onClick={toggleNav} | ||
type="button" | ||
data-bs-toggle="collapse" | ||
data-bs-target="#navbarCollapse" | ||
aria-controls="navbarCollapse" | ||
aria-expanded="false" | ||
aria-label="Toggle navigation" | ||
> | ||
<span className="navbar-toggler-icon" /> | ||
</button> | ||
<div className="collapse navbar-collapse" id="navbarCollapse"> | ||
<ul className="navbar-nav ml-auto mb-2 mb-md-0 align-items-center justify-content-end justify-content-md-between"> | ||
<li className="nav-item"> | ||
<a className="active btn-sm px-3" aria-current="page" href="#about"> | ||
About | ||
</a> | ||
</li> | ||
<li className="nav-item"> | ||
<a className="nav-link" aria-current="page" href="#schedule"> | ||
Schedule | ||
</a> | ||
</li> | ||
<li className="nav-item"> | ||
<a className="nav-link" aria-current="page" href="#registration"> | ||
Registration | ||
</a> | ||
</li> | ||
<li className="nav-item"> | ||
<a className="nav-link" aria-current="page" href="#faq"> | ||
FAQ | ||
</a> | ||
</li> | ||
<li className="nav-item"> | ||
<a className="nav-link" aria-current="page" href="#contact"> | ||
Contact | ||
</a> | ||
</li> | ||
</ul> | ||
</div> | ||
</div> | ||
</nav> | ||
); | ||
}; | ||
|
||
export default Navbar; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.