Skip to content

Commit 6e2826f

Browse files
committed
feat: add BlockSearch component and integrate it into the Header
1 parent 981239e commit 6e2826f

File tree

3 files changed

+60
-6
lines changed

3 files changed

+60
-6
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
'use client';
2+
import { faMagnifyingGlass } from '@fortawesome/free-solid-svg-icons';
3+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
4+
import { cn } from '@web/src/lib/tailwind.utils';
5+
import { useState } from 'react';
6+
import { Popover, PopoverContent, PopoverTrigger } from './popover';
7+
8+
export const BlockSearch = () => {
9+
const [query, setQuery] = useState('');
10+
11+
return (
12+
<Popover>
13+
<PopoverTrigger
14+
className={cn(
15+
'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',
16+
)}
17+
id={'search-button'}
18+
>
19+
<FontAwesomeIcon icon={faMagnifyingGlass} />
20+
<span className='hidden sm:block'>Search</span>
21+
</PopoverTrigger>
22+
<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'>
23+
<div className='flex flex-row gap-2 p-4'>
24+
<input
25+
type='text'
26+
value={query}
27+
onChange={(e) => setQuery(e.target.value)}
28+
placeholder='Search for songs and users'
29+
className='w-full bg-zinc-800 text-white border border-zinc-600 rounded-md p-2'
30+
/>
31+
<button
32+
className='bg-zinc-600 text-white rounded-md p-2 hover:bg-zinc-500 w-12 h-12'
33+
onClick={() => {
34+
console.log('Searching for:', query);
35+
}}
36+
>
37+
<FontAwesomeIcon icon={faMagnifyingGlass} />
38+
</button>
39+
</div>
40+
</PopoverContent>
41+
</Popover>
42+
);
43+
};

web/src/modules/shared/components/layout/BlockTab.tsx

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,29 @@ import Link from 'next/link';
44

55
import { cn } from '@web/src/lib/tailwind.utils';
66

7+
interface BlockTabProps {
8+
href: string;
9+
icon: IconDefinition;
10+
label: string;
11+
className?: string;
12+
id?: string;
13+
}
14+
715
export const BlockTab = ({
16+
id,
817
href,
918
icon,
1019
label,
1120
className,
12-
}: {
13-
href: string;
14-
icon: IconDefinition;
15-
label: string;
16-
className?: string;
17-
}) => {
21+
}: BlockTabProps) => {
1822
return (
1923
<Link
2024
href={href}
2125
className={cn(
2226
'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',
2327
className,
2428
)}
29+
id={id}
2530
>
2631
<FontAwesomeIcon icon={icon} />
2732
<span className='hidden sm:block'>{label}</span>

web/src/modules/shared/components/layout/Header.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import {
1616
import { BlockTab } from './BlockTab';
1717
import { NavLinks } from './NavLinks';
1818
import { RandomSongButton } from './RandomSongButton';
19+
import { BlockSearch } from './BlockSearchProps';
1920

2021
export async function Header() {
2122
let isLogged;
@@ -77,26 +78,31 @@ export async function Header() {
7778
icon={faMusic}
7879
label='Songs'
7980
className='bg-purple-700 after:bg-purple-900 before:bg-purple-950'
81+
id='songs-tab'
8082
/>
8183
<BlockTab
8284
href='/help'
8385
icon={faQuestionCircle}
8486
label='Help'
8587
className='bg-blue-700 after:bg-blue-900 before:bg-blue-950'
88+
id='help-tab'
8689
/>
8790
<BlockTab
8891
href='/blog'
8992
icon={faNewspaper}
9093
label='Blog'
9194
className='bg-green-700 after:bg-green-900 before:bg-green-950'
95+
id='blog-tab'
9296
/>
9397
<BlockTab
9498
href='/about'
9599
icon={faUser}
96100
label='About'
97101
className='bg-cyan-700 after:bg-cyan-900 before:bg-cyan-950'
102+
id='about-tab'
98103
/>
99104
<RandomSongButton />
105+
<BlockSearch />
100106
</div>
101107

102108
{/* Sign in / Profile */}

0 commit comments

Comments
 (0)