"use client"; import { motion, useReducedMotion } from "framer-motion"; import Image from "next/image"; import Link from "next/link"; import { usePathname } from "next/navigation"; import { useLocale, useTranslations } from "next-intl"; import { useState } from "react"; import { FloatingControls } from "@/components/layout/floating-controls"; import { Dock, DockIcon } from "@/components/ui/dock"; import { getLocalizedPath, stripLocalePrefix, type AppLocale } from "@/lib/locale"; import { cn } from "@/lib/utils"; type SiteDockProps = { defaultLocale: AppLocale; /** * Server-computed via `isSuperAdmin()` in the parent layout. This client * component only decides whether to *render* the Admin shortcut — it performs * no auth check and grants no access; the real guard lives server-side on * each admin page/action. */ isSuperAdmin?: boolean; }; type NavKey = "about" | "portfolio" | "products" | "contact"; type NavItem = { key: NavKey; path: string; /** Icon file under /public. Swap these for real macOS app icons anytime. */ icon: string; disabled?: boolean; }; // "Home" is intentionally omitted — the logo (first dock icon) is the home link. const navItems: NavItem[] = [ { key: "about", path: "/about", icon: "/dock/about.svg" }, { key: "portfolio", path: "/portfolio", icon: "/dock/portfolio.svg" }, { key: "products", path: "/products", icon: "/dock/products.svg", disabled: true }, { key: "contact", path: "/contact", icon: "/dock/contact.svg" }, ]; function isNavItemActive(currentPath: string, itemPath: string) { if (itemPath === "/") { return currentPath === "/"; } return currentPath === itemPath || currentPath.startsWith(`${itemPath}/`); } export function SiteDock({ defaultLocale, isSuperAdmin = false }: SiteDockProps) { const locale = useLocale(); const pathname = usePathname(); const t = useTranslations("navigation"); const reducedMotion = useReducedMotion(); const [bouncing, setBouncing] = useState(null); const currentPath = stripLocalePrefix(pathname); const homeHref = getLocalizedPath(locale, "/", defaultLocale); // macOS-style launch hop on click. const bounceProps = (id: string) => reducedMotion ? {} : { onClick: () => setBouncing(id), animate: bouncing === id ? { y: [0, -18, 0, -6, 0] } : { y: 0 }, transition: { duration: 0.5, ease: "easeOut" as const }, onAnimationComplete: () => setBouncing((cur) => (cur === id ? null : cur)), }; return ( <> {/* ===== Bottom dock — primary navigation ===== */}
{/* ── Logo (fixed src → no refresh flash) ── */} mohfarawati
{/* ── Pages (icon art carries its own squircle shape) ── */} {navItems.map(({ key, path, icon: iconSrc, disabled }) => { const itemPath = path || "/"; const isActive = isNavItemActive(currentPath, itemPath); const label = t(key); const icon = ( {label} ); return ( {disabled ? ( {icon} ) : ( {icon} )} {/* macOS running indicator */} {isActive ? ( ) : null} ); })}
{/* ===== Corner controls — theme / language / sound / admin (fan out) ===== */} ); } function DockTip({ label, soon }: { label: string; soon?: string }) { return ( {label} {soon ? {soon} : null} ); }