2022-04-15 14:24:30 +00:00
|
|
|
<template>
|
|
|
|
<section id="searchExcerptsWrapper">
|
2022-07-16 15:44:45 +00:00
|
|
|
<ScreenHeader layout="collapsed">
|
|
|
|
<span v-if="q">Searching for <span class="text-thin">{{ q }}</span></span>
|
2022-04-15 14:24:30 +00:00
|
|
|
<span v-else>Search</span>
|
2022-04-15 17:00:08 +00:00
|
|
|
</ScreenHeader>
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-05-09 11:12:06 +00:00
|
|
|
<div ref="wrapper" class="main-scroll-wrap">
|
2022-10-08 10:54:25 +00:00
|
|
|
<div v-if="q" class="results">
|
2022-04-15 14:24:30 +00:00
|
|
|
<section class="songs" data-testid="song-excerpts">
|
|
|
|
<h1>
|
|
|
|
Songs
|
2022-04-15 17:00:08 +00:00
|
|
|
<Btn
|
2022-08-01 07:55:23 +00:00
|
|
|
v-if="excerpt.songs.length && !searching"
|
2022-05-10 23:01:48 +00:00
|
|
|
data-testid="view-all-songs-btn"
|
2022-04-23 21:53:56 +00:00
|
|
|
orange
|
2022-04-15 14:24:30 +00:00
|
|
|
rounded
|
|
|
|
small
|
2022-04-23 21:53:56 +00:00
|
|
|
@click.prevent="goToSongResults"
|
2022-04-15 14:24:30 +00:00
|
|
|
>
|
|
|
|
View All
|
2022-04-15 17:00:08 +00:00
|
|
|
</Btn>
|
2022-04-15 14:24:30 +00:00
|
|
|
</h1>
|
2022-08-01 07:55:23 +00:00
|
|
|
<ul v-if="searching">
|
|
|
|
<li v-for="i in 6" :key="i">
|
|
|
|
<SongCardSkeleton/>
|
2022-07-07 18:05:46 +00:00
|
|
|
</li>
|
2022-04-15 14:24:30 +00:00
|
|
|
</ul>
|
2022-08-01 07:55:23 +00:00
|
|
|
<template v-else>
|
|
|
|
<ul v-if="excerpt.songs.length">
|
|
|
|
<li v-for="song in excerpt.songs" :key="song.id">
|
|
|
|
<SongCard :song="song"/>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<p v-else>None found.</p>
|
|
|
|
</template>
|
2022-04-15 14:24:30 +00:00
|
|
|
</section>
|
|
|
|
|
|
|
|
<section class="artists" data-testid="artist-excerpts">
|
|
|
|
<h1>Artists</h1>
|
2022-08-01 07:55:23 +00:00
|
|
|
<ul v-if="searching">
|
|
|
|
<li v-for="i in 6" :key="i">
|
|
|
|
<ArtistAlbumCardSkeleton layout="compact"/>
|
2022-04-15 14:24:30 +00:00
|
|
|
</li>
|
|
|
|
</ul>
|
2022-08-01 07:55:23 +00:00
|
|
|
<template v-else>
|
|
|
|
<ul v-if="excerpt.artists.length">
|
|
|
|
<li v-for="artist in excerpt.artists" :key="artist.id">
|
|
|
|
<ArtistCard :artist="artist" layout="compact"/>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<p v-else>None found.</p>
|
|
|
|
</template>
|
2022-04-15 14:24:30 +00:00
|
|
|
</section>
|
|
|
|
|
|
|
|
<section class="albums" data-testid="album-excerpts">
|
|
|
|
<h1>Albums</h1>
|
2022-08-01 07:55:23 +00:00
|
|
|
<ul v-if="searching">
|
|
|
|
<li v-for="i in 6" :key="i">
|
|
|
|
<ArtistAlbumCardSkeleton layout="compact"/>
|
2022-04-15 14:24:30 +00:00
|
|
|
</li>
|
|
|
|
</ul>
|
2022-08-01 07:55:23 +00:00
|
|
|
<template v-else>
|
|
|
|
<ul v-if="excerpt.albums.length">
|
|
|
|
<li v-for="album in excerpt.albums" :key="album.id">
|
|
|
|
<AlbumCard :album="album" layout="compact"/>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
<p v-else>None found.</p>
|
|
|
|
</template>
|
2022-04-15 14:24:30 +00:00
|
|
|
</section>
|
|
|
|
</div>
|
|
|
|
|
2022-04-21 18:12:11 +00:00
|
|
|
<ScreenEmptyState v-else>
|
2022-04-15 14:24:30 +00:00
|
|
|
<template v-slot:icon>
|
2022-07-15 07:23:55 +00:00
|
|
|
<icon :icon="faSearch"/>
|
2022-04-15 14:24:30 +00:00
|
|
|
</template>
|
|
|
|
Find songs, artists, and albums,
|
|
|
|
<span class="secondary d-block">all in one place.</span>
|
2022-04-21 18:12:11 +00:00
|
|
|
</ScreenEmptyState>
|
2022-04-15 14:24:30 +00:00
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</template>
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
<script lang="ts" setup>
|
2022-07-15 07:23:55 +00:00
|
|
|
import { faSearch } from '@fortawesome/free-solid-svg-icons'
|
2022-09-15 09:07:25 +00:00
|
|
|
import { intersectionBy } from 'lodash'
|
2022-07-07 18:05:46 +00:00
|
|
|
import { ref, toRef } from 'vue'
|
2022-10-08 10:54:25 +00:00
|
|
|
import { eventBus, requireInjection } from '@/utils'
|
2022-04-15 14:24:30 +00:00
|
|
|
import { searchStore } from '@/stores'
|
2022-10-08 10:54:25 +00:00
|
|
|
import { RouterKey } from '@/symbols'
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-07-07 18:05:46 +00:00
|
|
|
import ScreenHeader from '@/components/ui/ScreenHeader.vue'
|
|
|
|
import ScreenEmptyState from '@/components/ui/ScreenEmptyState.vue'
|
|
|
|
import ArtistCard from '@/components/artist/ArtistCard.vue'
|
|
|
|
import AlbumCard from '@/components/album/AlbumCard.vue'
|
|
|
|
import Btn from '@/components/ui/Btn.vue'
|
|
|
|
import SongCard from '@/components/song/SongCard.vue'
|
2022-08-01 07:55:23 +00:00
|
|
|
import SongCardSkeleton from '@/components/ui/skeletons/SongCardSkeleton.vue'
|
|
|
|
import ArtistAlbumCardSkeleton from '@/components/ui/skeletons/ArtistAlbumCardSkeleton.vue'
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-10-08 10:54:25 +00:00
|
|
|
const router = requireInjection(RouterKey)
|
|
|
|
|
2022-05-09 11:12:06 +00:00
|
|
|
const excerpt = toRef(searchStore.state, 'excerpt')
|
2022-04-15 17:00:08 +00:00
|
|
|
const q = ref('')
|
2022-08-01 07:55:23 +00:00
|
|
|
const searching = ref(false)
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-10-08 10:54:25 +00:00
|
|
|
const goToSongResults = () => router.go(`search/songs/?q=${q.value}`)
|
2022-04-15 14:24:30 +00:00
|
|
|
|
2022-09-15 09:07:25 +00:00
|
|
|
const doSearch = async () => {
|
2022-08-01 07:55:23 +00:00
|
|
|
searching.value = true
|
|
|
|
await searchStore.excerptSearch(q.value)
|
|
|
|
searching.value = false
|
2022-09-15 09:07:25 +00:00
|
|
|
}
|
|
|
|
|
2022-11-15 15:52:38 +00:00
|
|
|
eventBus.on('SEARCH_KEYWORDS_CHANGED', async _q => {
|
|
|
|
q.value = _q
|
|
|
|
await doSearch()
|
|
|
|
}).on('SONGS_DELETED', async songs => {
|
|
|
|
if (intersectionBy(songs, excerpt.value.songs, 'id').length !== 0) {
|
2022-09-15 09:07:25 +00:00
|
|
|
await doSearch()
|
|
|
|
}
|
2022-04-15 14:24:30 +00:00
|
|
|
})
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
|
.results > section {
|
|
|
|
margin-bottom: 3em;
|
|
|
|
}
|
|
|
|
|
|
|
|
h1 {
|
|
|
|
font-size: 1.4rem;
|
|
|
|
margin: 0 0 1.8rem;
|
|
|
|
font-weight: 100;
|
|
|
|
display: flex;
|
|
|
|
place-content: space-between;
|
|
|
|
}
|
|
|
|
|
|
|
|
section ul {
|
|
|
|
display: grid;
|
|
|
|
grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
|
|
|
|
grid-gap: .7em 1em;
|
|
|
|
|
2022-04-15 17:00:08 +00:00
|
|
|
@media only screen and (max-width: 667px) {
|
2022-04-15 14:24:30 +00:00
|
|
|
display: block;
|
|
|
|
|
|
|
|
> * + * {
|
|
|
|
margin-top: .7rem;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</style>
|