2022-04-15 14:24:30 +00:00
|
|
|
<template>
|
|
|
|
<article
|
2024-05-19 05:49:42 +00:00
|
|
|
:class="{ playing: playable.playback_state === 'Playing' || playable.playback_state === 'Paused' }"
|
2024-04-04 22:20:42 +00:00
|
|
|
class="group flex gap-3 py-2 pl-2.5 pr-3 rounded-md items-center bg-k-bg-secondary border border-k-border
|
|
|
|
hover:border-white/15 transition-[border-color] duration-200 ease-in-out
|
|
|
|
focus:ring-1 focus:ring-k-accent focus-within:ring-1 focus-within:ring-k-accent"
|
2022-04-23 22:15:08 +00:00
|
|
|
draggable="true"
|
2022-04-15 14:24:30 +00:00
|
|
|
tabindex="0"
|
2022-09-03 08:32:09 +00:00
|
|
|
@dragstart="onDragStart"
|
2022-04-30 11:55:54 +00:00
|
|
|
@contextmenu.prevent="requestContextMenu"
|
2022-04-23 22:15:08 +00:00
|
|
|
@dblclick.prevent="play"
|
2022-04-15 14:24:30 +00:00
|
|
|
>
|
2024-07-03 16:15:30 +00:00
|
|
|
<span class="leading-none">
|
2024-06-02 17:15:31 +00:00
|
|
|
<SongThumbnail :playable="playable" />
|
2024-04-04 22:20:42 +00:00
|
|
|
</span>
|
2024-05-19 05:49:42 +00:00
|
|
|
<main class="flex-1 flex items-start overflow-hidden gap-2">
|
2024-04-04 22:20:42 +00:00
|
|
|
<div class="flex-1 space-y-1 overflow-hidden">
|
2024-05-19 05:49:42 +00:00
|
|
|
<h3 class="flex gap-2 w-full overflow-hidden">
|
2024-04-04 22:20:42 +00:00
|
|
|
<ExternalMark v-if="external" />
|
2024-05-19 05:49:42 +00:00
|
|
|
<span class="flex-1 block overflow-hidden text-ellipsis whitespace-nowrap">
|
|
|
|
{{ playable.title }}
|
|
|
|
</span>
|
2024-01-04 10:24:40 +00:00
|
|
|
</h3>
|
2024-05-19 05:49:42 +00:00
|
|
|
<p class="text-k-text-secondary text-[0.9rem] opacity-80 overflow-hidden">
|
|
|
|
<a
|
|
|
|
v-if="isSong(playable)"
|
|
|
|
:href="`#/artist/${playable.artist_id}`"
|
|
|
|
class="!text-k-text-primary hover:!text-k-accent"
|
|
|
|
>
|
|
|
|
{{ playable.artist_name }}
|
2024-04-04 22:20:42 +00:00
|
|
|
</a>
|
2024-05-19 05:49:42 +00:00
|
|
|
<a
|
|
|
|
v-if="isEpisode(playable)"
|
|
|
|
:href="`#/podcasts/${playable.podcast_id}`"
|
|
|
|
class="!text-k-text-primary hover:!text-k-accent"
|
|
|
|
>
|
|
|
|
{{ playable.podcast_title }}
|
|
|
|
</a>
|
|
|
|
- {{ pluralize(playable.play_count, 'play') }}
|
2022-07-30 15:08:20 +00:00
|
|
|
</p>
|
|
|
|
</div>
|
2024-06-02 17:15:31 +00:00
|
|
|
<LikeButton :playable="playable" class="opacity-0 text-k-text-secondary group-hover:opacity-100" />
|
2022-07-30 15:08:20 +00:00
|
|
|
</main>
|
2022-04-15 14:24:30 +00:00
|
|
|
</article>
|
|
|
|
</template>
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
<script lang="ts" setup>
|
2024-01-04 10:24:40 +00:00
|
|
|
import { computed, toRefs } from 'vue'
|
2024-05-19 05:49:42 +00:00
|
|
|
import { eventBus, isEpisode, isSong, pluralize } from '@/utils'
|
2022-04-24 08:50:45 +00:00
|
|
|
import { playbackService } from '@/services'
|
2024-01-08 16:59:05 +00:00
|
|
|
import { useAuthorization, useDraggable, useKoelPlus } from '@/composables'
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-10-26 12:34:32 +00:00
|
|
|
import SongThumbnail from '@/components/song/SongThumbnail.vue'
|
2022-07-07 07:52:54 +00:00
|
|
|
import LikeButton from '@/components/song/SongLikeButton.vue'
|
2024-04-04 22:20:42 +00:00
|
|
|
import ExternalMark from '@/components/ui/ExternalMark.vue'
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2024-05-19 05:49:42 +00:00
|
|
|
const props = defineProps<{ playable: Playable }>()
|
|
|
|
const { playable } = toRefs(props)
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2024-01-08 16:59:05 +00:00
|
|
|
const { isPlus } = useKoelPlus()
|
2024-01-04 10:24:40 +00:00
|
|
|
const { currentUser } = useAuthorization()
|
2024-05-19 05:49:42 +00:00
|
|
|
const { startDragging } = useDraggable('playables')
|
2022-09-03 08:32:09 +00:00
|
|
|
|
2024-05-19 05:49:42 +00:00
|
|
|
const external = computed(() => {
|
|
|
|
if (!isSong(playable.value)) return false
|
|
|
|
return isPlus.value && playable.value.owner_id !== currentUser.value?.id
|
|
|
|
})
|
2024-01-04 10:24:40 +00:00
|
|
|
|
2024-05-19 05:49:42 +00:00
|
|
|
const requestContextMenu = (event: MouseEvent) => eventBus.emit(
|
|
|
|
'PLAYABLE_CONTEXT_MENU_REQUESTED',
|
|
|
|
event,
|
|
|
|
playable.value
|
|
|
|
)
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2024-05-19 05:49:42 +00:00
|
|
|
const onDragStart = (event: DragEvent) => startDragging(event, [playable.value])
|
|
|
|
const play = () => playbackService.play(playable.value)
|
2022-04-15 14:24:30 +00:00
|
|
|
</script>
|
|
|
|
|
2024-04-04 20:13:35 +00:00
|
|
|
<style lang="postcss" scoped>
|
2022-04-15 14:24:30 +00:00
|
|
|
article {
|
|
|
|
&.playing {
|
2024-04-04 22:20:42 +00:00
|
|
|
@apply text-k-accent;
|
2022-07-07 07:52:54 +00:00
|
|
|
}
|
|
|
|
|
2024-04-04 20:13:35 +00:00
|
|
|
/* show the thumbnail's playback control on the whole card focus and hover */
|
2024-04-23 21:01:27 +00:00
|
|
|
|
2024-04-04 22:20:42 +00:00
|
|
|
&:hover :deep(.song-thumbnail), &:focus :deep(.song-thumbnail) {
|
2022-04-15 14:24:30 +00:00
|
|
|
&::before {
|
2024-04-04 22:20:42 +00:00
|
|
|
@apply opacity-70;
|
2022-04-15 14:24:30 +00:00
|
|
|
}
|
2022-08-03 21:01:47 +00:00
|
|
|
}
|
2022-04-15 14:24:30 +00:00
|
|
|
}
|
|
|
|
</style>
|