mirror of
https://github.com/GiriNeko/YesPlayMusic.git
synced 2025-12-17 05:38:04 +00:00
36 lines
841 B
TypeScript
36 lines
841 B
TypeScript
const ArtistInline = ({
|
|
artists,
|
|
className,
|
|
disableLink,
|
|
}: {
|
|
artists: Artist[]
|
|
className?: string
|
|
disableLink?: boolean
|
|
}) => {
|
|
if (!artists) return <div></div>
|
|
|
|
const navigate = useNavigate()
|
|
const handleClick = (id: number) => {
|
|
id !== 0 && !disableLink && navigate(`/artist/${id}`)
|
|
}
|
|
|
|
return (
|
|
<div className={classNames('line-clamp-1', className)}>
|
|
{artists.map((artist, index) => (
|
|
<span key={`${artist.id}-${artist.name}`}>
|
|
<span
|
|
onClick={() => handleClick(artist.id)}
|
|
className={classNames({
|
|
'hover:underline': !!artist.id && !disableLink,
|
|
})}
|
|
>
|
|
{artist.name}
|
|
</span>
|
|
{index < artists.length - 1 ? ', ' : ''}
|
|
</span>
|
|
))}
|
|
</div>
|
|
)
|
|
}
|
|
|
|
export default ArtistInline
|