diff --git a/src/features/liste/components/sonuc-kaydet-cubugu.tsx b/src/features/liste/components/sonuc-kaydet-cubugu.tsx index e06a06c..0da602d 100644 --- a/src/features/liste/components/sonuc-kaydet-cubugu.tsx +++ b/src/features/liste/components/sonuc-kaydet-cubugu.tsx @@ -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;
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"; +//
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
+ * değiştikçe izlenen küme genişletilir. */ +function useTuruncuCtaEkranda(): boolean { + const [ekranda, setEkranda] = useState(false); + useEffect(() => { + const gorunenler = new Set(); + 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(); + 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() {
{/* İ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. */}