feat(v2): 9–10 Ekim çalışma ağacı — deneyim dili 1. dalga, PWA manifest, revizyon niyet modeli, listem/tadımlık bileşen denetimi
9–10 Ekim oturumlarının commit'lenmemiş işi tek parça alındı (raporlar: docs/ekip-raporlari/2026-10-09, 2026-10-10): - Landing deneyim dili 1. dalga: sayfa geçişi (ViewTransition), piksel morf/şerit, sorun sahneleri, adım akışı, sayan sayı, mobil menü, adım göstergesi, logoya tepki; DESIGN.md §11 ve AGENTS.md kuralları, tasarım denetimine yeni kurallar - Tema: tema ikonu, D kısayolu, tema geçişi - PWA: manifest.ts ve ikonlar - Danışman: revizyon niyet modeli (OPENROUTER_NIYET_MODEL), sohbet geçmişi, soru API'si - /listem ve /sonuc tadımlığı bileşen denetimi düzeltmeleri - eslint: .venv-tts/ yok sayılır tsc, eslint ve tasarım denetimi sıfır hata. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
304
src/components/mobil-menu.tsx
Normal file
304
src/components/mobil-menu.tsx
Normal file
@@ -0,0 +1,304 @@
|
||||
"use client";
|
||||
|
||||
// Telefon menüsü (DESIGN.md §4.36): üst çubuk tek satır kalsın diye sıralama
|
||||
// dışındaki her şey bu baloncuğun içinde. Açılınca tam ekran perde gelir,
|
||||
// iri haplar sırayla "pop" eder; 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,
|
||||
Search,
|
||||
type LucideIcon,
|
||||
} from "lucide-react";
|
||||
import { AnimasyonluMark } from "@/components/animasyonlu-mark";
|
||||
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 { cn } from "@/lib/utils";
|
||||
|
||||
/** Arama penceresini açtıran olay; `katalog-arama.tsx` dinler. */
|
||||
export const ARAMA_AC_OLAYI = "kt-arama-ac";
|
||||
|
||||
const HAP_ADIMI = 0.035;
|
||||
|
||||
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 tetikRef = useRef<HTMLButtonElement>(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));
|
||||
}
|
||||
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 } },
|
||||
}
|
||||
: {
|
||||
initial: { opacity: 0, scale: 0.6 },
|
||||
animate: {
|
||||
opacity: 1,
|
||||
scale: 1,
|
||||
transition: { ...YAY.birakma, delay: 0.06 + i * HAP_ADIMI },
|
||||
},
|
||||
exit: {
|
||||
opacity: 0,
|
||||
scale: 0.92,
|
||||
transition: { duration: SURE.cikis, ease: EGRI.standart },
|
||||
},
|
||||
};
|
||||
|
||||
let sira = 0;
|
||||
|
||||
return (
|
||||
<DialogPrimitive.Root open={acik} onOpenChange={degistir}>
|
||||
<DialogPrimitive.Trigger asChild>
|
||||
<button
|
||||
ref={tetikRef}
|
||||
type="button"
|
||||
aria-label={
|
||||
liste.length > 0
|
||||
? `Menü — listende ${liste.length}/${MANUEL_LISTE_MAX} program`
|
||||
: "Menü"
|
||||
}
|
||||
data-ucus-hedefi="mobil"
|
||||
className="relative flex size-9 shrink-0 cursor-pointer items-center justify-center rounded-full border border-slate-200 bg-card text-slate-900 outline-none transition-[background-color,transform] duration-150 hover:bg-slate-100 focus-visible:ring-3 focus-visible:ring-ring/50 active:scale-[0.96] motion-reduce:transition-none sm:size-12"
|
||||
>
|
||||
<MenuCizgileri acik={false} />
|
||||
{liste.length > 0 ? (
|
||||
<span
|
||||
data-ucus-rozet
|
||||
className="absolute -top-1 -right-1 flex h-5 min-w-5 items-center justify-center rounded-full bg-orange-500 px-1 font-heading text-xs font-bold text-white"
|
||||
>
|
||||
<SayiRulo deger={liste.length} />
|
||||
</span>
|
||||
) : null}
|
||||
</button>
|
||||
</DialogPrimitive.Trigger>
|
||||
|
||||
<AnimatePresence>
|
||||
{acik ? (
|
||||
<DialogPrimitive.Portal forceMount>
|
||||
<DialogPrimitive.Overlay forceMount asChild>
|
||||
<motion.div
|
||||
className="fixed inset-0 z-50 bg-slate-50/90 supports-backdrop-filter:backdrop-blur-md"
|
||||
initial={{ opacity: 0 }}
|
||||
animate={{ opacity: 1, transition: { duration: SURE.standart, ease: EGRI.standart } }}
|
||||
exit={{ opacity: 0, transition: { duration: SURE.cikis, ease: EGRI.standart } }}
|
||||
/>
|
||||
</DialogPrimitive.Overlay>
|
||||
<DialogPrimitive.Content
|
||||
forceMount
|
||||
aria-describedby={undefined}
|
||||
className="fixed inset-0 z-50 overflow-y-auto overscroll-contain outline-none"
|
||||
>
|
||||
<DialogPrimitive.Title className="sr-only">Menü</DialogPrimitive.Title>
|
||||
|
||||
{/* Üst sıra: çubuğun yerinde. Önce imza (logo bir tur döner),
|
||||
içerik ardından gelir (§11.2). */}
|
||||
<div
|
||||
className="pointer-events-none fixed inset-x-0 z-10 flex items-center justify-between px-3 sm:px-4"
|
||||
style={{ top: ust }}
|
||||
>
|
||||
<motion.span
|
||||
className="flex items-center font-bricolage"
|
||||
initial={{ opacity: 0 }}
|
||||
animate={{ opacity: 1, transition: { duration: SURE.standart } }}
|
||||
exit={{ opacity: 0, transition: { duration: SURE.anlik } }}
|
||||
>
|
||||
<AnimasyonluMark varyant="nabiz" className="size-8 sm:size-11" />
|
||||
<span className="text-lg font-light tracking-tighter sm:text-3xl">Kolay</span>
|
||||
<span className="text-lg font-semibold tracking-tighter sm:text-3xl">Tercih</span>
|
||||
</motion.span>
|
||||
<DialogPrimitive.Close asChild>
|
||||
<button
|
||||
type="button"
|
||||
aria-label="Menüyü kapat"
|
||||
className="pointer-events-auto flex size-9 cursor-pointer items-center justify-center rounded-full border border-slate-200 bg-card text-slate-900 outline-none transition-[background-color,transform] duration-150 hover:bg-slate-100 focus-visible:ring-3 focus-visible:ring-ring/50 active:scale-[0.96] motion-reduce:transition-none sm:size-12"
|
||||
>
|
||||
<MenuCizgileri acik />
|
||||
</button>
|
||||
</DialogPrimitive.Close>
|
||||
</div>
|
||||
|
||||
<nav
|
||||
aria-label="Menü"
|
||||
className="mx-auto flex min-h-full max-w-md flex-col gap-3 px-4 pb-10"
|
||||
style={{ paddingTop: ust + 72 }}
|
||||
>
|
||||
<motion.div {...hap(sira++)}>
|
||||
<button
|
||||
type="button"
|
||||
className={IRI_HAP}
|
||||
onClick={() => {
|
||||
setAcik(false);
|
||||
window.dispatchEvent(new Event(ARAMA_AC_OLAYI));
|
||||
}}
|
||||
>
|
||||
<Search className="size-5 shrink-0 text-primary" aria-hidden />
|
||||
Ara
|
||||
<span className="ml-auto text-sm font-medium font-sans text-slate-500">
|
||||
bölüm, üniversite, rehber
|
||||
</span>
|
||||
</button>
|
||||
</motion.div>
|
||||
|
||||
<motion.div {...hap(sira++)}>
|
||||
<button
|
||||
type="button"
|
||||
className={IRI_HAP}
|
||||
onPointerEnter={preloadListeCekmecesi}
|
||||
onFocus={preloadListeCekmecesi}
|
||||
onClick={() => {
|
||||
setAcik(false);
|
||||
cekmeceAc();
|
||||
}}
|
||||
>
|
||||
<ListChecks className="size-5 shrink-0 text-primary" aria-hidden />
|
||||
Kendi Listem
|
||||
<span
|
||||
className={cn(
|
||||
"ml-auto flex h-7 items-center rounded-full px-2.5 font-sans text-sm font-bold tabular-nums",
|
||||
liste.length > 0
|
||||
? "bg-orange-500 text-white"
|
||||
: "bg-slate-100 text-slate-500",
|
||||
)}
|
||||
>
|
||||
{liste.length}/{MANUEL_LISTE_MAX}
|
||||
</span>
|
||||
</button>
|
||||
</motion.div>
|
||||
|
||||
{kredi !== null ? (
|
||||
<>
|
||||
<motion.div {...hap(sira++)}>
|
||||
<Link href="/listem" className={IRI_HAP} onClick={() => setAcik(false)}>
|
||||
<ClipboardList className="size-5 shrink-0 text-primary" aria-hidden />
|
||||
Yapay Zeka Listem
|
||||
</Link>
|
||||
</motion.div>
|
||||
<motion.div {...hap(sira++)}>
|
||||
<Link
|
||||
href="/paket?kaynak=nav"
|
||||
className={IRI_HAP}
|
||||
onClick={() => setAcik(false)}
|
||||
>
|
||||
<Coins className="size-5 shrink-0 text-amber-500" aria-hidden />
|
||||
Kredilerim
|
||||
<span className="ml-auto font-sans text-base font-bold tabular-nums text-slate-700">
|
||||
{kredi.toLocaleString("tr-TR")}
|
||||
</span>
|
||||
</Link>
|
||||
</motion.div>
|
||||
</>
|
||||
) : null}
|
||||
|
||||
<motion.ul {...hap(sira++)} className="mt-2 grid grid-cols-2 gap-2">
|
||||
{GEZINME.map(({ href, etiket, ikon: Ikon }) => (
|
||||
<li key={href}>
|
||||
<Link
|
||||
href={href}
|
||||
className={cn(KUCUK_HAP, "w-full")}
|
||||
onClick={() => setAcik(false)}
|
||||
>
|
||||
<Ikon className="size-4 shrink-0 text-slate-500" aria-hidden />
|
||||
<span className="truncate">{etiket}</span>
|
||||
</Link>
|
||||
</li>
|
||||
))}
|
||||
</motion.ul>
|
||||
|
||||
<motion.div {...hap(sira++)} className="mt-4 flex justify-center">
|
||||
<TemaSecici ipucu={false} />
|
||||
</motion.div>
|
||||
|
||||
<motion.div
|
||||
{...hap(sira++)}
|
||||
className="mt-auto flex justify-center pt-6"
|
||||
// Giriş/çıkış sonrası menü açık kalmasın.
|
||||
onClick={() => setAcik(false)}
|
||||
>
|
||||
{girisSlotu}
|
||||
</motion.div>
|
||||
</nav>
|
||||
</DialogPrimitive.Content>
|
||||
</DialogPrimitive.Portal>
|
||||
) : null}
|
||||
</AnimatePresence>
|
||||
</DialogPrimitive.Root>
|
||||
);
|
||||
}
|
||||
|
||||
/** İ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 (
|
||||
<span aria-hidden className="relative block size-4">
|
||||
<span
|
||||
className={cn(
|
||||
"absolute left-0 h-0.5 w-4 rounded-full bg-current",
|
||||
acik ? "top-[7px] rotate-45" : "top-1",
|
||||
)}
|
||||
/>
|
||||
<span
|
||||
className={cn(
|
||||
"absolute left-0 h-0.5 w-4 rounded-full bg-current",
|
||||
acik ? "top-[7px] -rotate-45" : "top-2.5",
|
||||
)}
|
||||
/>
|
||||
</span>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user