peppa/apps/web/components/SettingsDialog.tsx
Асель 52d861bbc7 UI: board in one row, project panel moved into a ⋯ settings dialog
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 22:52:53 +05:00

34 lines
1.3 KiB
TypeScript

"use client";
import { useRef, type ReactNode } from "react";
import { Ellipsis, X } from "lucide-react";
import { Button } from "@/components/ui/button";
/** "⋯" button that opens a side dialog (native <dialog>) with page settings rendered on the server. */
export function SettingsDialog({ title, children }: { title: string; children: ReactNode }) {
const ref = useRef<HTMLDialogElement>(null);
return (
<>
<Button variant="ghost" size="icon" aria-label={title} title={title} onClick={() => ref.current?.showModal()}>
<Ellipsis />
</Button>
<dialog
ref={ref}
aria-label={title}
onClick={(e) => e.target === ref.current && ref.current.close()}
className="m-0 ml-auto h-dvh max-h-dvh w-[400px] max-w-full border-l bg-sidebar p-0 text-foreground backdrop:bg-black/50"
>
<div className="flex flex-col gap-4 px-4 py-5">
<div className="flex items-center gap-2">
<h2 className="m-0 text-[15px] font-semibold">{title}</h2>
<Button variant="ghost" size="icon" className="ml-auto" aria-label="Закрыть" onClick={() => ref.current?.close()}>
<X />
</Button>
</div>
{children}
</div>
</dialog>
</>
);
}