@@ -5,22 +5,12 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
55import { useRouter } from 'next/navigation' ;
66import { useState } from 'react' ;
77
8- import {
9- Popover ,
10- PopoverContent ,
11- PopoverTrigger ,
12- } from '@web/modules/shared/components/layout/popover' ;
13- import { cn } from '@web/lib/tailwind.utils' ;
14- import { MusicalNote } from './MusicalNote' ;
15-
168export function SearchBar ( ) {
179 const router = useRouter ( ) ;
1810 const [ searchQuery , setSearchQuery ] = useState ( '' ) ;
19- const [ isOpen , setIsOpen ] = useState ( false ) ;
2011
2112 const handleSearch = ( ) => {
2213 if ( searchQuery . trim ( ) ) {
23- setIsOpen ( false ) ;
2414 router . push ( `/search-song?q=${ encodeURIComponent ( searchQuery . trim ( ) ) } ` ) ;
2515 setSearchQuery ( '' ) ;
2616 }
@@ -33,44 +23,24 @@ export function SearchBar() {
3323 } ;
3424
3525 return (
36- < Popover open = { isOpen } onOpenChange = { setIsOpen } >
37- < PopoverTrigger asChild >
38- < button
39- className = { cn (
40- 'bevel p-2 flex-1 w-8 md:min-w-20 max-w-28 flex items-center justify-center gap-2 bg-zinc-600 after:bg-zinc-800 before:bg-zinc-900 translate-y-[11px] hover:translate-y-1.5 transition-all duration-150 hover:brightness-125' ,
41- 'bg-orange-700 after:bg-orange-900 before:bg-orange-950' ,
42- ) }
43- aria-label = 'Search songs'
44- >
45- < FontAwesomeIcon icon = { faMagnifyingGlass } className = 'text-sm' />
46- < span className = 'hidden sm:inline text-sm' > Search</ span >
47- < MusicalNote />
48- </ button >
49- </ PopoverTrigger >
50- < PopoverContent className = 'bg-zinc-800 border border-zinc-700 shadow-xl' >
51- < div className = 'space-y-3' >
52- < h3 className = 'font-semibold text-zinc-100' > Search Songs</ h3 >
53- < div className = 'flex gap-2' >
54- < input
55- type = 'text'
56- value = { searchQuery }
57- onChange = { ( e ) => setSearchQuery ( e . target . value ) }
58- onKeyDown = { handleKeyDown }
59- placeholder = 'Type your search...'
60- className = 'flex-1 px-3 py-2 bg-zinc-900 border border-zinc-700 rounded text-zinc-100 placeholder-zinc-500 focus:outline-none focus:ring-2 focus:ring-orange-500 focus:border-transparent'
61- autoFocus
62- />
63- < button
64- onClick = { handleSearch }
65- disabled = { ! searchQuery . trim ( ) }
66- className = 'px-4 py-2 bg-orange-600 hover:bg-orange-700 disabled:bg-zinc-700 disabled:text-zinc-500 disabled:cursor-not-allowed text-white rounded transition-colors duration-200 flex items-center gap-2'
67- aria-label = 'Search'
68- >
69- < FontAwesomeIcon icon = { faMagnifyingGlass } />
70- </ button >
71- </ div >
72- </ div >
73- </ PopoverContent >
74- </ Popover >
26+ < div className = 'flex gap-2' >
27+ < input
28+ type = 'text'
29+ value = { searchQuery }
30+ onChange = { ( e ) => setSearchQuery ( e . target . value ) }
31+ onKeyDown = { handleKeyDown }
32+ placeholder = 'Type your search...'
33+ className = 'flex-1 px-3 py-2 bg-zinc-900 border border-zinc-700 rounded text-zinc-100 placeholder-zinc-500 focus:outline-none focus:ring-2 focus:ring-orange-500 focus:border-transparent'
34+ autoFocus
35+ />
36+ < button
37+ onClick = { handleSearch }
38+ disabled = { ! searchQuery . trim ( ) }
39+ className = 'px-4 py-2 bg-orange-600 hover:bg-orange-700 disabled:bg-zinc-700 disabled:text-zinc-500 disabled:cursor-not-allowed text-white rounded transition-colors duration-200 flex items-center gap-2'
40+ aria-label = 'Search'
41+ >
42+ < FontAwesomeIcon icon = { faMagnifyingGlass } />
43+ </ button >
44+ </ div >
7545 ) ;
7646}
0 commit comments