()
| 26 | import ThemeSwitcher from './ThemeSwitcher' |
| 27 | |
| 28 | const Header = () => { |
| 29 | const pathname = usePathname() |
| 30 | const [active, setActive] = useState(false) |
| 31 | |
| 32 | useEffect(() => { |
| 33 | setActive(false) |
| 34 | }, [pathname]) |
| 35 | |
| 36 | const IsActive = (str: string) => { |
| 37 | const lastPart = pathname.toLowerCase().split('/').pop() |
| 38 | const strPart = str.toLowerCase().split('/').pop() |
| 39 | return strPart === lastPart |
| 40 | } |
| 41 | return ( |
| 42 | <header |
| 43 | className={`fixed top-0 z-50 w-full border-b bg-white dark:border-metal-800 ${pathname === '/' ? 'border-b-metal-100 dark:border-b-metal-900 dark:bg-[#0D1015]' : 'border-b-transparent dark:border-b-transparent dark:bg-metal-900'}`}> |
| 44 | <div className="relative mx-auto max-w-7xl px-6 2xl:px-0"> |
| 45 | <nav className="flex items-center justify-between py-4"> |
| 46 | <div className="flex items-center space-x-28"> |
| 47 | <Link href="/" className="flex"> |
| 48 | <Image src={KeepLogo} alt="Keep React" width="130" height="53" className="block dark:hidden" /> |
| 49 | <Image src={KeepDarkLogo} alt="Keep React" width="130" height="53" className="hidden dark:block" /> |
| 50 | </Link> |
| 51 | <div className="hidden laptop:ml-auto laptop:flex laptop:items-center laptop:space-x-10"> |
| 52 | {navbarRoutes.map((nav) => ( |
| 53 | <Link |
| 54 | key={nav.id} |
| 55 | href={nav.href} |
| 56 | target={nav.redirect ? '_blank' : '_self'} |
| 57 | className={`text-body-4 font-medium text-metal-600 hover:text-primary-500 active:text-primary-500 dark:text-metal-300 dark:active:text-white ${nav.name === 'Documentation' && pathname.includes('/docs/') ? 'text-primary-500 dark:text-white' : ''} ${nav.name === 'Blog' && pathname === '/blog' ? 'text-primary-500 dark:text-white' : ''}`}> |
| 58 | {nav.name} |
| 59 | </Link> |
| 60 | ))} |
| 61 | </div> |
| 62 | </div> |
| 63 | <div className="flex items-center gap-3"> |
| 64 | <SearchBar /> |
| 65 | <Link |
| 66 | href="https://github.com/StaticMania/keep-react" |
| 67 | target="_blank" |
| 68 | className="rounded-lg border border-metal-100 bg-white p-2.5 transition-all duration-300 hover:bg-metal-25 dark:border-metal-800 dark:bg-metal-900 dark:hover:border-metal-600 dark:hover:bg-metal-900"> |
| 69 | <Image src="/images/icon/github.svg" height={22} width={22} alt="github" className="block dark:hidden" /> |
| 70 | <Image |
| 71 | src="/images/icon/github-dark.svg" |
| 72 | height={22} |
| 73 | width={22} |
| 74 | alt="github" |
| 75 | className="hidden dark:block" |
| 76 | /> |
| 77 | </Link> |
| 78 | <Link |
| 79 | href="https://discord.gg/fSxDJyvJmr" |
| 80 | target="_blank" |
| 81 | className="rounded-lg border border-metal-100 bg-white p-2.5 transition-all duration-300 hover:bg-metal-25 dark:border-metal-800 dark:bg-metal-900 dark:hover:border-metal-600 dark:hover:bg-metal-900"> |
| 82 | <Image src="/images/icon/discord.svg" height={22} width={22} alt="discord" /> |
| 83 | </Link> |
| 84 | <ThemeSwitcher /> |
| 85 | <button |
nothing calls this directly
no test coverage detected