refactor(a11y): update LinkButton for disabled state

This commit is contained in:
satnaing
2022-11-26 16:03:21 +06:30
parent 57c3f796d4
commit 9e92f71838
+5 -4
View File
@@ -4,19 +4,20 @@ export interface Props {
className?: string; className?: string;
ariaLabel?: string; ariaLabel?: string;
title?: string; title?: string;
tabindex?: string; disabled?: boolean;
} }
const { href, className, ariaLabel, title, tabindex } = Astro.props; const { href, className, ariaLabel, title, disabled = false } = Astro.props;
--- ---
<a <a
type="button" type="button"
href={href} href={disabled ? "#" : href}
tabindex={tabindex} tabindex={disabled ? "-1" : "0"}
class={`group ${className}`} class={`group ${className}`}
aria-label={ariaLabel} aria-label={ariaLabel}
title={title} title={title}
aria-disabled={disabled}
> >
<slot /> <slot />
</a> </a>