"use client"; // Katlanır önizleme (DESIGN.md §4.40): uzun bir içeriğin başı görünür, altı // kademeli bulanıklıkla (progressive blur) sayfa zeminine söner; düğme // içeriği yayla açar, yeniden katlar. İçerik her zaman sayfadadır (HTML'de // ve ekran okuyucuda tam); kapalıyken yalnız görünüşü kırpılır. // // Bulanıklık katalog aramasındaki `ProgressiveBlur`dır (Skiper UI 41, tek // kaynak): degrade sayfa zeminine (`slate-50`) söner, bulanıklık maskeyle // aynı yönde koyulaşır. Aç/kapa yayı `YAY.akici`; hareketi azalt'ta anında // açılır. import { useId, useRef, useState, type ReactNode } from "react"; import { flushSync } from "react-dom"; import { animate, useReducedMotion, type AnimationPlaybackControls, } from "motion/react"; import { ChevronDown } from "lucide-react"; import { Button } from "@/components/ui/button"; import { ProgressiveBlur } from "@/components/ui/skiper-ui/skiper41"; import { YAY } from "@/lib/hareket"; import { cn } from "@/lib/utils"; export function KatlanirOnizleme({ children, kapaliSinif, acEtiketi, kapatEtiketi = "Daha az göster", className, }: { children: ReactNode; /** Kapalıyken görünen boy (ör. "max-h-80 lg:max-h-72") */ kapaliSinif: string; acEtiketi: string; kapatEtiketi?: string; className?: string; }) { const id = useId(); const kapRef = useRef(null); const animRef = useRef(null); const [acik, setAcik] = useState(false); const azalt = useReducedMotion(); function degistir() { const kap = kapRef.current; animRef.current?.stop(); if (kap) { kap.style.height = ""; kap.style.maxHeight = ""; } const once = kap?.getBoundingClientRect().height ?? 0; flushSync(() => setAcik((v) => !v)); if (!kap || azalt) return; const sonra = kap.getBoundingClientRect().height; // Katlanırken boy sınıfı hemen devreye girer; yay bitene dek kaldırılır. kap.style.maxHeight = "none"; animRef.current = animate( kap, { height: [once, sonra] }, { ...YAY.akici, onComplete: () => { kap.style.height = ""; kap.style.maxHeight = ""; }, }, ); } return (
{children} {!acik ? ( ) : null}
); }