"use client"; import { Icon } from "@iconify/react"; import dynamic from "next/dynamic"; import { Link, usePathname } from "@/i18n/routing"; import { useLocale, useTranslations } from "next-intl"; import { LanguageSwitcher } from "@/components/language-switcher"; import { useEffect, useState } from "react"; import { Button, ButtonIcon, ButtonLabel, Logo, Separator, } from "poyraz-ui/atoms"; import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger, Sheet, SheetClose, SheetContent, SheetTitle, SheetTrigger, Tabs, TabsList, TabsTrigger, Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, } from "poyraz-ui/molecules"; import { NavbarTopBar, NavbarTopBarSection } from "poyraz-ui/organisms"; import { useKeyboardShortcutLabel } from "@/lib/use-keyboard-shortcut-label"; import { getResumeHref, NAV_LINKS, SOCIAL_LINKS, TOP_ICON_LINKS } from "@/lib/links"; const SearchCommand = dynamic( () => import("@/components/search-command").then((mod) => mod.SearchCommand), { ssr: false }, ); const glassActionClassName = "!border-border/80 hover:!border-border focus-visible:!border-border data-[state=open]:!border-border"; const slowShineClassName = "[--poyraz-motion-duration-deliberate:1100ms]"; function getNavLinkClass(isActive: boolean) { return [ "inline-flex border-b-2 pb-1 text-sm transition-colors md:border-0 md:pb-0", isActive ? "border-red-600 text-foreground" : "border-transparent text-foreground/55 hover:text-foreground", ].join(" "); } type ThemeMode = "light" | "dark"; function applyTheme(theme: ThemeMode) { document.documentElement.dataset.poyrazTheme = theme; document.documentElement.style.colorScheme = theme; localStorage.setItem("poyraz-theme", theme); } function getInitialTheme(): ThemeMode { if (typeof window === "undefined") return "light"; const storedTheme = localStorage.getItem("poyraz-theme"); if (storedTheme === "dark" || storedTheme === "light") return storedTheme; return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light"; } function ThemeToggle() { const [theme, setTheme] = useState(getInitialTheme); const nextTheme = theme === "dark" ? "light" : "dark"; const label = theme === "dark" ? "Light mode" : "Dark mode"; useEffect(() => { applyTheme(theme); }, [theme]); return ( ); } export function SiteNavbar() { const pathname = usePathname(); const [searchOpen, setSearchOpen] = useState(false); const shortcut = useKeyboardShortcutLabel(); const t = useTranslations("Nav"); const locale = useLocale(); const isActiveLink = (href: string) => { if (href === "/") return pathname === "/"; return pathname === href || pathname.startsWith(`${href}/`); }; const activeTab = NAV_LINKS.find((item) => isActiveLink(item.href))?.id; const languageLabel = locale === "tr" ? "Switch to English" : "Türkçe'ye geç"; return (
{TOP_ICON_LINKS.map((item) => { const href = item.id === "cv" ? getResumeHref(locale) : item.href; const label = t.has(item.id) ? t(item.id) : item.label; return ( {label} ); })} {languageLabel} {locale === "tr" ? "Tema değiştir" : "Toggle theme"}
{NAV_LINKS.map((item, index) => (
{index > 0 && ( )} {t(item.id)}
))}
{t("socialLinks")} {SOCIAL_LINKS.map((item) => ( {item.label} ))}
{t("mobileMenu")}
{SOCIAL_LINKS.map((item) => ( {item.label} ))}
); }