koel/resources/assets/js/components/artist/ArtistInfo.vue

60 lines
1.9 KiB
Vue
Raw Normal View History

2022-04-15 14:24:30 +00:00
<template>
<article class="artist-info" :class="mode" data-test="artist-info">
<h1 class="name">
<span>{{ artist.name }}</span>
2022-04-21 21:51:17 +00:00
<button :title="`Shuffle all songs by ${artist.name}`" class="shuffle control" @click.prevent="shuffleAll">
2022-04-15 14:24:30 +00:00
<i class="fa fa-random"></i>
</button>
</h1>
<main v-if="artist.info">
2022-04-15 17:00:08 +00:00
<ArtistThumbnail :entity="artist"/>
2022-04-15 14:24:30 +00:00
<template v-if="artist.info">
2022-04-21 21:51:17 +00:00
<div v-if="artist.info.bio?.summary" class="bio">
<div v-if="showSummary" class="summary" v-html="artist.info.bio.summary"></div>
<div v-if="showFull" class="full" v-html="artist.info.bio.full"></div>
2022-04-15 14:24:30 +00:00
2022-04-21 21:51:17 +00:00
<button v-show="showSummary" class="more" data-test="more-btn" @click.prevent="showingFullBio = true">
2022-04-15 14:24:30 +00:00
Full Bio
</button>
</div>
2022-04-21 21:51:17 +00:00
<p v-else class="text-secondary none">This artist has no Last.fm biography yet.</p>
2022-04-15 14:24:30 +00:00
2022-04-21 21:51:17 +00:00
<footer>Data &copy; <a :href="artist.info.url" rel="openener" target="_blank">Last.fm</a></footer>
2022-04-15 14:24:30 +00:00
</template>
</main>
</article>
</template>
2022-04-15 17:00:08 +00:00
<script lang="ts" setup>
import { computed, defineAsyncComponent, ref, toRefs, watch } from 'vue'
2022-04-24 08:50:45 +00:00
import { playbackService } from '@/services'
2022-04-15 14:24:30 +00:00
2022-04-15 17:00:08 +00:00
type DisplayMode = 'sidebar' | 'full'
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, mode: DisplayMode }>(), { mode: 'sidebar' })
const { artist, mode } = toRefs(props)
2022-04-15 14:24:30 +00:00
2022-04-15 17:00:08 +00:00
const showingFullBio = ref(false)
2022-04-15 14:24:30 +00:00
2022-04-15 17:00:08 +00:00
watch(artist, () => (showingFullBio.value = false))
2022-04-15 14:24:30 +00:00
2022-04-26 11:32:13 +00:00
const showSummary = computed(() => mode.value !== 'full' && !showingFullBio.value)
2022-04-15 17:00:08 +00:00
const showFull = computed(() => !showSummary.value)
2022-04-15 14:24:30 +00:00
2022-04-24 08:50:45 +00:00
const shuffleAll = () => playbackService.playAllByArtist(artist.value, false)
2022-04-15 14:24:30 +00:00
</script>
<style lang="scss">
.artist-info {
@include artist-album-info();
.none {
margin-top: 1rem;
}
}
</style>