Skip to content

Commit 8a62c3a

Browse files
committed
feat: Update Navbar component with responsive styling and search functionality
1 parent 21d95a0 commit 8a62c3a

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

client/src/app/components/Footer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React from "react";
33

44
const Footer = () => {
55
return (
6-
<footer className="text-center mt-8 pb-4 text-gray-500 font-sourcecodepro">
6+
<footer className=" text-center mt-8 py-4 text-gray-500 font-sourcecodepro">
77
<p>
88
Made with{" "}
99
<span aria-label="heart" role="img">

client/src/app/components/Navbar.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,14 @@ import Image from "next/image";
44
import Link from "next/link";
55
import React, { useState } from "react";
66

7-
const Navbar: React.FC = () => {
7+
type NavbarProps = {
8+
search: string;
9+
setSearch: React.Dispatch<React.SetStateAction<string>>;
10+
};
11+
12+
const Navbar: React.FC<NavbarProps> = ({ search, setSearch }) => {
813
const [hoveredItem, setHoveredItem] = useState<string | null>(null);
14+
915
return (
1016
<nav className="bg-[#0e0e0e] z-10 border-b border-b-white fixed top-0 left-0 w-full md:px-8 px-4 py-4 flex justify-around items-center">
1117
{/* Logo */}
@@ -22,6 +28,8 @@ const Navbar: React.FC = () => {
2228
<form className="">
2329
<div className="relative flex ">
2430
<input
31+
value={search}
32+
onChange={(e) => setSearch(e.target.value)}
2533
type="text"
2634
placeholder="Search by username"
2735
className="bg-[#1f1f1f] sm:w-[260px] w-[100px] font-sourcecodepro text-white rounded px-4 py-3 focus:outline-none pl-10"

client/src/app/page.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ import "react-toastify/dist/ReactToastify.css";
1414
export default function Home() {
1515
const { datas, setDatas } = useContext(DataContext);
1616
const [loading, setLoading] = useState(true);
17+
const [search, setSearch] = useState<string>("");
18+
const [showStats, setShowStats] = useState(false);
19+
1720
const fetchData = async () => {
1821
try {
1922
const res = await fetch("/api/fetchdata");
@@ -30,7 +33,10 @@ export default function Home() {
3033
fetchData();
3134
}, [datas]);
3235

33-
const [showStats, setShowStats] = useState(false);
36+
const searchedData = datas?.filter((data: any) =>
37+
data.profileData.fullName.toLowerCase().includes(search.toLowerCase())
38+
);
39+
3440
return (
3541
<section className="px-4 lg:px-24 relative ">
3642
<button
@@ -45,14 +51,14 @@ export default function Home() {
4551
/>
4652
</button>
4753

48-
<Navbar />
54+
<Navbar search={search} setSearch={setSearch} />
4955

5056
<GenerateStats showStats={showStats} setShowStats={setShowStats} />
5157

52-
<div className="mt-32 max-w-7xl mx-auto place-items-center grid grid-cols-1 md:grid-cols-2 gap-y-8 xl:grid-cols-3 font-sourcecodepro gap-x-4">
58+
<div className="mt-32 max-w-7xl mx-auto place-items-center grid grid-cols-1 md:grid-cols-2 gap-y-8 xl:grid-cols-3 font-sourcecodepro gap-x-4">
5359
<PromotionCard />
54-
{datas &&
55-
datas
60+
{searchedData &&
61+
searchedData
5662
.sort(
5763
(a: any, b: any) =>
5864
new Date(b.timeStamp).getTime() -

0 commit comments

Comments
 (0)