chore(UI, accessibility): more items

- radio icon buttons
- links should be parent of icon
styled links to still line up with sibling components
This commit is contained in:
ElrikUnderlake 2023-03-12 15:50:14 -05:00
parent 60614badaf
commit e3aef20f42
No known key found for this signature in database
GPG Key ID: E9A5CF18AF6E2C67
3 changed files with 53 additions and 40 deletions

View File

@ -8,13 +8,14 @@ import {
import { memo } from 'react'; import { memo } from 'react';
export type IAIIconButtonProps = IconButtonProps & { export type IAIIconButtonProps = IconButtonProps & {
role?: string;
tooltip?: string; tooltip?: string;
tooltipProps?: Omit<TooltipProps, 'children'>; tooltipProps?: Omit<TooltipProps, 'children'>;
isChecked?: boolean; isChecked?: boolean;
}; };
const IAIIconButton = forwardRef((props: IAIIconButtonProps, forwardedRef) => { const IAIIconButton = forwardRef((props: IAIIconButtonProps, forwardedRef) => {
const { tooltip = '', tooltipProps, isChecked, ...rest } = props; const { role, tooltip = '', tooltipProps, isChecked, ...rest } = props;
return ( return (
<Tooltip <Tooltip
@ -27,6 +28,7 @@ const IAIIconButton = forwardRef((props: IAIIconButtonProps, forwardedRef) => {
> >
<IconButton <IconButton
ref={forwardedRef} ref={forwardedRef}
role={role}
aria-checked={isChecked !== undefined ? isChecked : undefined} aria-checked={isChecked !== undefined ? isChecked : undefined}
{...rest} {...rest}
/> />
@ -34,4 +36,5 @@ const IAIIconButton = forwardRef((props: IAIIconButtonProps, forwardedRef) => {
); );
}); });
IAIIconButton.displayName = 'IAIIconButton';
export default memo(IAIIconButton); export default memo(IAIIconButton);

View File

@ -101,12 +101,14 @@ const ImageGalleryContent = () => {
aria-label={t('gallery.showGenerations')} aria-label={t('gallery.showGenerations')}
tooltip={t('gallery.showGenerations')} tooltip={t('gallery.showGenerations')}
isChecked={currentCategory === 'result'} isChecked={currentCategory === 'result'}
role="radio"
icon={<FaImage />} icon={<FaImage />}
onClick={() => dispatch(setCurrentCategory('result'))} onClick={() => dispatch(setCurrentCategory('result'))}
/> />
<IAIIconButton <IAIIconButton
aria-label={t('gallery.showUploads')} aria-label={t('gallery.showUploads')}
tooltip={t('gallery.showUploads')} tooltip={t('gallery.showUploads')}
role="radio"
isChecked={currentCategory === 'user'} isChecked={currentCategory === 'user'}
icon={<FaUser />} icon={<FaUser />}
onClick={() => dispatch(setCurrentCategory('user'))} onClick={() => dispatch(setCurrentCategory('user'))}
@ -251,4 +253,5 @@ const ImageGalleryContent = () => {
); );
}; };
ImageGalleryContent.displayName = 'ImageGalleryContent';
export default ImageGalleryContent; export default ImageGalleryContent;

View File

@ -61,6 +61,11 @@ const SiteHeader = () => {
<LanguagePicker /> <LanguagePicker />
<Link
isExternal
href="http://github.com/invoke-ai/InvokeAI/issues"
marginBottom="-0.25rem"
>
<IAIIconButton <IAIIconButton
aria-label={t('common.reportBugLabel')} aria-label={t('common.reportBugLabel')}
tooltip={t('common.reportBugLabel')} tooltip={t('common.reportBugLabel')}
@ -68,13 +73,15 @@ const SiteHeader = () => {
data-variant="link" data-variant="link"
fontSize={20} fontSize={20}
size="sm" size="sm"
icon={ icon={<FaBug />}
<Link isExternal href="http://github.com/invoke-ai/InvokeAI/issues">
<FaBug />
</Link>
}
/> />
</Link>
<Link
isExternal
href="http://github.com/invoke-ai/InvokeAI"
marginBottom="-0.25rem"
>
<IAIIconButton <IAIIconButton
aria-label={t('common.githubLabel')} aria-label={t('common.githubLabel')}
tooltip={t('common.githubLabel')} tooltip={t('common.githubLabel')}
@ -82,13 +89,15 @@ const SiteHeader = () => {
data-variant="link" data-variant="link"
fontSize={20} fontSize={20}
size="sm" size="sm"
icon={ icon={<FaGithub />}
<Link isExternal href="http://github.com/invoke-ai/InvokeAI">
<FaGithub />
</Link>
}
/> />
</Link>
<Link
isExternal
href="https://discord.gg/ZmtBAhwWhy"
marginBottom="-0.25rem"
>
<IAIIconButton <IAIIconButton
aria-label={t('common.discordLabel')} aria-label={t('common.discordLabel')}
tooltip={t('common.discordLabel')} tooltip={t('common.discordLabel')}
@ -96,12 +105,9 @@ const SiteHeader = () => {
data-variant="link" data-variant="link"
fontSize={20} fontSize={20}
size="sm" size="sm"
icon={ icon={<FaDiscord />}
<Link isExternal href="https://discord.gg/ZmtBAhwWhy">
<FaDiscord />
</Link>
}
/> />
</Link>
<SettingsModal> <SettingsModal>
<IAIIconButton <IAIIconButton
@ -119,4 +125,5 @@ const SiteHeader = () => {
); );
}; };
SiteHeader.displayName = 'SiteHeader';
export default SiteHeader; export default SiteHeader;