add aria-labels
All checks were successful
deploy / deploy (push) Successful in 55s

This commit is contained in:
Lee 2023-10-27 23:00:54 +01:00
parent 09f5842a3d
commit c7dd4709d9
2 changed files with 13 additions and 3 deletions

@ -22,7 +22,6 @@ export default function Avatar({
src={url} src={url}
width={size} width={size}
height={size} height={size}
priority
/> />
</> </>
); );

@ -16,13 +16,15 @@ interface ButtonProps {
text: string; text: string;
icon?: JSX.Element; icon?: JSX.Element;
href?: string; href?: string;
ariaLabel: string;
children?: React.ReactNode; children?: React.ReactNode;
} }
function NavbarButton({ text, icon, href, children }: ButtonProps) { function NavbarButton({ text, icon, href, ariaLabel, children }: ButtonProps) {
return ( return (
<div className="group"> <div className="group">
<a <a
aria-label={ariaLabel}
className="flex h-full w-fit transform-gpu items-center justify-center gap-1 rounded-md p-3 transition-all hover:cursor-pointer hover:bg-blue-500" className="flex h-full w-fit transform-gpu items-center justify-center gap-1 rounded-md p-3 transition-all hover:cursor-pointer hover:bg-blue-500"
href={href} href={href}
> >
@ -49,6 +51,7 @@ export default function Navbar() {
<div className="flex h-fit w-full rounded-md bg-gray-800"> <div className="flex h-fit w-full rounded-md bg-gray-800">
{settingsStore !== undefined && settingsStore.player && ( {settingsStore !== undefined && settingsStore.player && (
<NavbarButton <NavbarButton
ariaLabel="Your profile"
text="You" text="You"
icon={ icon={
<Avatar <Avatar
@ -61,7 +64,11 @@ export default function Navbar() {
/> />
)} )}
<NavbarButton text="Friends" icon={<UserIcon height={20} width={20} />}> <NavbarButton
ariaLabel="View your friends"
text="Friends"
icon={<UserIcon height={20} width={20} />}
>
{settingsStore?.friends.length == 0 ? ( {settingsStore?.friends.length == 0 ? (
<p className="text-sm font-bold">No friends, add someone!</p> <p className="text-sm font-bold">No friends, add someone!</p>
) : ( ) : (
@ -92,11 +99,13 @@ export default function Navbar() {
/> />
</NavbarButton> </NavbarButton>
<NavbarButton <NavbarButton
ariaLabel="View the global ranking"
text="Ranking" text="Ranking"
icon={<GlobeAltIcon height={20} width={20} />} icon={<GlobeAltIcon height={20} width={20} />}
href="/ranking/global/1" href="/ranking/global/1"
/> />
<NavbarButton <NavbarButton
ariaLabel="View analytics for Scoresaber"
text="Analytics" text="Analytics"
icon={<ServerIcon height={20} width={20} />} icon={<ServerIcon height={20} width={20} />}
href="/analytics" href="/analytics"
@ -105,11 +114,13 @@ export default function Navbar() {
<div className="m-auto" /> <div className="m-auto" />
<NavbarButton <NavbarButton
ariaLabel="Search for a player"
text="Search" text="Search"
icon={<MagnifyingGlassIcon height={20} width={20} />} icon={<MagnifyingGlassIcon height={20} width={20} />}
href="/search" href="/search"
/> />
<NavbarButton <NavbarButton
ariaLabel="View your settings"
text="Settings" text="Settings"
icon={<CogIcon height={20} width={20} />} icon={<CogIcon height={20} width={20} />}
href="/settings" href="/settings"