feat(sonuc): sayfanın turuncu CTA'sı ekrandayken kaydet çubuğu çekilir
DESIGN.md §2 tek turuncu buton; main içindeki turuncu düğmeler IntersectionObserver ile izlenir, geçiş YAY.varsayilan. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -11,9 +11,15 @@
|
||||
// ve KVKK aydınlatma/koşullar notu o sayfada; çubuktan doğrudan Google'a
|
||||
// atlamak o notu atlatırdı.
|
||||
//
|
||||
// Sayfanın kendi turuncu CTA'sı (giriş paneli, tadımlık düğmesi) ekrandayken
|
||||
// çubuk çekilir: DESIGN.md §2 "bir ekranda tek turuncu buton". Paneller başka
|
||||
// dosyalarda yaşadığı için onlara işaret eklenmez; <main> içindeki turuncu
|
||||
// düğmeler sınıfından/varyantından bulunup izlenir.
|
||||
//
|
||||
// Çubuk içerik akışında kendi boyu kadar boşluk bırakır (ara parça), böylece
|
||||
// sayfanın en altı (dipnot, footer) çubuğun altında kalmaz.
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import Link from "next/link";
|
||||
import { motion, useReducedMotion } from "motion/react";
|
||||
import { ArrowRight } from "lucide-react";
|
||||
@@ -26,14 +32,59 @@ import { useManuelListe } from "../liste-store";
|
||||
import { useOturumDurumu } from "../liste-oturum-sinyali";
|
||||
import { useGirisUrl } from "../liste-giris-url";
|
||||
|
||||
// <main> içindeki turuncu CTA'lar: elle yazılmış eski düğmeler ve cta varyantı.
|
||||
const TURUNCU_CTA =
|
||||
'main a.bg-orange-500, main button.bg-orange-500, main [data-variant="cta"]';
|
||||
|
||||
/** Sayfadaki turuncu CTA'lardan biri çubuğun üstünde kalan görünür alanda mı.
|
||||
* Düğmeler Suspense/istemci bileşenlerinden sonradan geldiği için <main>
|
||||
* değiştikçe izlenen küme genişletilir. */
|
||||
function useTuruncuCtaEkranda(): boolean {
|
||||
const [ekranda, setEkranda] = useState(false);
|
||||
useEffect(() => {
|
||||
const gorunenler = new Set<Element>();
|
||||
const io = new IntersectionObserver(
|
||||
(kayitlar) => {
|
||||
for (const k of kayitlar) {
|
||||
if (k.isIntersecting) gorunenler.add(k.target);
|
||||
else gorunenler.delete(k.target);
|
||||
}
|
||||
setEkranda(gorunenler.size > 0);
|
||||
},
|
||||
// Alttaki 96 px çubuğun altında kalır; orada görünen düğme sayılmaz.
|
||||
{ rootMargin: "0px 0px -96px 0px" },
|
||||
);
|
||||
const izlenen = new Set<Element>();
|
||||
const tara = () => {
|
||||
for (const el of document.querySelectorAll(TURUNCU_CTA)) {
|
||||
if (izlenen.has(el)) continue;
|
||||
izlenen.add(el);
|
||||
io.observe(el);
|
||||
}
|
||||
};
|
||||
tara();
|
||||
const mo = new MutationObserver(tara);
|
||||
const main = document.querySelector("main");
|
||||
if (main) mo.observe(main, { childList: true, subtree: true });
|
||||
return () => {
|
||||
io.disconnect();
|
||||
mo.disconnect();
|
||||
};
|
||||
}, []);
|
||||
return ekranda;
|
||||
}
|
||||
|
||||
export function SonucKaydetCubugu() {
|
||||
const girisli = useOturumDurumu();
|
||||
const liste = useManuelListe();
|
||||
const girisUrl = useGirisUrl();
|
||||
const azalt = useReducedMotion();
|
||||
const gizli = useTuruncuCtaEkranda();
|
||||
|
||||
if (girisli !== false) return null;
|
||||
|
||||
const kapali = azalt ? { opacity: 0 } : { opacity: 0, y: 24 };
|
||||
|
||||
return (
|
||||
<>
|
||||
{/* Ara parça: çubuğun yüksekliği (p-2 + h-12 + alt boşluk) + güvenli alan */}
|
||||
@@ -44,10 +95,13 @@ export function SonucKaydetCubugu() {
|
||||
<ViewportPortal>
|
||||
<div className="pointer-events-none fixed inset-x-0 bottom-[calc(env(safe-area-inset-bottom)+0.75rem)] z-40 px-4 md:hidden print:hidden">
|
||||
<motion.div
|
||||
initial={azalt ? { opacity: 0 } : { opacity: 0, y: 24 }}
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
initial={kapali}
|
||||
animate={gizli ? kapali : { opacity: 1, y: 0 }}
|
||||
transition={YAY.varsayilan}
|
||||
className="pointer-events-auto mx-auto flex max-w-xl items-center gap-3 rounded-2xl border border-slate-200 bg-card p-2 pl-4 shadow-xl"
|
||||
// Çekilmişken odak/dokunma almaz, ekran okuyucu da atlar.
|
||||
inert={gizli}
|
||||
aria-hidden={gizli || undefined}
|
||||
className={`${gizli ? "pointer-events-none" : "pointer-events-auto"} mx-auto flex max-w-xl items-center gap-3 rounded-2xl border border-slate-200 bg-card p-2 pl-4 shadow-xl`}
|
||||
>
|
||||
{/* İki kısa satır: 375 px'te düğmenin yanında kalan ~110 px'e
|
||||
tek cümle sığmıyor, üç satıra kırılıyordu. */}
|
||||
|
||||
Reference in New Issue
Block a user