feat(web): show search prompt while no query is entered #24
No files matched your search
@@ -1,13 +1,20 @@
|
||||
"use client"
|
||||
|
||||
import { useSearchParams } from "next/navigation"
|
||||
|
||||
import { SearchResultsSkeleton } from "@/components/library-skeletons"
|
||||
import { SearchPrompt } from "@/components/search-prompt"
|
||||
import { Skeleton } from "@/components/ui/skeleton"
|
||||
|
||||
export default function Loading() {
|
||||
const hasQuery = Boolean(useSearchParams().get("q")?.trim())
|
||||
|
||||
return (
|
||||
<div className="flex h-svh flex-col">
|
||||
<header className="flex items-center justify-center border-b px-4 py-3">
|
||||
<Skeleton className="h-10 w-full max-w-xl rounded-full" />
|
||||
</header>
|
||||
<SearchResultsSkeleton />
|
||||
{hasQuery ? <SearchResultsSkeleton /> : <SearchPrompt />}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import { usePathname, useSearchParams } from "next/navigation"
|
||||
|
||||
import { ContentCarousel } from "@/components/content-carousel"
|
||||
import { SearchResultsSkeleton } from "@/components/library-skeletons"
|
||||
import { SearchPrompt } from "@/components/search-prompt"
|
||||
import { SearchSongItem } from "@/components/search-song-item"
|
||||
import { SearchTopResultCard, type TopResult } from "@/components/search-top-result-card"
|
||||
import { useCachedQuery } from "@/hooks/use-cached-query"
|
||||
@@ -55,13 +56,7 @@ function SearchResults({ query }: { query: string }) {
|
||||
}
|
||||
|
||||
if (!hasQuery) {
|
||||
return (
|
||||
<div className="flex flex-1 items-center justify-center px-6 pb-28">
|
||||
<p className="text-center text-muted-foreground">
|
||||
Search for songs, albums, artists, and playlists in your library.
|
||||
</p>
|
||||
</div>
|
||||
)
|
||||
return <SearchPrompt />
|
||||
}
|
||||
|
||||
if (!showResults) {
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
export function SearchPrompt() {
|
||||
return (
|
||||
<div className="flex flex-1 items-center justify-center px-6 pb-28">
|
||||
<p className="text-center text-muted-foreground">
|
||||
Search for songs, albums, artists, and playlists in your library.
|
||||
</p>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user