koel/resources/assets/js/components/screens/search/SongExcerptResultsBlock.vue

60 lines
1.5 KiB
Vue
Raw Normal View History

2024-04-04 22:20:42 +00:00
<template>
<ExcerptResultBlock>
<template #header>
Songs
<Btn
v-if="songs.length && !searching"
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>
<ul v-if="songs.length" class="results">
<li v-for="song in songs" :key="song.id">
<SongCard :song="song" />
</li>
</ul>
<p v-else>None found.</p>
</template>
</ExcerptResultBlock>
</template>
2024-04-23 21:01:27 +00:00
<script lang="ts" setup>
2024-04-04 22:20:42 +00:00
import { toRefs } from 'vue'
import { useRouter } from '@/composables'
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'
const props = withDefaults(defineProps<{ songs?: Song[], query?: string, searching?: boolean }>(), {
songs: () => [],
query: '',
searching: false,
})
const { songs, query, searching } = toRefs(props)
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>