From 5b642f043f14f02c9dd812146f247c61cf4b4720 Mon Sep 17 00:00:00 2001 From: Jing Hua <59118459+ztjhz@users.noreply.github.com> Date: Wed, 19 Jul 2023 20:48:08 -0700 Subject: [PATCH] a11y button (#335) fixes issue #333 --- src/components/ApiMenu/ApiMenu.tsx | 1 + src/components/Chat/ChatContent/CloneChat.tsx | 6 ++++- .../Chat/ChatContent/DownloadChat.tsx | 4 ++++ .../Chat/ChatContent/Message/CodeBlock.tsx | 1 + .../Message/CommandPrompt/CommandPrompt.tsx | 4 ++-- .../ChatContent/Message/NewMessageButton.tsx | 6 ++++- .../Chat/ChatContent/Message/RoleSelector.tsx | 1 + .../Message/View/Button/BaseButton.tsx | 3 +++ .../Message/View/Button/CopyButton.tsx | 1 + .../Message/View/Button/DeleteButton.tsx | 6 ++++- .../Message/View/Button/DownButton.tsx | 8 ++++++- .../Message/View/Button/EditButton.tsx | 8 ++++++- .../View/Button/MarkdownModeButton.tsx | 1 + .../Message/View/Button/RefreshButton.tsx | 8 ++++++- .../Message/View/Button/UpButton.tsx | 1 + .../ChatContent/Message/View/ContentView.tsx | 7 +++++- .../ChatContent/Message/View/EditView.tsx | 4 ++++ .../Chat/ChatContent/ScrollToBottomButton.tsx | 1 + src/components/Chat/ChatInput.tsx | 5 +++- .../ChatConfigMenu/ChatConfigMenu.tsx | 6 ++++- src/components/ConfigMenu/ConfigMenu.tsx | 1 + .../GoogleSync/GoogleSyncButton.tsx | 12 ++++++++-- .../ImportExportChat/ExportChat.tsx | 1 + .../ImportExportChat/ImportChat.tsx | 1 + .../ImportExportChat/ImportChatOpenAI.tsx | 1 + .../LanguageSelector/LanguageSelector.tsx | 1 + src/components/Menu/ChatFolder.tsx | 23 ++++++++++++++++--- src/components/Menu/ChatHistory.tsx | 14 +++++++++-- .../Menu/MenuOptions/ClearConversation.tsx | 4 +++- .../Menu/MenuOptions/ThemeSwitcher.tsx | 1 + src/components/MobileBar/MobileBar.tsx | 2 ++ src/components/PopupModal/PopupModal.tsx | 3 +++ .../PromptLibraryMenu/ExportPrompt.tsx | 1 + .../PromptLibraryMenu/ImportPrompt.tsx | 1 + .../PromptLibraryMenu/PromptLibraryMenu.tsx | 6 ++++- src/components/ShareGPT/ShareGPT.tsx | 1 + .../StopGeneratingButton.tsx | 5 +++- 37 files changed, 139 insertions(+), 21 deletions(-) diff --git a/src/components/ApiMenu/ApiMenu.tsx b/src/components/ApiMenu/ApiMenu.tsx index 12a3b5d..23a99d1 100644 --- a/src/components/ApiMenu/ApiMenu.tsx +++ b/src/components/ApiMenu/ApiMenu.tsx @@ -132,6 +132,7 @@ const ApiEndpointSelector = ({ */} diff --git a/src/components/Chat/ChatContent/Message/View/Button/CopyButton.tsx b/src/components/Chat/ChatContent/Message/View/Button/CopyButton.tsx index 76ae6c6..6d2f177 100644 --- a/src/components/Chat/ChatContent/Message/View/Button/CopyButton.tsx +++ b/src/components/Chat/ChatContent/Message/View/Button/CopyButton.tsx @@ -15,6 +15,7 @@ const CopyButton = ({ return ( : } + buttonProps={{ 'aria-label': 'copy message' }} onClick={(e) => { onClick(e); setIsCopied(true); diff --git a/src/components/Chat/ChatContent/Message/View/Button/DeleteButton.tsx b/src/components/Chat/ChatContent/Message/View/Button/DeleteButton.tsx index 4853fd8..235e6d1 100644 --- a/src/components/Chat/ChatContent/Message/View/Button/DeleteButton.tsx +++ b/src/components/Chat/ChatContent/Message/View/Button/DeleteButton.tsx @@ -11,7 +11,11 @@ const DeleteButton = memo( setIsDelete: React.Dispatch>; }) => { return ( - } onClick={() => setIsDelete(true)} /> + } + buttonProps={{ 'aria-label': 'delete message' }} + onClick={() => setIsDelete(true)} + /> ); } ); diff --git a/src/components/Chat/ChatContent/Message/View/Button/DownButton.tsx b/src/components/Chat/ChatContent/Message/View/Button/DownButton.tsx index 8310be5..b42d836 100644 --- a/src/components/Chat/ChatContent/Message/View/Button/DownButton.tsx +++ b/src/components/Chat/ChatContent/Message/View/Button/DownButton.tsx @@ -9,7 +9,13 @@ const DownButton = ({ }: { onClick: React.MouseEventHandler; }) => { - return } onClick={onClick} />; + return ( + } + buttonProps={{ 'aria-label': 'shift message down' }} + onClick={onClick} + /> + ); }; export default DownButton; diff --git a/src/components/Chat/ChatContent/Message/View/Button/EditButton.tsx b/src/components/Chat/ChatContent/Message/View/Button/EditButton.tsx index 449b0d4..a1715e9 100644 --- a/src/components/Chat/ChatContent/Message/View/Button/EditButton.tsx +++ b/src/components/Chat/ChatContent/Message/View/Button/EditButton.tsx @@ -10,7 +10,13 @@ const EditButton = memo( }: { setIsEdit: React.Dispatch>; }) => { - return } onClick={() => setIsEdit(true)} />; + return ( + } + buttonProps={{ 'aria-label': 'edit message' }} + onClick={() => setIsEdit(true)} + /> + ); } ); diff --git a/src/components/Chat/ChatContent/Message/View/Button/MarkdownModeButton.tsx b/src/components/Chat/ChatContent/Message/View/Button/MarkdownModeButton.tsx index 402116b..60d6cbb 100644 --- a/src/components/Chat/ChatContent/Message/View/Button/MarkdownModeButton.tsx +++ b/src/components/Chat/ChatContent/Message/View/Button/MarkdownModeButton.tsx @@ -14,6 +14,7 @@ const MarkdownModeButton = () => { return ( : } + buttonProps={{ 'aria-label': 'toggle markdown mode' }} onClick={() => { setMarkdownMode(!markdownMode); }} diff --git a/src/components/Chat/ChatContent/Message/View/Button/RefreshButton.tsx b/src/components/Chat/ChatContent/Message/View/Button/RefreshButton.tsx index b294478..a270cd4 100644 --- a/src/components/Chat/ChatContent/Message/View/Button/RefreshButton.tsx +++ b/src/components/Chat/ChatContent/Message/View/Button/RefreshButton.tsx @@ -9,7 +9,13 @@ const RefreshButton = ({ }: { onClick: React.MouseEventHandler; }) => { - return } onClick={onClick} />; + return ( + } + buttonProps={{ 'aria-label': 'regenerate message' }} + onClick={onClick} + /> + ); }; export default RefreshButton; diff --git a/src/components/Chat/ChatContent/Message/View/Button/UpButton.tsx b/src/components/Chat/ChatContent/Message/View/Button/UpButton.tsx index bc40941..e8470d9 100644 --- a/src/components/Chat/ChatContent/Message/View/Button/UpButton.tsx +++ b/src/components/Chat/ChatContent/Message/View/Button/UpButton.tsx @@ -12,6 +12,7 @@ const UpButton = ({ return ( } + buttonProps={{ 'aria-label': 'shift message up' }} onClick={onClick} /> ); diff --git a/src/components/Chat/ChatContent/Message/View/ContentView.tsx b/src/components/Chat/ChatContent/Message/View/ContentView.tsx index d0d4724..ad4c415 100644 --- a/src/components/Chat/ChatContent/Message/View/ContentView.tsx +++ b/src/components/Chat/ChatContent/Message/View/ContentView.tsx @@ -158,11 +158,16 @@ const ContentView = memo( <> - diff --git a/src/components/Chat/ChatContent/Message/View/EditView.tsx b/src/components/Chat/ChatContent/Message/View/EditView.tsx index 9b91791..656e7ba 100644 --- a/src/components/Chat/ChatContent/Message/View/EditView.tsx +++ b/src/components/Chat/ChatContent/Message/View/EditView.tsx @@ -189,6 +189,7 @@ const EditViewButtons = memo( generating ? 'cursor-not-allowed opacity-40' : '' }`} onClick={handleSaveAndSubmit} + aria-label={t('saveAndSubmit') as string} >
{t('saveAndSubmit')} @@ -205,6 +206,7 @@ const EditViewButtons = memo( : 'btn-primary' }`} onClick={handleSave} + aria-label={t('save') as string} >
{t('save')} @@ -217,6 +219,7 @@ const EditViewButtons = memo( onClick={() => { !generating && setIsModalOpen(true); }} + aria-label={t('saveAndSubmit') as string} >
{t('saveAndSubmit')} @@ -228,6 +231,7 @@ const EditViewButtons = memo(
diff --git a/src/components/ChatConfigMenu/ChatConfigMenu.tsx b/src/components/ChatConfigMenu/ChatConfigMenu.tsx index 8bef767..cc9e049 100644 --- a/src/components/ChatConfigMenu/ChatConfigMenu.tsx +++ b/src/components/ChatConfigMenu/ChatConfigMenu.tsx @@ -20,7 +20,11 @@ const ChatConfigMenu = () => { const [isModalOpen, setIsModalOpen] = useState(false); return (
- {isModalOpen && } diff --git a/src/components/ConfigMenu/ConfigMenu.tsx b/src/components/ConfigMenu/ConfigMenu.tsx index f8ad002..52f5c39 100644 --- a/src/components/ConfigMenu/ConfigMenu.tsx +++ b/src/components/ConfigMenu/ConfigMenu.tsx @@ -86,6 +86,7 @@ export const ModelSelector = ({ className='btn btn-neutral btn-small flex gap-1' type='button' onClick={() => setDropDown((prev) => !prev)} + aria-label='model' > {_model} diff --git a/src/components/GoogleSync/GoogleSyncButton.tsx b/src/components/GoogleSync/GoogleSyncButton.tsx index 69d21ec..3a1c43f 100644 --- a/src/components/GoogleSync/GoogleSyncButton.tsx +++ b/src/components/GoogleSync/GoogleSyncButton.tsx @@ -52,11 +52,19 @@ const GoogleSyncButton = ({ loginHandler }: { loginHandler?: () => void }) => { return (
- {cloudSync && ( - )} diff --git a/src/components/ImportExportChat/ExportChat.tsx b/src/components/ImportExportChat/ExportChat.tsx index c4ef881..f451533 100644 --- a/src/components/ImportExportChat/ExportChat.tsx +++ b/src/components/ImportExportChat/ExportChat.tsx @@ -26,6 +26,7 @@ const ExportChat = () => { }; downloadFile(fileData, getToday()); }} + aria-label={t('export') as string} > {t('export')} diff --git a/src/components/ImportExportChat/ImportChat.tsx b/src/components/ImportExportChat/ImportChat.tsx index 6562dd5..eb6a736 100644 --- a/src/components/ImportExportChat/ImportChat.tsx +++ b/src/components/ImportExportChat/ImportChat.tsx @@ -152,6 +152,7 @@ const ImportChat = () => { diff --git a/src/components/ImportExportChat/ImportChatOpenAI.tsx b/src/components/ImportExportChat/ImportChatOpenAI.tsx index 734aadb..b3022dc 100644 --- a/src/components/ImportExportChat/ImportChatOpenAI.tsx +++ b/src/components/ImportExportChat/ImportChatOpenAI.tsx @@ -68,6 +68,7 @@ const ImportChatOpenAI = ({ diff --git a/src/components/LanguageSelector/LanguageSelector.tsx b/src/components/LanguageSelector/LanguageSelector.tsx index f5f5d23..fab1268 100644 --- a/src/components/LanguageSelector/LanguageSelector.tsx +++ b/src/components/LanguageSelector/LanguageSelector.tsx @@ -14,6 +14,7 @@ const LanguageSelector = () => { className='btn btn-neutral btn-small w-36 flex justify-between' type='button' onClick={() => setDropDown((prev) => !prev)} + aria-label='language selector' > {languageCodeToName[i18n.language as keyof typeof languageCodeToName] ?? i18n.language} diff --git a/src/components/Menu/ChatFolder.tsx b/src/components/Menu/ChatFolder.tsx index 383e7c2..42b144c 100644 --- a/src/components/Menu/ChatFolder.tsx +++ b/src/components/Menu/ChatFolder.tsx @@ -211,10 +211,18 @@ const ChatFolder = ({ > {isDelete || isEdit ? ( <> - - @@ -229,6 +237,7 @@ const ChatFolder = ({ onClick={() => { setShowPalette((prev) => !prev); }} + aria-label='folder color' > @@ -243,12 +252,14 @@ const ChatFolder = ({ onClick={() => { updateColor(c); }} + aria-label={c} /> ))} @@ -260,16 +271,22 @@ const ChatFolder = ({ - - @@ -143,12 +151,14 @@ const ChatHistory = React.memo( diff --git a/src/components/Menu/MenuOptions/ClearConversation.tsx b/src/components/Menu/MenuOptions/ClearConversation.tsx index 0926998..7ce1d60 100644 --- a/src/components/Menu/MenuOptions/ClearConversation.tsx +++ b/src/components/Menu/MenuOptions/ClearConversation.tsx @@ -21,10 +21,12 @@ const ClearConversation = () => { return ( <> - diff --git a/src/components/PopupModal/PopupModal.tsx b/src/components/PopupModal/PopupModal.tsx index 55fac05..dbe91a3 100644 --- a/src/components/PopupModal/PopupModal.tsx +++ b/src/components/PopupModal/PopupModal.tsx @@ -49,6 +49,7 @@ const PopupModal = ({ type='button' className='text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm p-1.5 ml-auto inline-flex items-center dark:hover:bg-gray-600 dark:hover:text-white' onClick={_handleClose} + aria-label='close modal' > @@ -70,6 +71,7 @@ const PopupModal = ({ type='button' className='btn btn-primary' onClick={handleConfirm} + aria-label='confirm' > {t('confirm')} @@ -79,6 +81,7 @@ const PopupModal = ({ type='button' className='btn btn-neutral' onClick={_handleClose} + aria-label='cancel' > {t('cancel')} diff --git a/src/components/PromptLibraryMenu/ExportPrompt.tsx b/src/components/PromptLibraryMenu/ExportPrompt.tsx index ef2b1cd..f4856e9 100644 --- a/src/components/PromptLibraryMenu/ExportPrompt.tsx +++ b/src/components/PromptLibraryMenu/ExportPrompt.tsx @@ -17,6 +17,7 @@ const ExportPrompt = () => { onClick={() => { exportPrompts(prompts); }} + aria-label={t('export') as string} > {t('export')} diff --git a/src/components/PromptLibraryMenu/ImportPrompt.tsx b/src/components/PromptLibraryMenu/ImportPrompt.tsx index 080f2de..23fdc7e 100644 --- a/src/components/PromptLibraryMenu/ImportPrompt.tsx +++ b/src/components/PromptLibraryMenu/ImportPrompt.tsx @@ -63,6 +63,7 @@ const ImportPrompt = () => { diff --git a/src/components/PromptLibraryMenu/PromptLibraryMenu.tsx b/src/components/PromptLibraryMenu/PromptLibraryMenu.tsx index 61ec6fe..9d4f183 100644 --- a/src/components/PromptLibraryMenu/PromptLibraryMenu.tsx +++ b/src/components/PromptLibraryMenu/PromptLibraryMenu.tsx @@ -15,7 +15,11 @@ const PromptLibraryMenu = () => { const [isModalOpen, setIsModalOpen] = useState(false); return (
- {isModalOpen && ( diff --git a/src/components/ShareGPT/ShareGPT.tsx b/src/components/ShareGPT/ShareGPT.tsx index 12e4593..f9b4cc8 100644 --- a/src/components/ShareGPT/ShareGPT.tsx +++ b/src/components/ShareGPT/ShareGPT.tsx @@ -45,6 +45,7 @@ const ShareGPT = React.memo(() => { onClick={() => { setIsModalOpen(true); }} + aria-label={t('postOnShareGPT.title') as string} > {t('postOnShareGPT.title')} diff --git a/src/components/StopGeneratingButton/StopGeneratingButton.tsx b/src/components/StopGeneratingButton/StopGeneratingButton.tsx index e3c7fba..295c0fd 100644 --- a/src/components/StopGeneratingButton/StopGeneratingButton.tsx +++ b/src/components/StopGeneratingButton/StopGeneratingButton.tsx @@ -10,7 +10,10 @@ const StopGeneratingButton = () => { className='absolute bottom-6 left-0 right-0 m-auto flex md:w-full md:m-auto gap-0 md:gap-2 justify-center' onClick={() => setGenerating(false)} > -