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

65 lines
1.7 KiB
Vue
Raw Normal View History

2022-04-15 14:24:30 +00:00
<template>
<section id="songResultsWrapper">
2022-07-16 09:52:39 +00:00
<ScreenHeader :layout="headerLayout" has-thumbnail>
2022-07-16 15:44:45 +00:00
Songs for <span class="text-thin">{{ decodedQ }}</span>
2022-06-10 10:47:46 +00:00
<ControlsToggle :showing-controls="showingControls" @toggleControls="toggleControls"/>
2022-04-15 14:24:30 +00:00
2022-07-16 09:52:39 +00:00
<template v-slot:thumbnail>
<ThumbnailStack :thumbnails="thumbnails"/>
</template>
2022-07-10 17:15:56 +00:00
<template v-slot:meta v-if="songs.length">
<span>{{ pluralize(songs.length, 'song') }}</span>
<span>{{ duration }}</span>
2022-04-15 14:24:30 +00:00
</template>
<template v-slot:controls>
2022-04-15 17:00:08 +00:00
<SongListControls
2022-04-21 16:06:45 +00:00
v-if="songs.length && (!isPhone || showingControls)"
2022-04-15 17:00:08 +00:00
@playAll="playAll"
@playSelected="playSelected"
2022-04-15 14:24:30 +00:00
/>
</template>
2022-04-15 17:00:08 +00:00
</ScreenHeader>
2022-04-15 14:24:30 +00:00
2022-07-16 09:52:39 +00:00
<SongList ref="songList" @sort="sort" @press:enter="onPressEnter" @scroll-breakpoint="onScrollBreakpoint"/>
2022-04-15 14:24:30 +00:00
</section>
</template>
2022-04-15 17:00:08 +00:00
<script lang="ts" setup>
import { computed, toRef, toRefs } from 'vue'
2022-04-15 14:24:30 +00:00
import { searchStore } from '@/stores'
2022-04-15 17:00:08 +00:00
import { useSongList } from '@/composables'
2022-04-15 14:24:30 +00:00
import { pluralize } from '@/utils'
import ScreenHeader from '@/components/ui/ScreenHeader.vue'
2022-04-21 16:06:45 +00:00
const props = defineProps<{ q: string }>()
const { q } = toRefs(props)
2022-04-15 17:00:08 +00:00
const {
SongList,
SongListControls,
2022-06-10 10:47:46 +00:00
ControlsToggle,
2022-07-16 09:52:39 +00:00
ThumbnailStack,
headerLayout,
2022-04-21 16:06:45 +00:00
songs,
2022-04-15 17:00:08 +00:00
songList,
2022-07-16 09:52:39 +00:00
thumbnails,
2022-04-23 21:24:02 +00:00
duration,
2022-04-15 17:00:08 +00:00
showingControls,
isPhone,
onPressEnter,
2022-04-15 17:00:08 +00:00
playAll,
playSelected,
2022-06-10 10:47:46 +00:00
toggleControls,
2022-07-16 09:52:39 +00:00
sort,
onScrollBreakpoint
2022-06-10 10:47:46 +00:00
} = useSongList(toRef(searchStore.state, 'songs'), 'search-results')
2022-04-15 17:00:08 +00:00
const decodedQ = computed(() => decodeURIComponent(q.value))
searchStore.resetSongResultState()
searchStore.songSearch(decodedQ.value)
2022-04-15 14:24:30 +00:00
</script>