"use client"; // Telefon menüsü (DESIGN.md §4.36): üst çubuk tek satır kalsın diye sıralama // ve arama dışındaki her şey bu baloncuğun içinde. Açılınca perde logodan bir // halka gibi büyür (tema geçişinin halkası), baloncuklar halkanın ardından // yukarıdan aşağı sırayla "pop" eder. Tek hareket gibi okunur: ilk baloncuk // ~0,1 sn'de, hepsi 0,8 sn içinde yerinde. Kapanış hızlı ve sekmesiz. // // Esin: React Bits "Bubble Menu" (reactbits.dev, MIT + Commons Clause). Kod // KolayTercih diline çevrildi: GSAP yerine `motion`, zamanlama // `lib/hareket.ts`, renkler token; eğik/gökkuşağı haplar alınmadı. Kabuk // Radix Dialog ilkeli (odak tuzağı, Esc, odak dönüşü); hareketi azalt'ta // haplar yalnız belirir. import { useRef, useState, type ReactNode } from "react"; import Link from "next/link"; import { Dialog as DialogPrimitive } from "radix-ui"; import { AnimatePresence, motion, useReducedMotion } from "motion/react"; import { BookOpen, Building2, CircleHelp, ClipboardList, Coins, GraduationCap, ListChecks, type LucideIcon, } from "lucide-react"; import { AnimasyonluMark } from "@/components/animasyonlu-mark"; import { PikselSustur } from "@/components/piksel-sustur"; import { TemaSecici } from "@/components/tema-secici"; import { SayiRulo } from "@/components/ui/sayi-rulo"; import { MANUEL_LISTE_MAX, cekmeceAc, useManuelListe, } from "@/features/liste/liste-store"; import { preloadListeCekmecesi } from "@/features/liste/components/liste-cekmecesi-lazy"; import { EGRI, SURE, YAY } from "@/lib/hareket"; import { logoHalkasi } from "@/lib/tema-gecisi"; import { cn } from "@/lib/utils"; /** Halka: tüylü kenarlı bir daire, yalnız `transform` ile büyür (maske ya da * yarıçap değişkeni her karede boyama ister; telefonda takılır). Güçlü * yavaşlama eğrisiyle ekranı ilk ~0,15 sn'de kaplar, kalanı süzülmedir. */ const HALKA_CAPI = 400; const HALKA_SURESI = 0.4; /** Tam opak çekirdeğin yarıçapa oranı (tema-gecisi.ts `CEKIRDEK` ile aynı). */ const HALKA_CEKIRDEK = 55; /** İlk baloncuk halka üstünden geçince başlar, gerisi bu aralıkla izler. */ const HAP_GECIKMESI = 0.1; const HAP_ADIMI = 0.06; const GEZINME: { href: string; etiket: string; ikon: LucideIcon }[] = [ { href: "/bolumler", etiket: "Bölümler", ikon: GraduationCap }, { href: "/universiteler", etiket: "Üniversiteler", ikon: Building2 }, { href: "/rehber", etiket: "Rehber", ikon: BookOpen }, { href: "/#nasil-calisir", etiket: "Nasıl çalışır?", ikon: CircleHelp }, ]; const IRI_HAP = "flex min-h-14 w-full cursor-pointer items-center gap-3 rounded-full border border-slate-200 bg-card px-6 text-left font-heading text-xl font-bold text-slate-900 outline-none transition-[background-color,transform] duration-150 focus-visible:ring-3 focus-visible:ring-ring/50 active:scale-[0.97] motion-reduce:transition-none"; const KUCUK_HAP = "flex min-h-12 cursor-pointer items-center gap-2 rounded-full border border-slate-200 bg-card px-4 text-base font-semibold text-slate-700 outline-none transition-[background-color,transform] duration-150 focus-visible:ring-3 focus-visible:ring-ring/50 active:scale-[0.97] motion-reduce:transition-none"; export function MobilMenu({ kredi, girisSlotu, }: { /** Girişli kullanıcının kredisi; girişsizse `null`. */ kredi: number | null; /** "Giriş yap" ya da "Çıkış yap" hapı (sunucu tarafı karar verir). */ girisSlotu: ReactNode; }) { const [acik, setAcik] = useState(false); // Kapatma düğmesi ve logo, üst çubuktaki yerlerinde durur: çubuğun o anki // konumu (üst bant görünürken daha aşağıda) açılırken ölçülür. const [ust, setUst] = useState(16); const [halka, setHalka] = useState({ x: 24, y: 24, son: 2000 }); // Halka durunca perde düz zemine geçer: pencere dönse de boşluk kalmaz. const [oturdu, setOturdu] = useState(false); const tetikRef = useRef(null); const azalt = useReducedMotion(); const liste = useManuelListe(); function degistir(yeni: boolean) { if (yeni) { const r = tetikRef.current?.getBoundingClientRect(); if (r) setUst(Math.max(8, r.top)); setHalka(logoHalkasi()); setOturdu(false); } setAcik(yeni); } /** Sırayla "pop": baloncuk fırlar (§4.36: sekmenin serbest olduğu yer). */ const hap = (i: number) => azalt ? { initial: { opacity: 0 }, animate: { opacity: 1, transition: { duration: SURE.hizli } }, exit: { opacity: 0, transition: { duration: SURE.anlik } }, } : { // `scale` kısaltması değil tam `transform` dizgisi: Motion bunu // WAAPI'ye verir, pencere kurulurken / sayfa değişirken takılmaz. // 0'dan değil 0.9'dan: hiçbir şey yoktan var olmaz. initial: { opacity: 0, transform: "scale(0.9)" }, animate: { opacity: 1, transform: "scale(1)", transition: { ...YAY.birakma, delay: HAP_GECIKMESI + i * HAP_ADIMI }, }, exit: { opacity: 0, transform: "scale(0.92)", transition: { duration: SURE.cikis, ease: EGRI.standart }, }, }; let sira = 0; return ( {acik ? ( {azalt || oturdu ? null : ( setOturdu(true)} /> )} Menü {/* Üst sıra: çubuğun yerinde. Önce imza (logo bir tur döner), içerik ardından gelir (§11.2). */}
Kolay Tercih
) : null}
); } /** İki çizgi ↔ çarpı. Açık hâl perdede ayrı düğmede çizildiği için burada * geçiş yok; iki hâl aynı ölçüde (§4.3 çarpı ölçüsü). */ function MenuCizgileri({ acik }: { acik: boolean }) { return ( ); }