From 103b8fd71b229816e987607f2a73bc11f6de4751 Mon Sep 17 00:00:00 2001 From: GOURAVSINGH19 Date: Thu, 6 Jun 2024 17:13:58 +0530 Subject: [PATCH] done --- src/Components/Container.css | 11 ++++++ src/Components/TopContainer.js | 72 ++++++++++++++++++---------------- 2 files changed, 50 insertions(+), 33 deletions(-) diff --git a/src/Components/Container.css b/src/Components/Container.css index a8d6d38c..7b74d489 100644 --- a/src/Components/Container.css +++ b/src/Components/Container.css @@ -19,6 +19,7 @@ display: flex; justify-content: space-between; align-items: center; + position: relative; } .topContainer .inputBox { @@ -26,6 +27,15 @@ height: 45px; position: relative; } +.searchbtn{ + position: absolute; + top: 15px; + left: 10px; + color: white; + font-size: 22px; + cursor: pointer; +} + .inputBox #search_results { max-height: 24rem; min-width: 20rem; @@ -38,6 +48,7 @@ scrollbar-color: rgb(128, 128, 128) transparent; scrollbar-width: 5px; } + .inputBox #search_results div{ padding: 0.5rem 1rem; border-bottom: 0.1rem solid #ffffff59; diff --git a/src/Components/TopContainer.js b/src/Components/TopContainer.js index 4ef704b5..9d3b7c64 100644 --- a/src/Components/TopContainer.js +++ b/src/Components/TopContainer.js @@ -9,9 +9,15 @@ function TopContainer() { const [searchResult, setSearchResult] = useState(null); const [isDropdownOpen, setIsDropdownOpen] = useState(false); const dropdownRef = useRef(null); + const searchbar = useRef(null); + let tDrop = false; let tSearch = false; + const searchbtnclick = () => { + searchbar.current.focus(); + }; + useEffect(() => { // Add event listener to detect clicks anywhere on the page window.addEventListener("click", handleOutsideClick); @@ -55,11 +61,11 @@ function TopContainer() { }; const searchDropDown = () => { - if(!tSearch){ - document.getElementById("search_input").style.display="block"; + if (!tSearch) { + document.getElementById("search_input").style.display = "block"; tSearch = true; - } else{ - document.getElementById("search_input").style.display="none"; + } else { + document.getElementById("search_input").style.display = "none"; tSearch = false; } }; @@ -71,33 +77,31 @@ function TopContainer() { setIsMobile(window.innerWidth < 524); }; - window.addEventListener('resize', handleResize); + window.addEventListener("resize", handleResize); // Clean up the event listener on component unmount return () => { - window.removeEventListener('resize', handleResize); + window.removeEventListener("resize", handleResize); }; }, []); return ( -
-
+
+
setInput(e.target.value)} /> - + searchbtnclick()} className="searchbtn"> - + {searchResult ? ( -
+
{searchResult.map((item, index) => (
-

+

{item.title}

{item.category} @@ -109,52 +113,54 @@ function TopContainer() { )}
-
- -
-
+
+ + + +
+
{isDropdownOpen && ( -
+
{/* Notification items */} -
+
User "JohnDoe" has uploaded a new project titled "Introduction to Machine Learning." Check it out now!
-
+
User "JaneSmith" has commented on your project "Data Visualization with D3.js." View the comment now.
-
+
User "TechMaster" has updated the project "Web Development with React.js" with bug fixes. Explore the updated version.
-
+
Congratulations! Your project "Artificial Intelligence in Robotics" has been approved by the moderators. It's now live on the platform.
-
+
User "CodeNinja" has sent you a collaboration request for the project "Cybersecurity Best Practices." Accept or decline the request.
-

See all notifications

+

See all notifications

)}
-
- +
+
-

Sugam Arora

- +

Sugam Arora

+
-