2024-04-04 22:20:42 +00:00
|
|
|
<template>
|
|
|
|
<ExcerptResultBlock>
|
|
|
|
<template #header>
|
2024-05-19 05:49:42 +00:00
|
|
|
{{ headingText }}
|
2024-04-04 22:20:42 +00:00
|
|
|
|
|
|
|
<Btn
|
2024-05-19 05:49:42 +00:00
|
|
|
v-if="playables.length && !searching"
|
2024-04-04 22:20:42 +00:00
|
|
|
data-testid="view-all-songs-btn"
|
|
|
|
highlight
|
|
|
|
rounded
|
|
|
|
small
|
|
|
|
@click.prevent="goToSongResults"
|
|
|
|
>
|
|
|
|
View All
|
|
|
|
</Btn>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<ul v-if="searching" class="results">
|
|
|
|
<li v-for="i in 6" :key="i">
|
|
|
|
<SongCardSkeleton />
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<template v-else>
|
2024-05-19 05:49:42 +00:00
|
|
|
<ul v-if="playables.length" class="results">
|
|
|
|
<li v-for="playable in playables" :key="playable.id">
|
|
|
|
<SongCard :playable="playable" />
|
2024-04-04 22:20:42 +00:00
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<p v-else>None found.</p>
|
|
|
|
</template>
|
|
|
|
</ExcerptResultBlock>
|
|
|
|
</template>
|
|
|
|
|
2024-04-23 21:01:27 +00:00
|
|
|
<script lang="ts" setup>
|
2024-05-19 05:49:42 +00:00
|
|
|
import { computed, toRefs } from 'vue'
|
2024-04-04 22:20:42 +00:00
|
|
|
import { useRouter } from '@/composables'
|
2024-05-19 05:49:42 +00:00
|
|
|
import { getPlayableCollectionContentType } from '@/utils'
|
2024-04-04 22:20:42 +00:00
|
|
|
|
|
|
|
import SongCardSkeleton from '@/components/ui/skeletons/SongCardSkeleton.vue'
|
|
|
|
import ExcerptResultBlock from '@/components/screens/search/ExcerptResultBlock.vue'
|
|
|
|
import SongCard from '@/components/song/SongCard.vue'
|
|
|
|
import Btn from '@/components/ui/form/Btn.vue'
|
|
|
|
|
2024-05-19 05:49:42 +00:00
|
|
|
const props = withDefaults(defineProps<{ playables?: Playable[], query?: string, searching?: boolean }>(), {
|
|
|
|
playables: () => [],
|
2024-04-04 22:20:42 +00:00
|
|
|
query: '',
|
|
|
|
searching: false,
|
|
|
|
})
|
|
|
|
|
2024-05-19 05:49:42 +00:00
|
|
|
const headingText = computed(() => {
|
|
|
|
switch (getPlayableCollectionContentType(props.playables)) {
|
|
|
|
case 'episodes':
|
|
|
|
return 'Episodes'
|
|
|
|
case 'songs':
|
|
|
|
return 'Songs'
|
|
|
|
default:
|
|
|
|
return 'Songs & Episodes'
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
const { playables, query, searching } = toRefs(props)
|
2024-04-04 22:20:42 +00:00
|
|
|
const { go } = useRouter()
|
|
|
|
|
|
|
|
const goToSongResults = () => go(`search/songs/?q=${query.value}`)
|
|
|
|
</script>
|
|
|
|
|
2024-04-23 21:01:27 +00:00
|
|
|
<style lang="postcss" scoped>
|
2024-04-04 22:20:42 +00:00
|
|
|
.results {
|
|
|
|
@apply grid grid-cols-1 md:grid-cols-2 gap-x-4 gap-y-3;
|
|
|
|
}
|
|
|
|
</style>
|