43 lines
985 B
TypeScript
43 lines
985 B
TypeScript
"use client"
|
|
|
|
import { Star } from "lucide-react"
|
|
|
|
import { Button } from "@/components/ui/button"
|
|
import { cn } from "@/lib/utils"
|
|
|
|
type FavoriteMediaButtonProps = {
|
|
isFavorite: boolean
|
|
onToggle: () => void
|
|
favoritedLabel: string
|
|
unfavoritedLabel: string
|
|
className?: string
|
|
iconClassName?: string
|
|
}
|
|
|
|
export function FavoriteMediaButton({
|
|
isFavorite,
|
|
onToggle,
|
|
favoritedLabel,
|
|
unfavoritedLabel,
|
|
className,
|
|
iconClassName = "size-4",
|
|
}: FavoriteMediaButtonProps) {
|
|
return (
|
|
<Button
|
|
variant={isFavorite ? "default" : "secondary"}
|
|
size="icon"
|
|
className={cn(
|
|
"rounded-full",
|
|
!isFavorite &&
|
|
"hover:bg-primary hover:text-primary-foreground hover:border-transparent",
|
|
className
|
|
)}
|
|
aria-label={isFavorite ? favoritedLabel : unfavoritedLabel}
|
|
aria-pressed={isFavorite}
|
|
onClick={onToggle}
|
|
>
|
|
<Star className={cn(iconClassName, isFavorite && "fill-current")} />
|
|
</Button>
|
|
)
|
|
}
|