2022-04-15 14:24:30 +00:00
|
|
|
<template>
|
|
|
|
<article
|
2022-04-21 21:51:17 +00:00
|
|
|
v-if="showing"
|
|
|
|
:class="layout"
|
2022-04-15 14:24:30 +00:00
|
|
|
:title="artist.name"
|
|
|
|
class="item"
|
2022-04-21 21:51:17 +00:00
|
|
|
data-test="artist-card"
|
2022-04-15 14:24:30 +00:00
|
|
|
draggable="true"
|
|
|
|
tabindex="0"
|
|
|
|
@dblclick="shuffle"
|
2022-04-21 21:51:17 +00:00
|
|
|
@dragstart="dragStart"
|
|
|
|
@contextmenu.prevent.stop="requestContextMenu"
|
2022-04-15 14:24:30 +00:00
|
|
|
>
|
|
|
|
<span class="thumbnail-wrapper">
|
2022-04-15 17:00:08 +00:00
|
|
|
<ArtistThumbnail :entity="artist"/>
|
2022-04-15 14:24:30 +00:00
|
|
|
</span>
|
|
|
|
|
|
|
|
<footer>
|
|
|
|
<div class="info">
|
2022-04-21 21:51:17 +00:00
|
|
|
<a class="name" :href="`#!/artist/${artist.id}`">{{ artist.name }}</a>
|
2022-04-15 14:24:30 +00:00
|
|
|
</div>
|
|
|
|
<p class="meta">
|
|
|
|
<span class="left">
|
2022-04-15 17:00:08 +00:00
|
|
|
{{ pluralize(artist.albums.length, 'album') }}
|
2022-04-15 14:24:30 +00:00
|
|
|
•
|
2022-04-15 17:00:08 +00:00
|
|
|
{{ pluralize(artist.songs.length, 'song') }}
|
2022-04-15 14:24:30 +00:00
|
|
|
•
|
2022-04-15 17:00:08 +00:00
|
|
|
{{ pluralize(artist.playCount, 'play') }}
|
2022-04-15 14:24:30 +00:00
|
|
|
</span>
|
|
|
|
<span class="right">
|
|
|
|
<a
|
|
|
|
:title="`Shuffle all songs by ${artist.name}`"
|
|
|
|
class="shuffle-artist"
|
|
|
|
href
|
|
|
|
role="button"
|
2022-04-21 21:51:17 +00:00
|
|
|
@click.prevent="shuffle"
|
2022-04-15 14:24:30 +00:00
|
|
|
>
|
|
|
|
<i class="fa fa-random"></i>
|
|
|
|
</a>
|
|
|
|
<a
|
2022-04-21 21:51:17 +00:00
|
|
|
v-if="allowDownload"
|
2022-04-15 14:24:30 +00:00
|
|
|
:title="`Download all songs by ${artist.name}`"
|
|
|
|
class="download-artist"
|
|
|
|
href
|
|
|
|
role="button"
|
2022-04-21 21:51:17 +00:00
|
|
|
@click.prevent="download"
|
2022-04-15 14:24:30 +00:00
|
|
|
>
|
|
|
|
<i class="fa fa-download"></i>
|
|
|
|
</a>
|
|
|
|
</span>
|
|
|
|
</p>
|
|
|
|
</footer>
|
|
|
|
</article>
|
|
|
|
</template>
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
<script lang="ts" setup>
|
2022-04-21 21:51:17 +00:00
|
|
|
import { computed, defineAsyncComponent, toRef, toRefs } from 'vue'
|
2022-04-15 17:00:08 +00:00
|
|
|
import { eventBus, pluralize, startDragging } from '@/utils'
|
2022-04-24 08:50:45 +00:00
|
|
|
import { artistStore, commonStore } from '@/stores'
|
|
|
|
import { downloadService, playbackService } from '@/services'
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-21 10:18:11 +00:00
|
|
|
const ArtistThumbnail = defineAsyncComponent(() => import('@/components/ui/AlbumArtistThumbnail.vue'))
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
const props = withDefaults(defineProps<{ artist: Artist, layout: ArtistAlbumCardLayout }>(), { layout: 'full' })
|
|
|
|
const { artist, layout } = toRefs(props)
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-24 08:50:45 +00:00
|
|
|
const allowDownload = toRef(commonStore.state, 'allowDownload')
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
const showing = computed(() => artist.value.songs.length && !artistStore.isVariousArtists(artist.value))
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-04-24 08:50:45 +00:00
|
|
|
const shuffle = () => playbackService.playAllByArtist(artist.value, true /* shuffled */)
|
2022-04-15 17:00:08 +00:00
|
|
|
const download = () => downloadService.fromArtist(artist.value)
|
|
|
|
const dragStart = (event: DragEvent) => startDragging(event, artist.value, 'Artist')
|
|
|
|
const requestContextMenu = (event: MouseEvent) => eventBus.emit('ARTIST_CONTEXT_MENU_REQUESTED', event, artist.value)
|
2022-04-15 14:24:30 +00:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss">
|
|
|
|
@include artist-album-card();
|
|
|
|
</style>
|