From 331f5fea3090ed9d6693928239d996276b684f82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Carlos=20S=C3=A1nchez?= Date: Fri, 5 Apr 2024 20:15:00 -0600 Subject: [PATCH] notifications ui done --- components/Notifications.tsx | 159 ++++++++++++++++++++++++----- components/UserProfileButton.tsx | 2 +- components/icons/CloseIcon.tsx | 23 +++++ components/icons/DashboardIcon.tsx | 31 ++++++ components/icons/PIPIcon.tsx | 32 ++++++ components/icons/UserIcon.tsx | 117 +++++++++++++++++++++ 6 files changed, 340 insertions(+), 24 deletions(-) create mode 100644 components/icons/CloseIcon.tsx create mode 100644 components/icons/DashboardIcon.tsx create mode 100644 components/icons/PIPIcon.tsx create mode 100644 components/icons/UserIcon.tsx diff --git a/components/Notifications.tsx b/components/Notifications.tsx index 1bce446..19b6d99 100644 --- a/components/Notifications.tsx +++ b/components/Notifications.tsx @@ -1,33 +1,146 @@ "use client"; -import { useState } from "react"; +import { Menu, Transition } from "@headlessui/react"; +import { Fragment, useEffect, useState } from "react"; +import CloseIcon from "./icons/CloseIcon"; const Notifications = () => { const [isActive, setIsActive] = useState(false); - const notificationsCount = 1; + const [notifications, setNotifications] = useState([ + { + id: 1, + title: "RULER", + type: "RULER", + }, + { + id: 2, + title: "Sprint Survey", + type: "SPRINT", + }, + { + id: 3, + title: "Project Survey", + type: "PROJECT", + }, + ]); + + useEffect(() => { + const onClickOutsideButton = (e: MouseEvent) => { + if (!(e.target as HTMLElement).closest(".group")) { + setIsActive(false); + } + }; + document.addEventListener("click", onClickOutsideButton); + return () => document.removeEventListener("click", onClickOutsideButton); + }, []); + const handleClickNotification = (index: number) => { + const newNotifications = [...notifications]; + newNotifications.splice(index, 1); + setNotifications(newNotifications); + }; + return ( -
setIsActive(!isActive)} - className={`${isActive ? "bg-primary" : "bg-white"} group rounded-full p-2 drop-shadow-lg hover:bg-primary`} - > - + +
setIsActive(!isActive)}> + + + + {notifications.length > 0 && ( + + )} +
+ + + - - - {notificationsCount > 0 && ( - - )} -
+ + + {({ close }) => ( +
+
+

Notifications

+

({notifications.length})

+
+ +
+ )} +
+ {notifications.length > 0 && + notifications.map((notification, index) => { + return ( +
handleClickNotification(index)} + > + + {({ active }) => ( + + )} + +
+ ); + })} + {notifications.length === 0 && ( +
+ +

+ No tienes ninguna notificación +

+
+
+ )} +
+ + ); }; diff --git a/components/UserProfileButton.tsx b/components/UserProfileButton.tsx index 43885a7..aca711a 100644 --- a/components/UserProfileButton.tsx +++ b/components/UserProfileButton.tsx @@ -21,7 +21,7 @@ const UserProfileButton = ({ const isActive = false; return ( + )} + + +
+ {" "} + + {({ active }) => ( + + )} + +
+ + + + ); +}; +export default UserIcon;