75 lines
2.0 KiB
TypeScript
Raw Normal View History

2022-08-22 16:51:23 +08:00
import { openContextMenu } from '@/web/states/contextMenus'
import { cx } from '@emotion/css'
2022-10-28 20:29:04 +08:00
import { useTranslation } from 'react-i18next'
2022-08-22 16:51:23 +08:00
import { useParams } from 'react-router-dom'
2022-10-28 20:29:04 +08:00
import Icon from '../Icon'
2022-08-03 23:48:39 +08:00
const Actions = ({
onPlay,
onLike,
isLiked,
2022-08-22 16:51:23 +08:00
isLoading,
2022-08-03 23:48:39 +08:00
}: {
isLiked?: boolean
2022-08-22 16:51:23 +08:00
isLoading?: boolean
2022-08-03 23:48:39 +08:00
onPlay: () => void
onLike?: () => void
}) => {
2022-08-22 16:51:23 +08:00
const params = useParams()
2022-10-28 20:29:04 +08:00
const { t } = useTranslation()
2022-08-03 23:48:39 +08:00
return (
<div className='mt-11 flex items-end justify-between lg:mt-4 lg:justify-start'>
<div className='flex items-end'>
{/* Menu */}
2022-08-22 16:51:23 +08:00
<button
onClick={event => {
params?.id &&
openContextMenu({
event,
type: 'album',
dataSourceID: params.id,
})
}}
className={cx(
'mr-2.5 flex h-14 w-14 items-center justify-center rounded-full bg-white/10 transition duration-400',
isLoading
? 'text-transparent'
: 'text-white/40 hover:text-white/70 hover:dark:bg-white/30'
)}
>
<Icon name='more' className='pointer-events-none h-7 w-7' />
2022-08-03 23:48:39 +08:00
</button>
{/* Like */}
{onLike && (
<button
onClick={() => onLike()}
2022-08-22 16:51:23 +08:00
className={cx(
'flex h-14 w-14 items-center justify-center rounded-full bg-white/10 transition duration-400 lg:mr-2.5',
isLoading
? 'text-transparent'
: 'text-white/40 hover:text-white/70 hover:dark:bg-white/30'
)}
2022-08-03 23:48:39 +08:00
>
<Icon
name={isLiked ? 'heart' : 'heart-outline'}
className='h-7 w-7'
/>
</button>
)}
</div>
<button
onClick={() => onPlay()}
2022-08-22 16:51:23 +08:00
className={cx(
'h-14 rounded-full px-10 text-18 font-medium',
isLoading ? 'bg-white/10 text-transparent' : 'bg-brand-700 text-white'
)}
2022-08-03 23:48:39 +08:00
>
2022-10-28 20:29:04 +08:00
{t`player.play`}
2022-08-03 23:48:39 +08:00
</button>
</div>
)
}
export default Actions