mirror of
https://github.com/ChenQihan666/MyBlog-Next.git
synced 2026-08-14 19:41:02 +08:00
fix(a11y): resolve accessibility issues
A11y Improvements - add screen-reader only texts - remove autoFocus on search box - replace disabled link with span text in LinkButton
This commit is contained in:
@@ -86,6 +86,7 @@ const { activeNav } = Astro.props;
|
|||||||
d="M19.023 16.977a35.13 35.13 0 0 1-1.367-1.384c-.372-.378-.596-.653-.596-.653l-2.8-1.337A6.962 6.962 0 0 0 16 9c0-3.859-3.14-7-7-7S2 5.141 2 9s3.14 7 7 7c1.763 0 3.37-.66 4.603-1.739l1.337 2.8s.275.224.653.596c.387.363.896.854 1.384 1.367l1.358 1.392.604.646 2.121-2.121-.646-.604c-.379-.372-.885-.866-1.391-1.36zM9 14c-2.757 0-5-2.243-5-5s2.243-5 5-5 5 2.243 5 5-2.243 5-5 5z"
|
d="M19.023 16.977a35.13 35.13 0 0 1-1.367-1.384c-.372-.378-.596-.653-.596-.653l-2.8-1.337A6.962 6.962 0 0 0 16 9c0-3.859-3.14-7-7-7S2 5.141 2 9s3.14 7 7 7c1.763 0 3.37-.66 4.603-1.739l1.337 2.8s.275.224.653.596c.387.363.896.854 1.384 1.367l1.358 1.392.604.646 2.121-2.121-.646-.604c-.379-.372-.885-.866-1.391-1.36zM9 14c-2.757 0-5-2.243-5-5s2.243-5 5-5 5 2.243 5 5-2.243 5-5 5z"
|
||||||
></path>
|
></path>
|
||||||
</svg>
|
</svg>
|
||||||
|
<span class="sr-only">Search</span>
|
||||||
</LinkButton>
|
</LinkButton>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
|
|||||||
@@ -10,19 +10,24 @@ export interface Props {
|
|||||||
const { href, className, ariaLabel, title, disabled = false } = Astro.props;
|
const { href, className, ariaLabel, title, disabled = false } = Astro.props;
|
||||||
---
|
---
|
||||||
|
|
||||||
<a
|
{
|
||||||
href={disabled ? "#" : href}
|
disabled ? (
|
||||||
tabindex={disabled ? "-1" : "0"}
|
<span
|
||||||
class={`group inline-block ${className}`}
|
class={`group inline-block ${className}`}
|
||||||
aria-label={ariaLabel}
|
aria-label={ariaLabel}
|
||||||
title={title}
|
title={title}
|
||||||
aria-disabled={disabled}
|
aria-disabled={disabled}
|
||||||
>
|
>
|
||||||
<slot />
|
<slot />
|
||||||
</a>
|
</span>
|
||||||
|
) : (
|
||||||
<style>
|
<a
|
||||||
a {
|
{href}
|
||||||
@apply hover:text-skin-accent;
|
class={`group inline-block hover:text-skin-accent ${className}`}
|
||||||
}
|
aria-label={ariaLabel}
|
||||||
</style>
|
title={title}
|
||||||
|
>
|
||||||
|
<slot />
|
||||||
|
</a>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|||||||
@@ -80,6 +80,7 @@ export default function SearchBar({ searchList }: Props) {
|
|||||||
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
|
||||||
<path d="M19.023 16.977a35.13 35.13 0 0 1-1.367-1.384c-.372-.378-.596-.653-.596-.653l-2.8-1.337A6.962 6.962 0 0 0 16 9c0-3.859-3.14-7-7-7S2 5.141 2 9s3.14 7 7 7c1.763 0 3.37-.66 4.603-1.739l1.337 2.8s.275.224.653.596c.387.363.896.854 1.384 1.367l1.358 1.392.604.646 2.121-2.121-.646-.604c-.379-.372-.885-.866-1.391-1.36zM9 14c-2.757 0-5-2.243-5-5s2.243-5 5-5 5 2.243 5 5-2.243 5-5 5z"></path>
|
<path d="M19.023 16.977a35.13 35.13 0 0 1-1.367-1.384c-.372-.378-.596-.653-.596-.653l-2.8-1.337A6.962 6.962 0 0 0 16 9c0-3.859-3.14-7-7-7S2 5.141 2 9s3.14 7 7 7c1.763 0 3.37-.66 4.603-1.739l1.337 2.8s.275.224.653.596c.387.363.896.854 1.384 1.367l1.358 1.392.604.646 2.121-2.121-.646-.604c-.379-.372-.885-.866-1.391-1.36zM9 14c-2.757 0-5-2.243-5-5s2.243-5 5-5 5 2.243 5 5-2.243 5-5 5z"></path>
|
||||||
</svg>
|
</svg>
|
||||||
|
<span className="sr-only">Search</span>
|
||||||
</span>
|
</span>
|
||||||
<input
|
<input
|
||||||
className="block w-full rounded border border-skin-fill
|
className="block w-full rounded border border-skin-fill
|
||||||
@@ -92,7 +93,7 @@ export default function SearchBar({ searchList }: Props) {
|
|||||||
value={inputVal}
|
value={inputVal}
|
||||||
onChange={handleChange}
|
onChange={handleChange}
|
||||||
autoComplete="off"
|
autoComplete="off"
|
||||||
autoFocus
|
// autoFocus
|
||||||
ref={inputRef}
|
ref={inputRef}
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ const shareLinks = [
|
|||||||
title={social.linkTitle}
|
title={social.linkTitle}
|
||||||
>
|
>
|
||||||
<Fragment set:html={socialIcons[social.name]} />
|
<Fragment set:html={socialIcons[social.name]} />
|
||||||
|
<span class="sr-only">{social.linkTitle}</span>
|
||||||
</LinkButton>
|
</LinkButton>
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ const { centered = false } = Astro.props;
|
|||||||
title={social.linkTitle}
|
title={social.linkTitle}
|
||||||
>
|
>
|
||||||
<Fragment set:html={socialIcons[social.name]} />
|
<Fragment set:html={socialIcons[social.name]} />
|
||||||
|
<span class="sr-only">{social.linkTitle}</span>
|
||||||
</LinkButton>
|
</LinkButton>
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,6 +37,7 @@ const socialCount = SOCIALS.filter(social => social.active).length;
|
|||||||
d="M12 20.001h2C14 14.486 9.514 10 4 10v2c4.411 0 8 3.589 8 8.001z"
|
d="M12 20.001h2C14 14.486 9.514 10 4 10v2c4.411 0 8 3.589 8 8.001z"
|
||||||
></path><circle cx="6" cy="18" r="2"></circle>
|
></path><circle cx="6" cy="18" r="2"></circle>
|
||||||
</svg>
|
</svg>
|
||||||
|
<span class="sr-only">RSS Feed</span>
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
|
|||||||
Reference in New Issue
Block a user