File tree Expand file tree Collapse file tree 2 files changed +54
-0
lines changed
apps/frontend/src/modules/shared/components/layout Expand file tree Collapse file tree 2 files changed +54
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ import { checkLogin, getUserData } from '@web/modules/auth/features/auth.utils';
13
13
import { BlockTab } from './BlockTab' ;
14
14
import { NavLinks } from './NavLinks' ;
15
15
import { RandomSongButton } from './RandomSongButton' ;
16
+ import { SearchBox } from './SearchBox' ;
16
17
17
18
export async function Header ( ) {
18
19
let isLogged ;
@@ -93,6 +94,7 @@ export async function Header() {
93
94
label = 'About'
94
95
className = 'bg-cyan-700 after:bg-cyan-900 before:bg-cyan-950'
95
96
/>
97
+ < SearchBox />
96
98
< RandomSongButton />
97
99
</ div >
98
100
Original file line number Diff line number Diff line change
1
+ 'use client' ;
2
+ import { faMagnifyingGlass } from '@fortawesome/free-solid-svg-icons' ;
3
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' ;
4
+ import { useRouter } from 'next/navigation' ;
5
+ import { useState } from 'react' ;
6
+
7
+ import { cn } from '@web/lib/tailwind.utils' ;
8
+ import { Popover , PopoverContent , PopoverTrigger } from './popover' ;
9
+
10
+ export const SearchBox = ( ) => {
11
+ const [ query , setQuery ] = useState ( '' ) ;
12
+ const router = useRouter ( ) ;
13
+
14
+ return (
15
+ < Popover >
16
+ < PopoverTrigger
17
+ className = { cn (
18
+ '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' ,
19
+ ) }
20
+ id = { 'search-button' }
21
+ >
22
+ < FontAwesomeIcon icon = { faMagnifyingGlass } />
23
+ < span className = 'hidden sm:block' > Search</ span >
24
+ </ PopoverTrigger >
25
+ < PopoverContent className = 'w-fit p-[2px] pb-1.5 h-fit shadow-[inset_0px_0px_0px_2px_rgb(82_82_91)] drop-shadow-lg border-zinc-600 bg-zinc-800 text-white rounded-lg' >
26
+ < div className = 'flex flex-row gap-2 p-4' >
27
+ < input
28
+ type = 'text'
29
+ value = { query }
30
+ onChange = { ( e ) => setQuery ( e . target . value ) }
31
+ placeholder = 'Search for songs and users'
32
+ className = 'w-full bg-zinc-800 text-white border border-zinc-600 rounded-md p-2'
33
+ />
34
+ < button
35
+ className = 'bg-zinc-600 text-white rounded-md p-2 hover:bg-zinc-500 w-12 h-12'
36
+ onClick = { ( ) => {
37
+ const queryParam = new URLSearchParams ( {
38
+ page : '1' ,
39
+ limit : '20' ,
40
+ query,
41
+ } ) ;
42
+
43
+ router . push ( `/search-user?${ queryParam . toString ( ) } ` ) ;
44
+ } }
45
+ >
46
+ < FontAwesomeIcon icon = { faMagnifyingGlass } />
47
+ </ button >
48
+ </ div >
49
+ </ PopoverContent >
50
+ </ Popover >
51
+ ) ;
52
+ } ;
You can’t perform that action at this time.
0 commit comments