import { useId, useState, type ReactNode } from 'react' import { Markdown } from '@/components/markdown' import { t } from '@/lib/strings' import { cn } from '@/lib/utils' /** * Markdown alanı için "Yaz / Önizle" sekmeleri. `children` = yazma paneli (genelde `Textarea`). * Kimlikler `useId` ile üretilir → aynı sayfada birden çok editör olabilir. */ export function MarkdownTabs({ label, value, children, }: { /** Sekme listesinin erişilebilir adı */ label: string /** Önizlenecek metin */ value: string children: ReactNode }) { const id = useId() const [tab, setTab] = useState<'write' | 'preview'>('write') const tabButton = (v: typeof tab, text: string) => ( ) return (
{tabButton('write', t.notes.write)} {tabButton('preview', t.notes.preview)}
{tab === 'write' ? (
{children}
) : (
{value.trim() ? ( {value} ) : (

{t.notes.previewEmpty}

)}
)}
) }