koel/resources/assets/js/components/album/AlbumInfo.vue

61 lines
2 KiB
Vue
Raw Normal View History

2022-04-15 14:24:30 +00:00
<template>
<article class="album-info" :class="mode" data-test="album-info">
<h1 class="name">
<span>{{ album.name }}</span>
<button :title="`Shuffle all songs in ${album.name}`" @click.prevent="shuffleAll" class="shuffle control">
<i class="fa fa-random"></i>
</button>
</h1>
<main>
2022-04-15 17:00:08 +00:00
<AlbumThumbnail :entity="album"/>
2022-04-15 14:24:30 +00:00
<template v-if="album.info">
2022-04-29 13:32:12 +00:00
<div class="wiki" v-if="album.info?.wiki?.summary">
<div class="summary" v-if="showSummary" v-html="album.info?.wiki?.summary"></div>
<div class="full" v-if="showFull" v-html="album.info?.wiki?.full"></div>
2022-04-15 14:24:30 +00:00
<button class="more" v-if="showSummary" @click.prevent="showingFullWiki = true" data-test="more-btn">
Full Wiki
</button>
</div>
2022-04-29 13:32:12 +00:00
<TrackList :album="album" v-if="album.info?.tracks?.length" data-test="album-info-tracks"/>
2022-04-15 14:24:30 +00:00
2022-04-29 13:32:12 +00:00
<footer>Data &copy; <a target="_blank" rel="noopener" :href="album.info?.url">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>
2022-04-24 08:50:45 +00:00
import { playbackService } from '@/services'
2022-04-15 17:00:08 +00:00
import { computed, defineAsyncComponent, ref, toRefs, watch } from 'vue'
2022-04-15 14:24:30 +00:00
2022-04-21 10:43:10 +00:00
const TrackList = defineAsyncComponent(() => import('./AlbumTrackList.vue'))
2022-04-21 10:18:11 +00:00
const AlbumThumbnail = defineAsyncComponent(() => import('@/components/ui/AlbumArtistThumbnail.vue'))
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-29 13:32:12 +00:00
const props = withDefaults(defineProps<{ album: Album, mode?: DisplayMode }>(), { mode: 'sidebar' })
2022-04-15 17:00:08 +00:00
const { album, mode } = toRefs(props)
2022-04-15 14:24:30 +00:00
2022-04-15 17:00:08 +00:00
const showingFullWiki = ref(false)
2022-04-15 14:24:30 +00:00
2022-04-15 17:00:08 +00:00
/**
* Whenever a new album is loaded into this component, we reset the "full wiki" state.
*/
watch(album, () => (showingFullWiki.value = false))
2022-04-15 14:24:30 +00:00
2022-04-15 17:00:08 +00:00
const showSummary = computed(() => mode.value !== 'full' && !showingFullWiki.value)
const showFull = computed(() => !showSummary.value)
2022-04-15 14:24:30 +00:00
2022-04-24 08:50:45 +00:00
const shuffleAll = () => playbackService.playAllInAlbum(album.value)
2022-04-15 14:24:30 +00:00
</script>
<style lang="scss">
.album-info {
@include artist-album-info();
}
</style>