feat: add better aria labels

This commit is contained in:
MAZE 2024-04-24 15:55:42 +03:30
parent 837826fbc1
commit 9774532308
2 changed files with 9 additions and 3 deletions

View File

@ -11,9 +11,10 @@ import { useKeyboardButton } from '@/hooks/use-keyboard-button';
interface FavoriteProps {
id: string;
label: string;
}
export function Favorite({ id }: FavoriteProps) {
export function Favorite({ id, label }: FavoriteProps) {
const isFavorite = useSoundStore(state => state.sounds[id].isFavorite);
const toggleFavorite = useSoundStore(state => state.toggleFavorite);
@ -26,8 +27,12 @@ export function Favorite({ id }: FavoriteProps) {
return (
<AnimatePresence initial={false} mode="wait">
<button
aria-label="Add Sound to Favorites"
className={cn(styles.favoriteButton, isFavorite && styles.isFavorite)}
aria-label={
isFavorite
? `Remove ${label} Sound from Favorites`
: `Add ${label} Sound to Favorites`
}
onKeyDown={handleKeyDown}
onClick={e => {
e.stopPropagation();

View File

@ -81,6 +81,7 @@ export function Sound({
return (
<div
aria-label={`${label} sound`}
role="button"
tabIndex={0}
className={cn(
@ -91,7 +92,7 @@ export function Sound({
onClick={handleClick}
onKeyDown={handleKeyDown}
>
<Favorite id={id} />
<Favorite id={id} label={label} />
<div className={styles.icon}>
{isLoading ? (
<span className={styles.spinner}>