Fix social links accessibility (#112)

This commit is contained in:
Szymon Kin 2022-12-04 18:42:11 +01:00 committed by GitHub
parent 47a23ca34a
commit 4307e95b64
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 20 additions and 7 deletions

View file

@ -9,6 +9,7 @@ export interface Props {
target?: astroHTML.JSX.AnchorHTMLAttributes['target']; target?: astroHTML.JSX.AnchorHTMLAttributes['target'];
href: string; href: string;
size: IconButtonSize; size: IconButtonSize;
'aria-label'?: astroHTML.JSX.AnchorHTMLAttributes['aria-label'];
} }
const sizeMap: Record<IconButtonSize, string> = { const sizeMap: Record<IconButtonSize, string> = {
@ -16,7 +17,7 @@ const sizeMap: Record<IconButtonSize, string> = {
large: 'w-9 h-9', large: 'w-9 h-9',
}; };
const { icon, href, target, size } = Astro.props; const { icon, href, target, size, ...rest } = Astro.props;
--- ---
<a <a
@ -36,6 +37,7 @@ const { icon, href, target, size } = Astro.props;
'focus:ring-primary-500', 'focus:ring-primary-500',
sizeMap[size], sizeMap[size],
]} ]}
{...rest}
> >
<Icon client:load name={icon} size={16} /> <Icon client:load name={icon} size={16} />
</a> </a>

View file

@ -27,6 +27,7 @@ const SidebarItem = ({ section, icon, title = '' }: SidebarItemProps) => {
${active ? 'bg-primary-600 text-white' : 'bg-white text-gray-400 hover:bg-primary-600 hover:text-white'} ${active ? 'bg-primary-600 text-white' : 'bg-white text-gray-400 hover:bg-primary-600 hover:text-white'}
`} `}
aria-current={active ? 'page' : undefined} aria-current={active ? 'page' : undefined}
aria-label={`${section} section`}
> >
<Icon name={icon} size={20} /> <Icon name={icon} size={20} />
</a> </a>

View file

@ -46,7 +46,11 @@ const { alt, ...sharedImageProps } = {
/> />
</div> </div>
<div class:list={['flex', 'gap-2']}> <div class:list={['flex', 'gap-2']}>
{socials?.map(({ icon, url }) => <IconButton icon={icon} href={url} target="_blank" size="small" />)} {
socials?.map(({ icon, url, name: socialName }) => (
<IconButton icon={icon} href={url} target="_blank" size="small" aria-label={socialName} />
))
}
</div> </div>
</div> </div>
<Image <Image

View file

@ -26,8 +26,8 @@ const {
{ {
socials && ( socials && (
<div class:list={['flex', 'gap-3']}> <div class:list={['flex', 'gap-3']}>
{socials.map(({ icon, url }) => ( {socials.map(({ icon, url, name }) => (
<IconButton icon={icon} href={url} target="_blank" size="small" /> <IconButton icon={icon} href={url} target="_blank" size="small" aria-label={name} />
))} ))}
</div> </div>
) )

View file

@ -22,7 +22,11 @@ const WorkTimelineItem = 'div';
</Typography> </Typography>
</div> </div>
<div class:list={['flex', 'flex-wrap', 'gap-2']}> <div class:list={['flex', 'flex-wrap', 'gap-2']}>
{job.socials?.map(({ icon, url }) => <IconButton icon={icon} href={url} target="_blank" size="small" />)} {
job.socials?.map(({ icon, url, name }) => (
<IconButton icon={icon} href={url} target="_blank" size="small" aria-label={name} />
))
}
</div> </div>
</div> </div>
<Timestamp <Timestamp

View file

@ -32,6 +32,8 @@ const section: Section = 'main';
src={image} src={image}
alt={fullName} alt={fullName}
class:list={['w-24', 'h-24', 'sm:w-36', 'sm:h-36', 'md:w-52', 'md:h-52', 'rounded-lg', 'max-w-none']} class:list={['w-24', 'h-24', 'sm:w-36', 'sm:h-36', 'md:w-52', 'md:h-52', 'rounded-lg', 'max-w-none']}
format="webp"
aspectRatio="1/1"
/> />
<Button href={url} download={downloadedFileName}>{label}</Button> <Button href={url} download={downloadedFileName}>{label}</Button>
</div> </div>
@ -44,8 +46,8 @@ const section: Section = 'main';
{ {
socials.length > 0 && ( socials.length > 0 && (
<div class:list={['flex', 'gap-3', 'flex-wrap', 'sm:flex-nowrap']}> <div class:list={['flex', 'gap-3', 'flex-wrap', 'sm:flex-nowrap']}>
{socials.map(({ icon, url: iconUrl }) => ( {socials.map(({ icon, url: iconUrl, name }) => (
<IconButton href={iconUrl} icon={icon} size="small" target="_blank" /> <IconButton href={iconUrl} icon={icon} size="small" target="_blank" aria-label={name} />
))} ))}
</div> </div>
) )