diff --git a/src/Components/Container.css b/src/Components/Container.css index fa64ad03..293406f1 100644 --- a/src/Components/Container.css +++ b/src/Components/Container.css @@ -153,6 +153,56 @@ color: #f1f1f1; } +.notification-container { + position: relative; +} + +.profileIcon { + cursor: pointer; +} + +.dropdown-content { + position: absolute; + top: 100%; + right: 0; + background-color: #19162c; + border-radius: 10px; + box-shadow: 0px 0px 20px rgba(0, 0, 0, 0.4); + padding: 8px; + z-index: 1; + width: 400px; /* Adjust width as needed */ + padding: 20px; +} + +.notification-item { + padding: 8px 0; + border-bottom: 1px solid #eee; +} + +.notification-item:last-child { + border-bottom: none; +} + +.seeAll { + text-align: center; + margin-top: 10px; + cursor: pointer; + font-weight: bold; +} + +.notification-item { + padding: 8px 0; + border-bottom: 1px solid #121026; + transition: background-color 0.3s ease; /* Add transition for smooth color change */ + cursor: pointer; +} + +.notification-item:hover { + background-color: #121026; /* Change background color on hover */ + +} + + @media screen and (max-width: 525px) { .container { width: calc(100% - 68px); diff --git a/src/Components/TopContainer.js b/src/Components/TopContainer.js index 8fd0ad07..60030139 100644 --- a/src/Components/TopContainer.js +++ b/src/Components/TopContainer.js @@ -1,23 +1,33 @@ -import React, { useEffect } from "react"; +import React, { useEffect, useState, useRef } from "react"; import { BiSearchAlt } from "react-icons/bi"; import { FaBell, FaChevronDown } from "react-icons/fa"; import women from "../img/women.jpg"; function TopContainer() { + const [isDropdownOpen, setIsDropdownOpen] = useState(false); + const dropdownRef = useRef(null); + useEffect(() => { - const mouseTarget = document.getElementById("menuChevron"); - const menuContainer = document.getElementById("menuContainer"); - mouseTarget.addEventListener("mouseenter", () => { - mouseTarget.style.transform = "rotate(180deg)"; - menuContainer.style.transform = "translateX(0px)"; - }); - - menuContainer.addEventListener("mouseleave", () => { - mouseTarget.style.transform = "rotate(0deg)"; - menuContainer.style.transform = "translateX(300px)"; - }); + // Add event listener to detect clicks anywhere on the page + window.addEventListener("click", handleOutsideClick); + + // Cleanup function to remove the event listener + return () => { + window.removeEventListener("click", handleOutsideClick); + }; }, []); + const toggleDropdown = () => { + setIsDropdownOpen(!isDropdownOpen); + }; + + const handleOutsideClick = (event) => { + // Check if the clicked element is outside the dropdown content + if (dropdownRef.current && !dropdownRef.current.contains(event.target)) { + setIsDropdownOpen(false); + } + }; + return (
See all notifications
+Sugam Arora