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 {
|
interface FavoriteProps {
|
||||||
id: string;
|
id: string;
|
||||||
|
label: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function Favorite({ id }: FavoriteProps) {
|
export function Favorite({ id, label }: FavoriteProps) {
|
||||||
const isFavorite = useSoundStore(state => state.sounds[id].isFavorite);
|
const isFavorite = useSoundStore(state => state.sounds[id].isFavorite);
|
||||||
const toggleFavorite = useSoundStore(state => state.toggleFavorite);
|
const toggleFavorite = useSoundStore(state => state.toggleFavorite);
|
||||||
|
|
||||||
@ -26,8 +27,12 @@ export function Favorite({ id }: FavoriteProps) {
|
|||||||
return (
|
return (
|
||||||
<AnimatePresence initial={false} mode="wait">
|
<AnimatePresence initial={false} mode="wait">
|
||||||
<button
|
<button
|
||||||
aria-label="Add Sound to Favorites"
|
|
||||||
className={cn(styles.favoriteButton, isFavorite && styles.isFavorite)}
|
className={cn(styles.favoriteButton, isFavorite && styles.isFavorite)}
|
||||||
|
aria-label={
|
||||||
|
isFavorite
|
||||||
|
? `Remove ${label} Sound from Favorites`
|
||||||
|
: `Add ${label} Sound to Favorites`
|
||||||
|
}
|
||||||
onKeyDown={handleKeyDown}
|
onKeyDown={handleKeyDown}
|
||||||
onClick={e => {
|
onClick={e => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
@ -81,6 +81,7 @@ export function Sound({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
aria-label={`${label} sound`}
|
||||||
role="button"
|
role="button"
|
||||||
tabIndex={0}
|
tabIndex={0}
|
||||||
className={cn(
|
className={cn(
|
||||||
@ -91,7 +92,7 @@ export function Sound({
|
|||||||
onClick={handleClick}
|
onClick={handleClick}
|
||||||
onKeyDown={handleKeyDown}
|
onKeyDown={handleKeyDown}
|
||||||
>
|
>
|
||||||
<Favorite id={id} />
|
<Favorite id={id} label={label} />
|
||||||
<div className={styles.icon}>
|
<div className={styles.icon}>
|
||||||
{isLoading ? (
|
{isLoading ? (
|
||||||
<span className={styles.spinner}>
|
<span className={styles.spinner}>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user