mirror of
https://github.com/remvze/moodist.git
synced 2025-09-29 15:30:49 -04:00
feat: add better aria labels
This commit is contained in:
parent
837826fbc1
commit
9774532308
@ -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();
|
||||
|
@ -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}>
|
||||
|
Loading…
x
Reference in New Issue
Block a user