From 264d7905c62e6aa9a423f409fca946f7ef321bef Mon Sep 17 00:00:00 2001 From: Alvaro Parker Date: Wed, 7 Oct 2026 09:55:57 -0300 Subject: [PATCH] refactor(frontend): share Tailwind dialog and form controls --- vocero-frontend/src/components/Dialog.tsx | 29 ++- .../src/components/ReportsPanel.tsx | 2 +- .../src/components/SettingsDialogs.tsx | 232 ++++++++++-------- vocero-frontend/src/components/ui.tsx | 81 ++++++ 4 files changed, 235 insertions(+), 109 deletions(-) create mode 100644 vocero-frontend/src/components/ui.tsx diff --git a/vocero-frontend/src/components/Dialog.tsx b/vocero-frontend/src/components/Dialog.tsx index 358d2b9..2157a87 100644 --- a/vocero-frontend/src/components/Dialog.tsx +++ b/vocero-frontend/src/components/Dialog.tsx @@ -1,13 +1,22 @@ import { X } from "lucide-react"; import { useLayoutEffect, useId, useRef, type ReactNode } from "react"; +import { IconButton } from "./ui"; + interface Props { title: string; children: ReactNode; onClose: () => void; - className?: string; + size?: "default" | "about" | "profile" | "drawer"; } -export function Dialog({ title, children, onClose, className = "" }: Props) { +const sizes = { + default: "w-[min(440px,92vw)] rounded-panel", + about: "max-h-[88vh] w-[min(680px,92vw)] rounded-panel", + profile: "max-h-[90vh] w-[min(480px,90vw)] rounded-panel", + drawer: "m-0 h-dvh max-h-dvh w-[min(360px,92vw)] rounded-none", +}; + +export function Dialog({ title, children, onClose, size = "default" }: Props) { const ref = useRef(null); const titleId = useId(); useLayoutEffect(() => { @@ -24,7 +33,7 @@ export function Dialog({ title, children, onClose, className = "" }: Props) { return ( { event.preventDefault(); @@ -36,12 +45,16 @@ export function Dialog({ title, children, onClose, className = "" }: Props) { } }} > -
-
-

{title}

- +
{children}
diff --git a/vocero-frontend/src/components/ReportsPanel.tsx b/vocero-frontend/src/components/ReportsPanel.tsx index 97fa424..89ba47f 100644 --- a/vocero-frontend/src/components/ReportsPanel.tsx +++ b/vocero-frontend/src/components/ReportsPanel.tsx @@ -48,7 +48,7 @@ export function ReportsPanel({ ); } return open ? ( - +
diff --git a/vocero-frontend/src/components/SettingsDialogs.tsx b/vocero-frontend/src/components/SettingsDialogs.tsx index bf66569..f9abd5c 100644 --- a/vocero-frontend/src/components/SettingsDialogs.tsx +++ b/vocero-frontend/src/components/SettingsDialogs.tsx @@ -5,6 +5,7 @@ import { profileRows } from "../lib/profile"; import { GATE_MAX, GATE_OFF, VOICES } from "../lib/settings"; import { LIVE_STATES, type AppState, type VoiceController } from "../realtime/controller"; import { Dialog } from "./Dialog"; +import { Button, DialogFooter, DialogIntro, Field, FieldHint, Input, Select, Textarea } from "./ui"; interface Props { state: AppState; @@ -27,12 +28,12 @@ export function SettingsDialog({ state, controller, onClose }: Props) { onClose(); }} > -
-
+
+
{config.allowDirect && !config.lb && ( - + + )} -
-
-