From 34ecaaffb1eebef6d509ed73db336c7bdb181e76 Mon Sep 17 00:00:00 2001 From: "A.J. Shulman" Date: Thu, 8 May 2025 15:54:56 -0400 Subject: improve: enhance ChatBox UI with consistent styling and better accessibility MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit • Fixed dictation button styling to match send button dimensions and colors • Created dedicated DictationButton.scss for better button styling • Removed vertical movement animations from all buttons for a more stable UI • Fixed empty space issue below the "Show Agent Thoughts/Actions" button • Implemented consistent hover effects across all interactive elements • Ensured font size scaling works for agent thoughts/actions content • Used Dash blue colors (#487af0, #3b6cd7) for consistent branding • Improved microphone button state visualization with pulse animation --- .../nodes/chatbot/chatboxcomponents/ChatBox.tsx | 106 ++++++++++++++++++--- 1 file changed, 92 insertions(+), 14 deletions(-) (limited to 'src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx') diff --git a/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx b/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx index ba30cb42b..490739be6 100644 --- a/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx +++ b/src/client/views/nodes/chatbot/chatboxcomponents/ChatBox.tsx @@ -40,7 +40,6 @@ import { ASSISTANT_ROLE, AssistantMessage, CHUNK_TYPE, Citation, ProcessingInfo, import { Vectorstore } from '../vectorstore/Vectorstore'; import './ChatBox.scss'; import MessageComponentBox from './MessageComponent'; -import { ProgressBar } from './ProgressBar'; import { OpenWhere } from '../../OpenWhere'; import { Upload } from '../../../../../server/SharedMediaTypes'; import { DocumentMetadataTool } from '../tools/DocumentMetadataTool'; @@ -76,6 +75,8 @@ export class ChatBox extends ViewBoxAnnotatableComponent() { @observable private _linked_csv_files: { filename: string; id: string; text: string }[] = []; @observable private _isUploadingDocs: boolean = false; @observable private _citationPopup: { text: string; visible: boolean } = { text: '', visible: false }; + @observable private _isFontSizeModalOpen: boolean = false; + @observable private _fontSize: 'small' | 'normal' | 'large' | 'xlarge' = 'normal'; // Private properties for managing OpenAI API, vector store, agent, and UI elements private openai!: OpenAI; // Using definite assignment assertion @@ -147,6 +148,9 @@ export class ChatBox extends ViewBoxAnnotatableComponent() { this.dataDoc.data = JSON.stringify(serializableHistory); } ); + + // Initialize font size from saved preference + this.initFontSize(); } /** @@ -1074,12 +1078,61 @@ export class ChatBox extends ViewBoxAnnotatableComponent() { }; _dictation: DictationButton | null = null; + + /** + * Toggles the font size modal visibility + */ + @action + toggleFontSizeModal = () => { + this._isFontSizeModalOpen = !this._isFontSizeModalOpen; + }; + + /** + * Changes the font size and applies it to the chat interface + * @param size The new font size to apply + */ + @action + changeFontSize = (size: 'small' | 'normal' | 'large' | 'xlarge') => { + this._fontSize = size; + this._isFontSizeModalOpen = false; + + // Save preference to localStorage if needed + if (typeof window !== 'undefined') { + localStorage.setItem('chatbox-font-size', size); + } + }; + + /** + * Initializes font size from saved preference + */ + initFontSize = () => { + if (typeof window !== 'undefined') { + const savedSize = localStorage.getItem('chatbox-font-size'); + if (savedSize && ['small', 'normal', 'large', 'xlarge'].includes(savedSize)) { + this._fontSize = savedSize as 'small' | 'normal' | 'large' | 'xlarge'; + } + } + }; + + /** + * Renders a font size icon SVG + */ + renderFontSizeIcon = () => ( + + + + + + ); + /** * Renders the chat interface, including the message list, input field, and other UI elements. */ render() { + const fontSizeClass = `font-size-${this._fontSize}`; + return ( -
+
{this._isUploadingDocs && (
@@ -1095,6 +1148,29 @@ export class ChatBox extends ViewBoxAnnotatableComponent() { )}

{this.userName()}'s AI Assistant

+
+ {this.renderFontSizeIcon()} +
+ {this._isFontSizeModalOpen && ( +
+
this.changeFontSize('small')}> + Small + Aa +
+
this.changeFontSize('normal')}> + Normal + Aa +
+
this.changeFontSize('large')}> + Large + Aa +
+
this.changeFontSize('xlarge')}> + Extra Large + Aa +
+
+ )}
{this._history.map((message, index) => ( @@ -1106,18 +1182,20 @@ export class ChatBox extends ViewBoxAnnotatableComponent() {
- { - this._textInputRef = r; - }} - type="text" - name="messageInput" - autoComplete="off" - placeholder="Type your message here..." - value={this._inputValue} - onChange={action(e => (this._inputValue = e.target.value))} - disabled={this._isLoading} - /> +
+ { + this._textInputRef = r; + }} + type="text" + name="messageInput" + autoComplete="off" + placeholder="Type your message here..." + value={this._inputValue} + onChange={action(e => (this._inputValue = e.target.value))} + disabled={this._isLoading} + /> +