2 Commits

Author SHA1 Message Date
6ec834ddc5 fix(ssr): add screen reader labels to buttons on player page
All checks were successful
deploy / deploy (push) Successful in 1m20s
2023-11-08 08:49:33 +00:00
e40c78e9b9 fix(ssr): remove a tag on button 2023-11-08 08:49:15 +00:00
2 changed files with 17 additions and 14 deletions

View File

@ -3,38 +3,38 @@ import { Tooltip, TooltipContent, TooltipTrigger } from "./ui/Tooltip";
interface ButtonProps { interface ButtonProps {
text?: JSX.Element | string; text?: JSX.Element | string;
url?: string;
icon?: JSX.Element; icon?: JSX.Element;
color?: string; color?: string;
tooltip?: React.ReactNode; tooltip?: React.ReactNode;
className?: string; className?: string;
ariaLabel?: string;
onClick?: () => void; onClick?: () => void;
} }
export default function Button({ export default function Button({
text, text,
url,
icon, icon,
color, color,
tooltip, tooltip,
className, className,
ariaLabel = "Default button label",
onClick, onClick,
}: ButtonProps) { }: ButtonProps) {
if (!color) color = "bg-blue-500"; if (!color) color = "bg-blue-500";
const base = ( const base = (
<a href={url} onClick={onClick}> <button
<p className={clsx(
className={clsx( "flex items-center justify-center gap-2 rounded-md px-4 py-2",
"font-md flex w-fit transform-gpu flex-row items-center gap-1 rounded-md p-1 transition-all hover:opacity-80", color,
className, className,
color, )}
)} onClick={onClick}
> aria-label={ariaLabel}
{icon} >
{text} {icon}
</p> {text}
</a> </button>
); );
if (tooltip) { if (tooltip) {

View File

@ -136,6 +136,7 @@ export default function PlayerInfo({ playerData }: PlayerInfoProps) {
onClick={claimProfile} onClick={claimProfile}
tooltip={<p>Set as your Profile</p>} tooltip={<p>Set as your Profile</p>}
icon={<HomeIcon width={24} height={24} />} icon={<HomeIcon width={24} height={24} />}
ariaLabel="Set as your Profile"
/> />
)} )}
@ -147,6 +148,7 @@ export default function PlayerInfo({ playerData }: PlayerInfoProps) {
tooltip={<p>Add as Friend</p>} tooltip={<p>Add as Friend</p>}
icon={<UserIcon width={24} height={24} />} icon={<UserIcon width={24} height={24} />}
color="bg-green-500" color="bg-green-500"
ariaLabel="Add Friend"
/> />
)} )}
@ -156,6 +158,7 @@ export default function PlayerInfo({ playerData }: PlayerInfoProps) {
tooltip={<p>Remove Friend</p>} tooltip={<p>Remove Friend</p>}
icon={<XMarkIcon width={24} height={24} />} icon={<XMarkIcon width={24} height={24} />}
color="bg-red-500" color="bg-red-500"
ariaLabel="Remove Friend"
/> />
)} )}
</> </>