|
| 1 | +import { Menu, X, Search } from 'lucide-react'; |
| 2 | +import { useState } from 'react'; |
| 3 | + |
| 4 | +export function Header() { |
| 5 | + const [isMenuOpen, setIsMenuOpen] = useState(false); |
| 6 | + |
| 7 | + return ( |
| 8 | + <header className="fixed top-0 left-0 right-0 z-50 bg-white/80 backdrop-blur-xl border-b border-gray-200/50"> |
| 9 | + <nav className="max-w-7xl mx-auto px-6 py-4"> |
| 10 | + <div className="flex items-center justify-between"> |
| 11 | + {/* Logo */} |
| 12 | + <div className="flex items-center"> |
| 13 | + <h1 className="text-xl tracking-tight">张伟的博客</h1> |
| 14 | + </div> |
| 15 | + |
| 16 | + {/* Desktop Navigation */} |
| 17 | + <div className="hidden md:flex items-center gap-8"> |
| 18 | + <a href="#" className="text-sm text-gray-600 hover:text-gray-900 transition-colors"> |
| 19 | + 首页 |
| 20 | + </a> |
| 21 | + <a href="#" className="text-sm text-gray-600 hover:text-gray-900 transition-colors"> |
| 22 | + 文章 |
| 23 | + </a> |
| 24 | + <a href="#" className="text-sm text-gray-600 hover:text-gray-900 transition-colors"> |
| 25 | + 关于 |
| 26 | + </a> |
| 27 | + <a href="#" className="text-sm text-gray-600 hover:text-gray-900 transition-colors"> |
| 28 | + 联系 |
| 29 | + </a> |
| 30 | + <button className="p-2 hover:bg-gray-100 rounded-full transition-colors"> |
| 31 | + <Search className="w-4 h-4 text-gray-600" /> |
| 32 | + </button> |
| 33 | + </div> |
| 34 | + |
| 35 | + {/* Mobile Menu Button */} |
| 36 | + <button |
| 37 | + onClick={() => setIsMenuOpen(!isMenuOpen)} |
| 38 | + className="md:hidden p-2 hover:bg-gray-100 rounded-full transition-colors" |
| 39 | + > |
| 40 | + {isMenuOpen ? ( |
| 41 | + <X className="w-5 h-5 text-gray-600" /> |
| 42 | + ) : ( |
| 43 | + <Menu className="w-5 h-5 text-gray-600" /> |
| 44 | + )} |
| 45 | + </button> |
| 46 | + </div> |
| 47 | + |
| 48 | + {/* Mobile Menu */} |
| 49 | + {isMenuOpen && ( |
| 50 | + <div className="md:hidden mt-4 pt-4 border-t border-gray-200"> |
| 51 | + <div className="flex flex-col gap-4"> |
| 52 | + <a href="#" className="text-sm text-gray-600 hover:text-gray-900 transition-colors"> |
| 53 | + 首页 |
| 54 | + </a> |
| 55 | + <a href="#" className="text-sm text-gray-600 hover:text-gray-900 transition-colors"> |
| 56 | + 文章 |
| 57 | + </a> |
| 58 | + <a href="#" className="text-sm text-gray-600 hover:text-gray-900 transition-colors"> |
| 59 | + 关于 |
| 60 | + </a> |
| 61 | + <a href="#" className="text-sm text-gray-600 hover:text-gray-900 transition-colors"> |
| 62 | + 联系 |
| 63 | + </a> |
| 64 | + </div> |
| 65 | + </div> |
| 66 | + )} |
| 67 | + </nav> |
| 68 | + </header> |
| 69 | + ); |
| 70 | +} |
0 commit comments