From b627e7dc1549fe6365803f22eaf4785e9567cb2f Mon Sep 17 00:00:00 2001 From: seanrobertwright Date: Sat, 4 Oct 2025 19:37:53 -0400 Subject: [PATCH] feat: enhance AddKnowledgeDialog with scrollable content and fixed header - Introduced ScrollableDialogContent component for better user experience in AddKnowledgeDialog. - Updated dialog structure to include a fixed header and scrollable body, improving accessibility and usability. - Adjusted styles to maintain visual consistency and added maxHeight prop for dynamic height management. - Updated .gitignore to include DIALOG-FIX.md for better tracking of dialog-related changes. This change enhances the dialog's functionality, making it more user-friendly while adhering to design principles. --- .gitignore | 1 + .../components/AddKnowledgeDialog.tsx | 370 +++++++++--------- .../src/features/ui/primitives/dialog.tsx | 68 +++- 3 files changed, 256 insertions(+), 183 deletions(-) diff --git a/.gitignore b/.gitignore index 96c7a645e3..1d6f7db707 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ temp/ UAT/ .DS_Store +DIALOG-FIX.md \ No newline at end of file diff --git a/archon-ui-main/src/features/knowledge/components/AddKnowledgeDialog.tsx b/archon-ui-main/src/features/knowledge/components/AddKnowledgeDialog.tsx index 3788affd18..fde07a8f02 100644 --- a/archon-ui-main/src/features/knowledge/components/AddKnowledgeDialog.tsx +++ b/archon-ui-main/src/features/knowledge/components/AddKnowledgeDialog.tsx @@ -7,7 +7,7 @@ import { Globe, Loader2, Upload } from "lucide-react"; import { useId, useState } from "react"; import { useToast } from "@/features/shared/hooks/useToast"; import { Button, Input, Label } from "../../ui/primitives"; -import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "../../ui/primitives/dialog"; +import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle, ScrollableDialogContent } from "../../ui/primitives/dialog"; import { cn } from "../../ui/primitives/styles"; import { Tabs, TabsContent } from "../../ui/primitives/tabs"; import { useCrawlUrl, useUploadDocument } from "../hooks"; @@ -127,208 +127,214 @@ export const AddKnowledgeDialog: React.FC = ({ return ( - - - Add Knowledge - Crawl websites or upload documents to expand your knowledge base. - + + {/* Fixed Header */} +
+ + Add Knowledge + Crawl websites or upload documents to expand your knowledge base. + +
- setActiveTab(v as "crawl" | "upload")}> - {/* Enhanced Tab Buttons */} -
- {/* Crawl Website Tab */} - + - {/* Upload Document Tab */} - -
+ + - {/* Crawl Tab */} - - {/* Enhanced URL Input Section */} -
- -
-
- + {/* Crawl Tab */} + + {/* Enhanced URL Input Section */} +
+ +
+
+ +
+ setCrawlUrl(e.target.value)} + disabled={isProcessing} + className="pl-10 h-12 backdrop-blur-md bg-gradient-to-r from-white/60 to-white/50 dark:from-black/60 dark:to-black/50 border-gray-300/60 dark:border-gray-600/60 focus:border-cyan-400/70 focus:shadow-[0_0_20px_rgba(34,211,238,0.15)]" + />
- setCrawlUrl(e.target.value)} - disabled={isProcessing} - className="pl-10 h-12 backdrop-blur-md bg-gradient-to-r from-white/60 to-white/50 dark:from-black/60 dark:to-black/50 border-gray-300/60 dark:border-gray-600/60 focus:border-cyan-400/70 focus:shadow-[0_0_20px_rgba(34,211,238,0.15)]" - /> +

+ Enter the URL of a website you want to crawl for knowledge +

-

- Enter the URL of a website you want to crawl for knowledge -

-
-
- +
+ - -
+ +
- + - - + + - {/* Upload Tab */} - - {/* Enhanced File Input Section */} -
- + {/* Upload Tab */} + + {/* Enhanced File Input Section */} +
+ - {/* Custom File Upload Area */} -
- setSelectedFile(e.target.files?.[0] || null)} - disabled={isProcessing} - className="absolute inset-0 w-full h-full opacity-0 cursor-pointer disabled:cursor-not-allowed z-10" - /> -
- + setSelectedFile(e.target.files?.[0] || null)} + disabled={isProcessing} + className="absolute inset-0 w-full h-full opacity-0 cursor-pointer disabled:cursor-not-allowed z-10" /> -
- {selectedFile ? ( -
-

{selectedFile.name}

-

- {Math.round(selectedFile.size / 1024)} KB -

-
- ) : ( -
-

Click to browse or drag & drop

-

- PDF, DOC, DOCX, TXT, MD files supported -

-
+
+ +
+ {selectedFile ? ( +
+

{selectedFile.name}

+

+ {Math.round(selectedFile.size / 1024)} KB +

+
+ ) : ( +
+

Click to browse or drag & drop

+

+ PDF, DOC, DOCX, TXT, MD files supported +

+
+ )} +
-
- + - + - - - - + + + +
+
); }; diff --git a/archon-ui-main/src/features/ui/primitives/dialog.tsx b/archon-ui-main/src/features/ui/primitives/dialog.tsx index 27947ebdbf..d743499466 100644 --- a/archon-ui-main/src/features/ui/primitives/dialog.tsx +++ b/archon-ui-main/src/features/ui/primitives/dialog.tsx @@ -33,8 +33,9 @@ export const DialogContent = React.forwardRef< React.ElementRef, React.ComponentPropsWithoutRef & { showCloseButton?: boolean; + maxHeight?: string; } ->(({ className, children, showCloseButton = true, ...props }, ref) => ( +>(({ className, children, showCloseButton = true, maxHeight = "90vh", ...props }, ref) => (
{children}
@@ -81,6 +86,67 @@ export const DialogContent = React.forwardRef< )); DialogContent.displayName = DialogPrimitive.Content.displayName; +// Scrollable Dialog Content with fixed header and scrollable body +export const ScrollableDialogContent = React.forwardRef< + React.ElementRef, + React.ComponentPropsWithoutRef & { + showCloseButton?: boolean; + maxHeight?: string; + } +>(({ className, children, showCloseButton = true, maxHeight = "90vh", ...props }, ref) => ( + + + + {/* Scrollable Content Area */} +
+ {children} +
+ + {showCloseButton && ( + + + Close + + )} +
+
+)); +ScrollableDialogContent.displayName = "ScrollableDialogContent"; + // Dialog Header export const DialogHeader = React.forwardRef>( ({ className, ...props }, ref) => (