feat: add badge to display sound type in SoundCard component

This commit is contained in:
JSC
2025-09-21 15:39:04 +02:00
parent 7faf2d38ab
commit 41659c9299

View File

@@ -1,4 +1,5 @@
import { Card, CardContent } from '@/components/ui/card' import { Card, CardContent } from '@/components/ui/card'
import { Badge } from '@/components/ui/badge'
import { type Sound } from '@/lib/api/services/sounds' import { type Sound } from '@/lib/api/services/sounds'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
import { formatDuration } from '@/utils/format-duration' import { formatDuration } from '@/utils/format-duration'
@@ -27,6 +28,19 @@ export function SoundCard({ sound, playSound, onFavoriteToggle, colorClasses }:
onFavoriteToggle(sound.id, !sound.is_favorited) onFavoriteToggle(sound.id, !sound.is_favorited)
} }
const getBadgeVariant = (type: Sound['type']) => {
switch (type) {
case 'SDB':
return 'default'
case 'TTS':
return 'secondary'
case 'EXT':
return 'outline'
default:
return 'default'
}
}
return ( return (
<Card <Card
onClick={handlePlaySound} onClick={handlePlaySound}
@@ -36,6 +50,14 @@ export function SoundCard({ sound, playSound, onFavoriteToggle, colorClasses }:
)} )}
> >
<CardContent className="grid grid-cols-1 pl-3 pr-3 gap-1"> <CardContent className="grid grid-cols-1 pl-3 pr-3 gap-1">
{/* Type badge */}
<Badge
variant={getBadgeVariant(sound.type)}
className="absolute top-2 left-2 text-xs px-1.5 py-0.5 h-5"
>
{sound.type}
</Badge>
{/* Favorite button */} {/* Favorite button */}
<button <button
data-favorite-button data-favorite-button
@@ -57,7 +79,7 @@ export function SoundCard({ sound, playSound, onFavoriteToggle, colorClasses }:
/> />
</button> </button>
<h3 className="font-medium text-s truncate pr-8">{sound.name}</h3> <h3 className="font-medium text-s truncate pl-12 pr-8">{sound.name}</h3>
<div className="grid grid-cols-2 gap-1 text-xs text-muted-foreground"> <div className="grid grid-cols-2 gap-1 text-xs text-muted-foreground">
<div className="flex"> <div className="flex">
<Clock className="h-3.5 w-3.5 mr-0.5" /> <Clock className="h-3.5 w-3.5 mr-0.5" />