11import React , { useState , useEffect } from 'react' ;
22import { Link } from 'react-router-dom' ;
33import Fez from './Fez' ;
4+ import { FaBars , FaTimes } from 'react-icons/fa' ;
45
56const Navbar = ( ) => {
67 const [ isScrolled , setIsScrolled ] = useState ( false ) ;
8+ const [ isMenuOpen , setIsMenuOpen ] = useState ( false ) ;
79
810 useEffect ( ( ) => {
911 const handleScroll = ( ) => {
@@ -15,14 +17,18 @@ const Navbar = () => {
1517 } ;
1618 } , [ ] ) ;
1719
20+ const toggleMenu = ( ) => {
21+ setIsMenuOpen ( ! isMenuOpen ) ;
22+ } ;
23+
1824 return (
1925 < header className = { `backdrop-blur-sm sticky top-0 z-40 transition-colors border-b ${ isScrolled ? 'border-gray-700/50' : 'border-transparent' } ` } >
2026 < div className = "container mx-auto flex justify-between items-center p-4 text-white" >
2127 < Link to = "/" className = "flex items-center space-x-2" >
2228 < Fez />
2329 < span className = "text-2xl font-semibold tracking-tight" > fez< span className = "text-primary-400" > codex</ span > </ span >
2430 </ Link >
25- < div className = "flex items-center space-x-6" >
31+ < div className = "hidden md: flex items-center space-x-6" >
2632 < Link to = "/" className = "text-sm font-medium hover:text-gray-300 transition-colors" > Home</ Link >
2733 < Link to = "/about" className = "text-sm font-medium hover:text-gray-300 transition-colors" > About</ Link >
2834 < Link to = "/blog" className = "text-sm font-medium hover:text-gray-300 transition-colors" > Blog</ Link >
@@ -31,9 +37,27 @@ const Navbar = () => {
3137 Play Wordle
3238 </ a >
3339 </ div >
40+ < div className = "md:hidden" >
41+ < button onClick = { toggleMenu } className = "text-white focus:outline-none" >
42+ { isMenuOpen ? < FaTimes size = { 24 } /> : < FaBars size = { 24 } /> }
43+ </ button >
44+ </ div >
3445 </ div >
46+ { isMenuOpen && (
47+ < div className = "md:hidden bg-gray-900/90 backdrop-blur-sm" >
48+ < div className = "container mx-auto flex flex-col items-center space-y-4 p-4" >
49+ < Link to = "/" className = "text-white text-sm font-medium hover:text-gray-300 transition-colors" onClick = { toggleMenu } > Home</ Link >
50+ < Link to = "/about" className = "text-white text-sm font-medium hover:text-gray-300 transition-colors" onClick = { toggleMenu } > About</ Link >
51+ < Link to = "/blog" className = "text-white text-sm font-medium hover:text-gray-300 transition-colors" onClick = { toggleMenu } > Blog</ Link >
52+ < Link to = "/projects" className = "text-white text-sm font-medium hover:text-gray-300 transition-colors" onClick = { toggleMenu } > Projects</ Link >
53+ < a href = "https://www.nytimes.com/games/wordle/index.html" target = "_blank" rel = "noopener noreferrer" className = "bg-primary-500 hover:bg-primary-600 text-white font-bold py-2 px-4 rounded-full transition-colors" onClick = { toggleMenu } >
54+ Play Wordle
55+ </ a >
56+ </ div >
57+ </ div >
58+ ) }
3559 </ header >
3660 ) ;
3761} ;
3862
39- export default Navbar ;
63+ export default Navbar ;
0 commit comments