-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Merge branch staging] Responsive Navbar
- Loading branch information
Showing
13 changed files
with
1,252 additions
and
720 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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 |
---|---|---|
|
@@ -30,3 +30,4 @@ export default function Navbar() { | |
</nav> | ||
); | ||
} | ||
|
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 |
---|---|---|
|
@@ -10,3 +10,4 @@ export default function NavbarLink({ name, onClick }: NavbarLinkProps) { | |
</li> | ||
); | ||
} | ||
|
Empty file.
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,25 @@ | ||
import { FaArrowRight } from "react-icons/fa"; | ||
import { NavLink } from "./Navbar"; | ||
import NavbarButton from "./NavbarButton"; | ||
import NavbarLink from "./NavbarLink"; | ||
|
||
type DesktopMenuProps = { | ||
navigate: (path: string) => void; | ||
navLinks: NavLink[]; | ||
}; | ||
|
||
const DesktopMenu: React.FC<DesktopMenuProps> = ({ navigate, navLinks }) => ( | ||
<div className="hidden lg:flex lg:flex-row lg:space-x-12 lg:items-center lg:mr-4 z-50"> | ||
{navLinks.map((link, index) => ( | ||
<NavbarLink key={index} name={link.name} onClick={() => navigate(link.path)} /> | ||
))} | ||
<NavbarButton onClick={() => console.log('Contact button clicked')}> | ||
<div className="flex flex-row space-x-2 text-white items-center justify-center"> | ||
<div className="font-fira-code text-sm">Blog</div> | ||
<FaArrowRight size={12} /> | ||
</div> | ||
</NavbarButton> | ||
</div> | ||
); | ||
|
||
export default DesktopMenu; |
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,35 @@ | ||
import { FaArrowRight } from "react-icons/fa"; | ||
import { NavLink } from "./Navbar"; | ||
import NavbarButton from "./NavbarButton"; | ||
import NavbarLink from "./NavbarLink"; | ||
|
||
type DropdownMenuProps = { | ||
terminalText: string; | ||
isCursorVisible: boolean; | ||
navigate: (path: string) => void; | ||
navLinks: NavLink[]; | ||
}; | ||
|
||
const DropdownMenu = ({ terminalText, isCursorVisible, navigate, navLinks }: DropdownMenuProps) => ( | ||
<div className="lg:hidden fixed top-0 left-0 w-full h-[480px] bg-gradient-to-b from-black to-[#1c1c1c] border-b-2 border-[#cdcdcd] bg-opacity-50"> | ||
<div className="flex flex-col items-center justify-center space-y-10 mt-32 text-white text-xl z-50"> | ||
{navLinks.map((link, index) => ( | ||
<NavbarLink key={index} name={link.name} onClick={() => navigate(link.path)} /> | ||
))} | ||
<NavbarButton onClick={() => console.log('Contact button clicked')}> | ||
<div className="flex flex-row space-x-2 text-white items-center justify-center"> | ||
<div className="font-fira-code text-xl">Blog</div> | ||
<FaArrowRight size={12} /> | ||
</div> | ||
</NavbarButton> | ||
</div> | ||
<div className="text-[#cdcdcd] absolute bottom-0 p-2"> | ||
<p className="font-fira-code text-sm"> | ||
basile@desktop:~# <span>{terminalText}</span> | ||
<span className="text-[7px]" style={{ opacity: isCursorVisible ? 0 : 1 }}>▄▄</span> | ||
</p> | ||
</div> | ||
</div> | ||
); | ||
|
||
export default DropdownMenu; |
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,88 @@ | ||
import Logo from '../Logo'; | ||
import NavbarButton from './NavbarButton'; | ||
import NavbarContent from './NavbarContent'; | ||
import { useNavigate } from "react-router-dom"; | ||
import { useEffect, useState } from "react"; | ||
import { IoMenu, IoClose } from "react-icons/io5"; | ||
import { useTypewriter } from "react-simple-typewriter"; | ||
import DesktopMenu from './DesktopMenu'; | ||
import DropdownMenu from './DropdownMenu'; | ||
|
||
// Définition des types pour les liens de navigation | ||
export type NavLink = { | ||
name: string; | ||
path: string; | ||
}; | ||
|
||
export default function Navbar() { | ||
const [isDropdownNavToggled, setDropdownNavToggled] = useState<boolean>(false); | ||
const [isCursorVisible, setCursorVisible] = useState<boolean>(true); | ||
const [isShortLogo, setIsShortLogo] = useState<boolean>(false); | ||
|
||
const navigate = useNavigate(); | ||
const [terminalText, _] = useTypewriter({ | ||
words: [":(){ :|:& };:", "sudo rm -rf /*", "aptitude -v moo", "alias please='sudo'", "make love not war", "cowsay 'Moew!'", "echo 'don't nod' | rev"], | ||
loop: 0, | ||
typeSpeed: 70, | ||
deleteSpeed: 50, | ||
delaySpeed: 495 | ||
}); | ||
|
||
// Liste des liens de navigation avec un typage clair | ||
const navLinks: NavLink[] = [ | ||
{ name: "> mes-projets", path: "/" }, | ||
{ name: "> mes-compétences", path: "/" }, | ||
{ name: "> mes-expériences", path: "/" } | ||
]; | ||
|
||
const handleDropdownNav = () => { | ||
setDropdownNavToggled(!isDropdownNavToggled); | ||
}; | ||
|
||
const handleResize = () => { | ||
setIsShortLogo(window.innerWidth <= 1024); | ||
}; | ||
|
||
useEffect(() => { | ||
handleResize(); | ||
window.addEventListener('resize', handleResize); | ||
return () => window.removeEventListener('resize', handleResize); | ||
}, []); | ||
|
||
useEffect(() => { | ||
if (isDropdownNavToggled) { | ||
const interval = setInterval(() => setCursorVisible(prev => !prev), 500); | ||
return () => clearInterval(interval); | ||
} | ||
}, [isDropdownNavToggled]); | ||
|
||
return ( | ||
<nav className="flex flex-row items-center justify-between p-4"> | ||
<div className="z-50"> | ||
<Logo onClick={() => navigate('/')} scale="90" short={isShortLogo} /> | ||
</div> | ||
|
||
<NavbarContent> | ||
{/* Menu pour mobile */} | ||
<div className="flex lg:hidden z-50"> | ||
<NavbarButton onClick={handleDropdownNav}> | ||
{isDropdownNavToggled ? <IoClose size={30} /> : <IoMenu size={30} />} | ||
</NavbarButton> | ||
</div> | ||
|
||
{/* Menu pour desktop */} | ||
<DesktopMenu navigate={navigate} navLinks={navLinks} /> | ||
</NavbarContent> | ||
|
||
{/* Dropdown menu pour mobile */} | ||
{isDropdownNavToggled && ( | ||
<DropdownMenu | ||
terminalText={terminalText} | ||
isCursorVisible={isCursorVisible} | ||
navigate={navigate} | ||
navLinks={navLinks} | ||
/> | ||
)} | ||
</nav> | ||
); | ||
} |
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
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,14 @@ | ||
interface NavbarLinkProps { | ||
name: string; | ||
onClick: () => void; | ||
} | ||
|
||
export default function NavbarLink({ name, onClick }: NavbarLinkProps) { | ||
return ( | ||
<div | ||
onClick={onClick} | ||
className="font-fira-code text-white cursor-pointer select-none"> | ||
{name} | ||
</div> | ||
); | ||
} |
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