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

48 lines
1,003 B
Vue
Raw Normal View History

2022-04-15 14:24:30 +00:00
<template>
<section class="track-listing">
<h1>Track Listing</h1>
<ul class="tracks">
<li
2022-04-21 10:43:10 +00:00
is="vue:TrackListItem"
2022-04-29 18:26:07 +00:00
v-for="(track, index) in album.info?.tracks"
2022-04-21 10:43:10 +00:00
:key="index"
2022-04-15 14:24:30 +00:00
:album="album"
:track="track"
2022-05-03 16:51:59 +00:00
data-testid="album-track-item"
2022-04-15 14:24:30 +00:00
/>
</ul>
</section>
</template>
2022-04-15 17:00:08 +00:00
<script lang="ts" setup>
2022-06-10 10:47:46 +00:00
import { defineAsyncComponent, onMounted, provide, ref, toRefs } from 'vue'
import { songStore } from '@/stores'
import { SongsKey } from '@/symbols'
2022-04-15 14:24:30 +00:00
2022-04-21 10:43:10 +00:00
const TrackListItem = defineAsyncComponent(() => import('./AlbumTrackListItem.vue'))
2022-04-15 14:24:30 +00:00
2022-04-15 17:00:08 +00:00
const props = defineProps<{ album: Album }>()
const { album } = toRefs(props)
2022-06-10 10:47:46 +00:00
const songs = ref<Song[]>([])
provide(SongsKey, songs)
onMounted(async () => songs.value = await songStore.fetchForAlbum(album.value))
2022-04-15 14:24:30 +00:00
</script>
2022-04-21 10:43:10 +00:00
<style lang="scss" scoped>
ul {
counter-reset: trackCounter;
}
li {
counter-increment: trackCounter;
&::before {
content: counter(trackCounter);
}
}
</style>