koel/resources/assets/js/components/screens/home/RecentlyPlayedSongs.vue

42 lines
1 KiB
Vue
Raw Normal View History

2022-06-10 10:47:46 +00:00
<template>
<section class="recent">
<h1>
Recently Played
<Btn
data-testid="home-view-all-recently-played-btn"
@click.prevent="goToRecentlyPlayedScreen"
rounded
small
orange
>
View All
</Btn>
</h1>
<ol v-if="songs.length" class="recent-song-list">
<li v-for="song in songs" :key="song.id">
<SongCard :song="song"/>
</li>
</ol>
<p v-show="!songs.length" class="text-secondary">
Your recently played songs will be displayed here.<br/>
Start listening!
</p>
</section>
</template>
<script lang="ts" setup>
import { defineAsyncComponent, toRef } from 'vue'
import router from '@/router'
import { recentlyPlayedStore } from '@/stores'
import Btn from '@/components/ui/Btn.vue'
2022-06-10 10:47:46 +00:00
const SongCard = defineAsyncComponent(() => import('@/components/song/SongCard.vue'))
const songs = toRef(recentlyPlayedStore.excerptState, 'songs')
const goToRecentlyPlayedScreen = () => router.go('recently-played')
</script>