Skip to content

Commit f8ea419

Browse files
committed
feat:moved search bar from sidebar to navbar
1 parent d144ac8 commit f8ea419

File tree

2 files changed

+56
-261
lines changed

2 files changed

+56
-261
lines changed

src/components/Navbar.tsx

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,24 @@ import ModeToggle from "@/components/toggle-theme";
66
import Link from "next/link";
77
import { usePathname } from "next/navigation";
88
import { ArrowDownLeftIcon } from "lucide-react";
9+
import SearchbarChild from "./Searchbar/searchbar-child";
10+
import { fetchSubjects } from "./Searchbar/searchbar";
11+
import { useEffect, useState } from "react";
912

1013
function Navbar() {
1114
const pathname = usePathname();
15+
const [subjects, setSubjects] = useState<string[]>([]);
16+
17+
useEffect(() => {
18+
const getSubjects = async () => {
19+
const subs = await fetchSubjects();
20+
setSubjects(subs);
21+
};
22+
getSubjects();
23+
}, []);
1224

1325
return (
14-
<div className="sticky top-0 z-10 flex h-[85px] w-full items-center justify-between gap-x-3 overflow-hidden bg-[#B2B8FF] px-2 py-6 dark:bg-[#130E1F] md:px-12">
26+
<div className="sticky top-0 z-10 flex h-[85px] w-full items-center justify-between gap-x-3 bg-[#B2B8FF] px-2 py-6 dark:bg-[#130E1F] md:px-12">
1527
<div className="flex items-center gap-x-2 md:w-auto">
1628
<a
1729
href="https://www.codechefvit.com/"
@@ -32,6 +44,15 @@ function Navbar() {
3244
Papers
3345
</Link>
3446
</div>
47+
48+
{pathname === "/catalogue" && (
49+
<div className="hidden flex-1 justify-center md:flex">
50+
<div className="w-[60%] max-w-[500px]">
51+
<SearchbarChild initialSubjects={subjects} />
52+
</div>
53+
</div>
54+
)}
55+
3556
<div className="md:w/[20%] flex items-center justify-end gap-x-2">
3657
<div className="scale-75 sm:scale-100">
3758
<ModeToggle />
@@ -52,4 +73,4 @@ function Navbar() {
5273
);
5374
}
5475

55-
export default Navbar;
76+
export default Navbar;

0 commit comments

Comments
 (0)