"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>
52 lines
1.7 KiB
TypeScript
52 lines
1.7 KiB
TypeScript
"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>
|
||
);
|
||
}
|