From e2a0eedd63f64253ce96b8ccd55dac4fdfc2eebf Mon Sep 17 00:00:00 2001 From: Xin Wang Date: Mon, 8 Jun 2026 10:21:43 +0800 Subject: [PATCH] Enhance ComponentsModelsPage with FieldLabel and HelpHint components for improved form usability Refactored the ComponentsModelsPage to introduce FieldLabel and HelpHint components, enhancing the user experience by providing contextual hints for form fields. Updated the layout to replace traditional labels with these new components, ensuring better accessibility and clarity for users when entering model details. This change aims to streamline the form interface and improve overall usability. --- src/components/pages/ComponentsModelsPage.tsx | 143 +++++++++++++++--- 1 file changed, 122 insertions(+), 21 deletions(-) diff --git a/src/components/pages/ComponentsModelsPage.tsx b/src/components/pages/ComponentsModelsPage.tsx index e4301d0..e5269eb 100644 --- a/src/components/pages/ComponentsModelsPage.tsx +++ b/src/components/pages/ComponentsModelsPage.tsx @@ -7,6 +7,7 @@ import { ChevronRight, Eye, EyeOff, + HelpCircle, Loader2, MoreHorizontal, Pencil, @@ -41,7 +42,12 @@ import { DialogHeader, DialogTitle, } from "@/components/ui/dialog"; -import { useState } from "react"; +import { + Popover, + PopoverContent, + PopoverTrigger, +} from "@/components/ui/popover"; +import { useState, type ReactNode } from "react"; type ModelType = "LLM" | "ASR" | "TTS" | "Realtime" | "Embedding"; @@ -529,24 +535,40 @@ export function ComponentsModelsPage() {
-
@@ -691,3 +741,54 @@ export function ComponentsModelsPage() { ); } + +function FieldLabel({ + htmlFor, + children, + hint, +}: { + htmlFor?: string; + children: ReactNode; + hint: { description: string; example?: string }; +}) { + return ( +
+ + +
+ ); +} + +function HelpHint({ + description, + example, +}: { + description: string; + example?: string; +}) { + return ( + + + + + +

{description}

+ {example && ( +

+ 填写样例: + {example} +

+ )} +
+
+ ); +}