chore(accessibility): add all aria-labels

This commit is contained in:
ElrikUnderlake 2023-03-10 20:49:16 -06:00
parent 685df33584
commit e9f237f39d
No known key found for this signature in database
GPG Key ID: E9A5CF18AF6E2C67
11 changed files with 59 additions and 20 deletions

View File

@ -1,7 +1,25 @@
{ {
"accessibility": { "accessibility": {
"modelSelect": "Model Select", "modelSelect": "Model Select",
"invokeProgressBar": "Invoke progress bar" "invokeProgressBar": "Invoke progress bar",
"reset": "Reset",
"uploadImage": "Upload Image",
"previousImage": "Previous Image",
"nextImage": "Next Image",
"useThisParameter": "Use this parameter",
"copyMetadataJson": "Copy metadata JSON",
"exitViewer": "ExitViewer",
"zoomIn": "Zoom In",
"zoomOut": "Zoom Out",
"rotateCounterClockwise": "Rotate Counter-Clockwise",
"rotateClockwise": "Rotate Clockwise",
"flipHorizontally": "Flip Horizontally",
"flipVertically": "Flip Vertically",
"modifyConfig": "Modify Config",
"toggleAutoscroll": "Toggle autoscroll",
"toggleLogViewer": "Toggle Log Viewer",
"showGallery": "Show Gallery",
"showOptionsPanel": "Show Options Panel"
}, },
"common": { "common": {
"hotkeysLabel": "Hotkeys", "hotkeysLabel": "Hotkeys",

View File

@ -26,6 +26,7 @@ import {
import { clamp } from 'lodash'; import { clamp } from 'lodash';
import { FocusEvent, useEffect, useMemo, useState } from 'react'; import { FocusEvent, useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { BiReset } from 'react-icons/bi'; import { BiReset } from 'react-icons/bi';
import IAIIconButton, { IAIIconButtonProps } from './IAIIconButton'; import IAIIconButton, { IAIIconButtonProps } from './IAIIconButton';
@ -96,6 +97,8 @@ export default function IAISlider(props: IAIFullSliderProps) {
...rest ...rest
} = props; } = props;
const { t } = useTranslation();
const [localInputValue, setLocalInputValue] = useState< const [localInputValue, setLocalInputValue] = useState<
string | number | undefined string | number | undefined
>(String(value)); >(String(value));
@ -234,7 +237,7 @@ export default function IAISlider(props: IAIFullSliderProps) {
{withReset && ( {withReset && (
<IAIIconButton <IAIIconButton
size="sm" size="sm"
aria-label="Reset" aria-label={t('accessibility.reset')}
tooltip="Reset" tooltip="Reset"
icon={<BiReset />} icon={<BiReset />}
onClick={handleResetDisable} onClick={handleResetDisable}

View File

@ -1,14 +1,16 @@
import { ImageUploaderTriggerContext } from 'app/contexts/ImageUploaderTriggerContext'; import { ImageUploaderTriggerContext } from 'app/contexts/ImageUploaderTriggerContext';
import { useContext } from 'react'; import { useContext } from 'react';
import { useTranslation } from 'react-i18next';
import { FaUpload } from 'react-icons/fa'; import { FaUpload } from 'react-icons/fa';
import IAIIconButton from './IAIIconButton'; import IAIIconButton from './IAIIconButton';
const ImageUploaderIconButton = () => { const ImageUploaderIconButton = () => {
const { t } = useTranslation();
const openImageUploader = useContext(ImageUploaderTriggerContext); const openImageUploader = useContext(ImageUploaderTriggerContext);
return ( return (
<IAIIconButton <IAIIconButton
aria-label="Upload Image" aria-label={t('accessibility.uploadImage')}
tooltip="Upload Image" tooltip="Upload Image"
icon={<FaUpload />} icon={<FaUpload />}
onClick={openImageUploader || undefined} onClick={openImageUploader || undefined}

View File

@ -42,6 +42,7 @@ import {
import { setShouldShowImageDetails } from 'features/ui/store/uiSlice'; import { setShouldShowImageDetails } from 'features/ui/store/uiSlice';
import { memo } from 'react'; import { memo } from 'react';
import { useHotkeys } from 'react-hotkeys-hook'; import { useHotkeys } from 'react-hotkeys-hook';
import { useTranslation } from 'react-i18next';
import { FaCopy } from 'react-icons/fa'; import { FaCopy } from 'react-icons/fa';
import { IoArrowUndoCircleOutline } from 'react-icons/io5'; import { IoArrowUndoCircleOutline } from 'react-icons/io5';
import { APP_METADATA_HEIGHT } from 'theme/util/constants'; import { APP_METADATA_HEIGHT } from 'theme/util/constants';
@ -66,12 +67,14 @@ const MetadataItem = ({
labelPosition, labelPosition,
withCopy = false, withCopy = false,
}: MetadataItemProps) => { }: MetadataItemProps) => {
const { t } = useTranslation();
return ( return (
<Flex gap={2}> <Flex gap={2}>
{onClick && ( {onClick && (
<Tooltip label={`Recall ${label}`}> <Tooltip label={`Recall ${label}`}>
<IconButton <IconButton
aria-label="Use this parameter" aria-label={t('accessibility.useThisParameter')}
icon={<IoArrowUndoCircleOutline />} icon={<IoArrowUndoCircleOutline />}
size="xs" size="xs"
variant="ghost" variant="ghost"
@ -162,6 +165,8 @@ const ImageMetadataViewer = memo(
width, width,
} = metadata; } = metadata;
const { t } = useTranslation();
const metadataJSON = JSON.stringify(image.metadata, null, 2); const metadataJSON = JSON.stringify(image.metadata, null, 2);
return ( return (
@ -422,7 +427,7 @@ const ImageMetadataViewer = memo(
<Flex gap={2}> <Flex gap={2}>
<Tooltip label="Copy metadata JSON"> <Tooltip label="Copy metadata JSON">
<IconButton <IconButton
aria-label="Copy metadata JSON" aria-label={t('accessibility.copyMetadataJson')}
icon={<FaCopy />} icon={<FaCopy />}
size="xs" size="xs"
variant="ghost" variant="ghost"

View File

@ -3,6 +3,7 @@ import { createSelector } from '@reduxjs/toolkit';
import { useAppDispatch, useAppSelector } from 'app/storeHooks'; import { useAppDispatch, useAppSelector } from 'app/storeHooks';
import { isEqual } from 'lodash'; import { isEqual } from 'lodash';
import { useState } from 'react'; import { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { FaAngleLeft, FaAngleRight } from 'react-icons/fa'; import { FaAngleLeft, FaAngleRight } from 'react-icons/fa';
import { gallerySelector } from '../store/gallerySelectors'; import { gallerySelector } from '../store/gallerySelectors';
import { import {
@ -51,6 +52,7 @@ export const nextPrevImageButtonsSelector = createSelector(
const NextPrevImageButtons = () => { const NextPrevImageButtons = () => {
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const { t } = useTranslation();
const { isOnFirstImage, isOnLastImage } = useAppSelector( const { isOnFirstImage, isOnLastImage } = useAppSelector(
nextPrevImageButtonsSelector nextPrevImageButtonsSelector
@ -95,7 +97,7 @@ const NextPrevImageButtons = () => {
> >
{shouldShowNextPrevButtons && !isOnFirstImage && ( {shouldShowNextPrevButtons && !isOnFirstImage && (
<IconButton <IconButton
aria-label="Previous image" aria-label={t('accessibility.previousImage')}
icon={<FaAngleLeft size={64} />} icon={<FaAngleLeft size={64} />}
variant="unstyled" variant="unstyled"
onClick={handleClickPrevButton} onClick={handleClickPrevButton}
@ -114,7 +116,7 @@ const NextPrevImageButtons = () => {
> >
{shouldShowNextPrevButtons && !isOnLastImage && ( {shouldShowNextPrevButtons && !isOnLastImage && (
<IconButton <IconButton
aria-label="Next image" aria-label={t('accessibility.nextImage')}
icon={<FaAngleRight size={64} />} icon={<FaAngleRight size={64} />}
variant="unstyled" variant="unstyled"
onClick={handleClickNextButton} onClick={handleClickNextButton}

View File

@ -38,6 +38,7 @@ export const lightboxSelector = createSelector(
export default function Lightbox() { export default function Lightbox() {
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const { t } = useTranslation();
const isLightBoxOpen = useAppSelector( const isLightBoxOpen = useAppSelector(
(state: RootState) => state.lightbox.isLightboxOpen (state: RootState) => state.lightbox.isLightboxOpen
); );
@ -96,7 +97,7 @@ export default function Lightbox() {
> >
<IAIIconButton <IAIIconButton
icon={<BiExit />} icon={<BiExit />}
aria-label="Exit Viewer" aria-label={t('accessibility.exitViewer')}
onClick={() => { onClick={() => {
dispatch(setIsLightboxOpen(false)); dispatch(setIsLightboxOpen(false));
}} }}

View File

@ -1,5 +1,6 @@
import { ButtonGroup } from '@chakra-ui/react'; import { ButtonGroup } from '@chakra-ui/react';
import IAIIconButton from 'common/components/IAIIconButton'; import IAIIconButton from 'common/components/IAIIconButton';
import { useTranslation } from 'react-i18next';
import { import {
BiReset, BiReset,
BiRotateLeft, BiRotateLeft,
@ -26,12 +27,13 @@ const ReactPanZoomButtons = ({
reset, reset,
}: ReactPanZoomButtonsProps) => { }: ReactPanZoomButtonsProps) => {
const { zoomIn, zoomOut, resetTransform } = useTransformContext(); const { zoomIn, zoomOut, resetTransform } = useTransformContext();
const { t } = useTranslation();
return ( return (
<ButtonGroup isAttached orientation="vertical"> <ButtonGroup isAttached orientation="vertical">
<IAIIconButton <IAIIconButton
icon={<BiZoomIn />} icon={<BiZoomIn />}
aria-label="Zoom In" aria-label={t('accessibility.zoomIn')}
tooltip="Zoom In" tooltip="Zoom In"
onClick={() => zoomIn()} onClick={() => zoomIn()}
fontSize={20} fontSize={20}
@ -39,7 +41,7 @@ const ReactPanZoomButtons = ({
<IAIIconButton <IAIIconButton
icon={<BiZoomOut />} icon={<BiZoomOut />}
aria-label="Zoom Out" aria-label={t('accessibility.zoomOut')}
tooltip="Zoom Out" tooltip="Zoom Out"
onClick={() => zoomOut()} onClick={() => zoomOut()}
fontSize={20} fontSize={20}
@ -47,7 +49,7 @@ const ReactPanZoomButtons = ({
<IAIIconButton <IAIIconButton
icon={<BiRotateLeft />} icon={<BiRotateLeft />}
aria-label="Rotate Counter-Clockwise" aria-label={t('accessibility.rotateCounterClockwise')}
tooltip="Rotate Counter-Clockwise" tooltip="Rotate Counter-Clockwise"
onClick={rotateCounterClockwise} onClick={rotateCounterClockwise}
fontSize={20} fontSize={20}
@ -55,7 +57,7 @@ const ReactPanZoomButtons = ({
<IAIIconButton <IAIIconButton
icon={<BiRotateRight />} icon={<BiRotateRight />}
aria-label="Rotate Clockwise" aria-label={t('accessibility.rotateClockwise')}
tooltip="Rotate Clockwise" tooltip="Rotate Clockwise"
onClick={rotateClockwise} onClick={rotateClockwise}
fontSize={20} fontSize={20}
@ -63,7 +65,7 @@ const ReactPanZoomButtons = ({
<IAIIconButton <IAIIconButton
icon={<MdFlip />} icon={<MdFlip />}
aria-label="Flip Horizontally" aria-label={t('accessibility.flipHorizontally')}
tooltip="Flip Horizontally" tooltip="Flip Horizontally"
onClick={flipHorizontally} onClick={flipHorizontally}
fontSize={20} fontSize={20}
@ -71,7 +73,7 @@ const ReactPanZoomButtons = ({
<IAIIconButton <IAIIconButton
icon={<MdFlip style={{ transform: 'rotate(90deg)' }} />} icon={<MdFlip style={{ transform: 'rotate(90deg)' }} />}
aria-label="Flip Vertically" aria-label={t('accessibility.flipVertically')}
tooltip="Flip Vertically" tooltip="Flip Vertically"
onClick={flipVertically} onClick={flipVertically}
fontSize={20} fontSize={20}
@ -79,7 +81,7 @@ const ReactPanZoomButtons = ({
<IAIIconButton <IAIIconButton
icon={<BiReset />} icon={<BiReset />}
aria-label="Reset" aria-label={t('accessibility.reset')}
tooltip="Reset" tooltip="Reset"
onClick={() => { onClick={() => {
resetTransform(); resetTransform();

View File

@ -11,6 +11,7 @@ import { isEqual } from 'lodash';
import { Resizable } from 're-resizable'; import { Resizable } from 're-resizable';
import { useLayoutEffect, useRef, useState } from 'react'; import { useLayoutEffect, useRef, useState } from 'react';
import { useHotkeys } from 'react-hotkeys-hook'; import { useHotkeys } from 'react-hotkeys-hook';
import { useTranslation } from 'react-i18next';
import { FaAngleDoubleDown, FaCode, FaMinus } from 'react-icons/fa'; import { FaAngleDoubleDown, FaCode, FaMinus } from 'react-icons/fa';
import { systemSelector } from '../store/systemSelectors'; import { systemSelector } from '../store/systemSelectors';
@ -46,6 +47,7 @@ const consoleSelector = createSelector(
*/ */
const Console = () => { const Console = () => {
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const { t } = useTranslation();
const log = useAppSelector(logSelector); const log = useAppSelector(logSelector);
const { shouldShowLogViewer, hasError, wasErrorSeen } = const { shouldShowLogViewer, hasError, wasErrorSeen } =
useAppSelector(consoleSelector); useAppSelector(consoleSelector);
@ -156,7 +158,7 @@ const Console = () => {
> >
<IAIIconButton <IAIIconButton
size="sm" size="sm"
aria-label="Toggle autoscroll" aria-label={t('accessibility.toggleAutoscroll')}
icon={<FaAngleDoubleDown />} icon={<FaAngleDoubleDown />}
onClick={() => setShouldAutoscroll(!shouldAutoscroll)} onClick={() => setShouldAutoscroll(!shouldAutoscroll)}
isChecked={shouldAutoscroll} isChecked={shouldAutoscroll}
@ -175,7 +177,7 @@ const Console = () => {
> >
<IAIIconButton <IAIIconButton
size="sm" size="sm"
aria-label="Toggle Log Viewer" aria-label={t('accessibility.toggleLogViewer')}
icon={shouldShowLogViewer ? <FaMinus /> : <FaCode />} icon={shouldShowLogViewer ? <FaMinus /> : <FaCode />}
onClick={handleClickLogViewerToggle} onClick={handleClickLogViewerToggle}
sx={{ sx={{

View File

@ -94,7 +94,7 @@ export default function ModelListItem(props: ModelListItemProps) {
icon={<EditIcon />} icon={<EditIcon />}
size="sm" size="sm"
onClick={openModelHandler} onClick={openModelHandler}
aria-label="Modify Config" aria-label={t('accessibility.modifyConfig')}
isDisabled={status === 'active' || isProcessing || !isConnected} isDisabled={status === 'active' || isProcessing || !isConnected}
/> />
<IAIAlertDialog <IAIAlertDialog

View File

@ -2,10 +2,12 @@ import { useAppDispatch, useAppSelector } from 'app/storeHooks';
import IAIIconButton from 'common/components/IAIIconButton'; import IAIIconButton from 'common/components/IAIIconButton';
import { setDoesCanvasNeedScaling } from 'features/canvas/store/canvasSlice'; import { setDoesCanvasNeedScaling } from 'features/canvas/store/canvasSlice';
import { setShouldShowGallery } from 'features/gallery/store/gallerySlice'; import { setShouldShowGallery } from 'features/gallery/store/gallerySlice';
import { useTranslation } from 'react-i18next';
import { MdPhotoLibrary } from 'react-icons/md'; import { MdPhotoLibrary } from 'react-icons/md';
import { floatingSelector } from './FloatingParametersPanelButtons'; import { floatingSelector } from './FloatingParametersPanelButtons';
const FloatingGalleryButton = () => { const FloatingGalleryButton = () => {
const { t } = useTranslation();
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const { shouldShowGalleryButton, shouldPinGallery } = const { shouldShowGalleryButton, shouldPinGallery } =
useAppSelector(floatingSelector); useAppSelector(floatingSelector);
@ -21,7 +23,7 @@ const FloatingGalleryButton = () => {
<IAIIconButton <IAIIconButton
tooltip="Show Gallery (G)" tooltip="Show Gallery (G)"
tooltipProps={{ placement: 'top' }} tooltipProps={{ placement: 'top' }}
aria-label="Show Gallery" aria-label={t('accessibility.showGallery')}
onClick={handleShowGallery} onClick={handleShowGallery}
sx={{ sx={{
pos: 'absolute', pos: 'absolute',

View File

@ -13,6 +13,7 @@ import {
} from 'features/ui/store/uiSelectors'; } from 'features/ui/store/uiSelectors';
import { setShouldShowParametersPanel } from 'features/ui/store/uiSlice'; import { setShouldShowParametersPanel } from 'features/ui/store/uiSlice';
import { isEqual } from 'lodash'; import { isEqual } from 'lodash';
import { useTranslation } from 'react-i18next';
import { FaSlidersH } from 'react-icons/fa'; import { FaSlidersH } from 'react-icons/fa';
@ -68,6 +69,7 @@ export const floatingSelector = createSelector(
const FloatingParametersPanelButtons = () => { const FloatingParametersPanelButtons = () => {
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const { t } = useTranslation();
const { const {
shouldShowParametersPanelButton, shouldShowParametersPanelButton,
shouldShowProcessButtons, shouldShowProcessButtons,
@ -95,7 +97,7 @@ const FloatingParametersPanelButtons = () => {
<IAIIconButton <IAIIconButton
tooltip="Show Options Panel (O)" tooltip="Show Options Panel (O)"
tooltipProps={{ placement: 'top' }} tooltipProps={{ placement: 'top' }}
aria-label="Show Options Panel" aria-label={t('accessibility.showOptionsPanel')}
onClick={handleShowOptionsPanel} onClick={handleShowOptionsPanel}
sx={floatingButtonStyles} sx={floatingButtonStyles}
> >