Files
kolaytercih/src/components/piksel-sustur.tsx
bilalgursen 42b6c590af feat(piksel): "Piksel sussun" anahtarı footer'dan kaldırıldı, yalnız telefon menüsünde (→ 2.5.4)
"Footer piksel konuşsun sussun seçeneği" oturumunun tamamladığı değişiklik; çalışma
ağacında commit'siz duruyordu, köşe işinin (2.5.5) altına alındı.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-10-27 00:37:29 +03:00

52 lines
1.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"use client";
// "Piksel sussun" anahtarı (S-013): yalnız telefon menüsünde, tema seçicinin
// altında (27 Eki 2026'da footer'dan kaldırıldı). Seçim cihazda kalır (lib/piksel-soyle.ts). Susunca
// logodaki Piksel yine yaşar, yalnız balon açmaz. Sunucu HTML'inde hiçbir
// seçenek işaretli gelmez, hydration sonrası işaretlenir (tema-secici kalıbı).
import { useSyncExternalStore } from "react";
import { SecimHaplari } from "@/components/ui/secim-haplari";
import { olay } from "@/lib/analitik";
import { PIKSEL_SUSTU_OLAYI, pikselSustuMu, pikselSustur } from "@/lib/piksel-soyle";
import { cn } from "@/lib/utils";
const SECENEKLER = [
{ deger: "konussun", etiket: "Konuşsun" },
{ deger: "sussun", etiket: "Sussun" },
] as const;
type Secim = (typeof SECENEKLER)[number]["deger"];
const abone = (f: () => void) => {
window.addEventListener(PIKSEL_SUSTU_OLAYI, f);
window.addEventListener("storage", f);
return () => {
window.removeEventListener(PIKSEL_SUSTU_OLAYI, f);
window.removeEventListener("storage", f);
};
};
export function PikselSustur({ className }: { className?: string }) {
const secili = useSyncExternalStore<Secim | null>(
abone,
() => (pikselSustuMu() ? "sussun" : "konussun"),
() => null,
);
return (
<div className={cn("flex items-center gap-2", className)}>
<span className="text-xs font-semibold text-slate-500">Piksel</span>
<SecimHaplari<Secim>
ariaLabel="Piksel konuşsun mu"
secenekler={SECENEKLER}
deger={secili}
onChange={(d) => {
pikselSustur(d === "sussun");
if (d === "sussun") olay("piksel_susturuldu");
}}
varyant="kapsul"
boyut="md"
/>
</div>
);
}