Skip to content

Commit 9cf07b7

Browse files
committed
Merge branch 'feature/song-search' of github.com:OpenNBS/NoteBlockWorld into feature/song-search
2 parents 4fcf74f + 37dabb0 commit 9cf07b7

File tree

7 files changed

+67
-109
lines changed

7 files changed

+67
-109
lines changed

apps/frontend/src/modules/shared/components/layout/Header.tsx

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { checkLogin, getUserData } from '@web/modules/auth/features/auth.utils';
1313
import { BlockTab } from './BlockTab';
1414
import { NavLinks } from './NavLinks';
1515
import { RandomSongButton } from './RandomSongButton';
16-
import { SearchButton } from './SearchButton';
16+
import { SearchBar } from './SearchBar';
1717

1818
export async function Header() {
1919
let isLogged;
@@ -34,22 +34,6 @@ export async function Header() {
3434
<header className='fixed w-[calc(100vw_-_16px)] h-14 flex flex-row justify-center items-center bg-zinc-900 border-b border-zinc-700 py-2 z-10'>
3535
{/* Navbar */}
3636
<nav className='w-full flex flex-row justify-between items-center gap-8 md:gap-12 max-w-screen-xl px-6 sm:px-10'>
37-
{/* Logo */}
38-
<div className='hidden lg:block flex-0 text-lg text-nowrap'>
39-
<picture className='w-full h-auto'>
40-
<Link href='/'>
41-
<Image
42-
unoptimized
43-
src='/nbw-logo-flat.png'
44-
alt='Note Block World logo'
45-
className=''
46-
width={300}
47-
height={64}
48-
/>
49-
</Link>
50-
</picture>
51-
</div>
52-
5337
{/* Icon */}
5438
<div className='flex-0 flex justify-start lg:justify-center min-w-fit'>
5539
<Link href='/'>
@@ -68,6 +52,11 @@ export async function Header() {
6852
</Link>
6953
</div>
7054

55+
{/* Search bar */}
56+
<div className='flex-1 max-w-sm'>
57+
<SearchBar />
58+
</div>
59+
7160
{/* Info pages */}
7261
<div className='flex flex-1 justify-center gap-1 h-8 text-center'>
7362
<BlockTab
@@ -94,7 +83,6 @@ export async function Header() {
9483
label='About'
9584
className='bg-cyan-700 after:bg-cyan-900 before:bg-cyan-950'
9685
/>
97-
<SearchButton />
9886
<RandomSongButton />
9987
</div>
10088

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
'use client';
2+
3+
import { faMagnifyingGlass } from '@fortawesome/free-solid-svg-icons';
4+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
5+
import { useRouter } from 'next/navigation';
6+
import { useState } from 'react';
7+
8+
export function SearchBar() {
9+
const router = useRouter();
10+
const [searchQuery, setSearchQuery] = useState('');
11+
12+
const handleSearch = () => {
13+
if (searchQuery.trim()) {
14+
router.push(`/search?q=${encodeURIComponent(searchQuery.trim())}`);
15+
}
16+
};
17+
18+
const handleKeyDown = (e: React.KeyboardEvent<HTMLInputElement>) => {
19+
if (e.key === 'Enter') {
20+
handleSearch();
21+
}
22+
};
23+
24+
return (
25+
<div className='flex'>
26+
<input
27+
type='text'
28+
value={searchQuery}
29+
onChange={(e) => setSearchQuery(e.target.value)}
30+
onKeyDown={handleKeyDown}
31+
placeholder='Search songs...'
32+
className='flex-1 px-3 py-2 bg-transparent border border-zinc-700 rounded-l-full text-sm text-white placeholder-zinc-500 focus:outline-none focus:border-blue-500 focus:border-transparent'
33+
/>
34+
<button
35+
onClick={handleSearch}
36+
disabled={!searchQuery.trim()}
37+
className='px-4 py-2 pl-3 bg-zinc-700 hover:bg-zinc-600 text-white rounded-r-full transition-colors duration-200 flex items-center gap-2'
38+
aria-label='Search'
39+
>
40+
<FontAwesomeIcon icon={faMagnifyingGlass} />
41+
</button>
42+
</div>
43+
);
44+
}

apps/frontend/src/modules/shared/components/layout/SearchButton.tsx

Lines changed: 0 additions & 76 deletions
This file was deleted.

bun.lock

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"eslint": "^9.36.0",
1616
"eslint-plugin-import": "^2.32.0",
1717
"eslint-plugin-mdx": "^3.6.2",
18-
"eslint-plugin-unused-imports": "^2.0.0",
18+
"eslint-plugin-unused-imports": "^4.2.0",
1919
"globals": "^16.4.0",
2020
"husky": "^9.1.7",
2121
"lint-staged": "^16.2.3",
@@ -1620,9 +1620,7 @@
16201620

16211621
"eslint-plugin-react-hooks": ["[email protected]", "", { "peerDependencies": { "eslint": "^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0" } }, "sha512-AZYbMo/NW9chdL7vk6HQzQhT+PvTAEVqWk9ziruUoW2kAOcN5qNyelv70e0F1VNQAbvutOC9oc+xfWycI9FxDw=="],
16221622

1623-
"eslint-plugin-unused-imports": ["[email protected]", "", { "dependencies": { "eslint-rule-composer": "^0.3.0" }, "peerDependencies": { "@typescript-eslint/eslint-plugin": "^5.0.0", "eslint": "^8.0.0" }, "optionalPeers": ["@typescript-eslint/eslint-plugin"] }, "sha512-3APeS/tQlTrFa167ThtP0Zm0vctjr4M44HMpeg1P4bK6wItarumq0Ma82xorMKdFsWpphQBlRPzw/pxiVELX1A=="],
1624-
1625-
"eslint-rule-composer": ["[email protected]", "", {}, "sha512-bt+Sh8CtDmn2OajxvNO+BX7Wn4CIWMpTRm3MaiKPCQcnnlm0CS2mhui6QaoeQugs+3Kj2ESKEEGJUdVafwhiCg=="],
1623+
"eslint-plugin-unused-imports": ["[email protected]", "", { "peerDependencies": { "@typescript-eslint/eslint-plugin": "^8.0.0-0 || ^7.0.0 || ^6.0.0 || ^5.0.0", "eslint": "^9.0.0 || ^8.0.0" }, "optionalPeers": ["@typescript-eslint/eslint-plugin"] }, "sha512-hLbJ2/wnjKq4kGA9AUaExVFIbNzyxYdVo49QZmKCnhk5pc9wcYRbfgLHvWJ8tnsdcseGhoUAddm9gn/lt+d74w=="],
16261624

16271625
"eslint-scope": ["[email protected]", "", { "dependencies": { "esrecurse": "^4.3.0", "estraverse": "^5.2.0" } }, "sha512-sNXOfKCn74rt8RICKMvJS7XKV/Xk9kA7DyJr8mJik3S7Cwgy3qlkkmyS2uQB3jiJg6VNdZd/pDBJu0nvG2NlTg=="],
16281626

eslint.config.mjs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import eslint from '@eslint/js';
44
import { defineConfig } from 'eslint/config';
55
import importPlugin from 'eslint-plugin-import';
66
import react from 'eslint-plugin-react';
7+
import unusedImports from 'eslint-plugin-unused-imports';
78
import globals from 'globals';
89
import tseslint from 'typescript-eslint';
910

@@ -34,6 +35,7 @@ export default defineConfig(
3435
},
3536
plugins: {
3637
import: importPlugin,
38+
'unused-imports': unusedImports,
3739
},
3840
settings: {
3941
'import/resolver': {
@@ -57,16 +59,7 @@ export default defineConfig(
5759
'@typescript-eslint/no-explicit-any': 'warn',
5860
'@typescript-eslint/no-require-imports': 'warn',
5961
'@typescript-eslint/ban-ts-comment': 'warn',
60-
'@typescript-eslint/no-unused-vars': [
61-
'warn',
62-
{
63-
vars: 'all',
64-
varsIgnorePattern: '^_',
65-
args: 'after-used',
66-
argsIgnorePattern: '^_',
67-
caughtErrors: 'none', // Allow unused error variables in catch blocks
68-
},
69-
],
62+
'@typescript-eslint/no-unused-vars': 'off', // Handled by unused-imports plugin
7063
'lines-between-class-members': [
7164
'warn',
7265
'always',
@@ -98,6 +91,17 @@ export default defineConfig(
9891
],
9992
'import/newline-after-import': 'warn',
10093
'import/no-duplicates': 'warn',
94+
'unused-imports/no-unused-imports': 'warn',
95+
'unused-imports/no-unused-vars': [
96+
'warn',
97+
{
98+
vars: 'all',
99+
varsIgnorePattern: '^_',
100+
args: 'after-used',
101+
argsIgnorePattern: '^_',
102+
caughtErrors: 'none', // Allow unused error variables in catch blocks
103+
},
104+
],
101105
},
102106
},
103107

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
"eslint": "^9.36.0",
8080
"eslint-plugin-import": "^2.32.0",
8181
"eslint-plugin-mdx": "^3.6.2",
82-
"eslint-plugin-unused-imports": "^2.0.0",
82+
"eslint-plugin-unused-imports": "^4.2.0",
8383
"globals": "^16.4.0",
8484
"husky": "^9.1.7",
8585
"lint-staged": "^16.2.3",

0 commit comments

Comments
 (0)