notifications on tabs bar'

This commit is contained in:
anovazzi1 2023-03-06 19:51:00 -03:00
commit fc6fee3d21
7 changed files with 109 additions and 84 deletions

View file

@ -22,7 +22,7 @@ export default function SingleAlert({ dropItem, removeAlert}:SingleAlertComponen
leaveTo={"transform translate-x-[-100%]"} leaveTo={"transform translate-x-[-100%]"}
> >
{type === "error"? {type === "error"?
<div className="flex bg-red-50 rounded-md p-4 mb-2" key={dropItem.id}> <div className="flex bg-red-50 rounded-md p-3 mb-2 mx-2" key={dropItem.id}>
<div className="flex-shrink-0"> <div className="flex-shrink-0">
<XCircleIcon <XCircleIcon
className="h-5 w-5 text-red-400" className="h-5 w-5 text-red-400"
@ -61,7 +61,7 @@ export default function SingleAlert({ dropItem, removeAlert}:SingleAlertComponen
</div> </div>
</div> </div>
:(type === "notice" ? :(type === "notice" ?
<div className="flex rounded-md p-4 bg-blue-50 mb-2" key={dropItem.id}> <div className="flex rounded-md bg-blue-50 p-3 mb-2 mx-2" key={dropItem.id}>
<div className="flex-shrink-0"> <div className="flex-shrink-0">
<InformationCircleIcon <InformationCircleIcon
className="h-5 w-5 text-blue-400" className="h-5 w-5 text-blue-400"
@ -99,7 +99,7 @@ export default function SingleAlert({ dropItem, removeAlert}:SingleAlertComponen
</div> </div>
</div> </div>
: :
<div className="flex bg-green-50 p-4 mb-2" key={dropItem.id}> <div className="flex bg-green-50 p-3 mb-2 mx-2 rounded-md" key={dropItem.id}>
<div className="flex-shrink-0"> <div className="flex-shrink-0">
<CheckCircleIcon <CheckCircleIcon
className="h-5 w-5 text-green-400" className="h-5 w-5 text-green-400"

View file

@ -3,54 +3,45 @@ import { alertContext } from "../../contexts/alertContext";
import { import {
XMarkIcon, XMarkIcon,
} from "@heroicons/react/24/solid"; } from "@heroicons/react/24/solid";
import { Transition } from "@headlessui/react";
import { TrashIcon } from "@heroicons/react/24/outline"; import { TrashIcon } from "@heroicons/react/24/outline";
import SingleAlert from "./components/singleAlertComponent"; import SingleAlert from "./components/singleAlertComponent";
import { AlertDropdownType } from "../../types/alerts"; import { AlertDropdownType } from "../../types/alerts";
import { PopUpContext } from "../../contexts/popUpContext";
export default function AlertDropdown({closeFunction, open}: AlertDropdownType) { export default function AlertDropdown({}: AlertDropdownType) {
const { const {
notificationList, notificationList,
clearNotificationList, clearNotificationList,
removeFromNotificationList, removeFromNotificationList,
} = useContext(alertContext); } = useContext(alertContext);
const {closePopUp} = useContext(PopUpContext)
return ( return (
<Transition <div className="z-10 py-2 pb-4 rounded-md bg-white ring-1 ring-black ring-opacity-5 shadow-lg focus:outline-none overflow-hidden w-[14rem] h-[28rem] flex flex-col">
show={open} <div className="flex pl-3 flex-row justify-between text-md font-medium text-gray-800">
enter="transition ease-out duration-100"
enterFrom="transform opacity-0 scale-95"
enterTo="transform opacity-100 scale-100"
leave="transition ease-in duration-75"
leaveFrom="transform opacity-100 scale-100"
leaveTo="transform opacity-0 scale-95"
>
<div className="z-10 px-8 py-6 pb-8 rounded-md bg-white ring-1 ring-black ring-opacity-5 shadow-lg focus:outline-none overflow-hidden w-[36rem] h-[40rem] flex flex-col">
<div className="flex flex-row justify-between text-md font-medium text-gray-800">
Notifications Notifications
<div className="flex gap-4"> <div className="flex gap-3 pr-2 ">
<button <button
className="hover:text-black" className="hover:text-black"
onClick={() => {closeFunction(); setTimeout(clearNotificationList, 100)}} onClick={() => {closePopUp(); setTimeout(clearNotificationList, 100)}}
> >
<TrashIcon className="w-5 h-5" /> <TrashIcon className="w-5 h-5" />
</button> </button>
<button <button
className="hover:text-black" className="hover:text-black"
onClick={closeFunction} onClick={closePopUp}
> >
<XMarkIcon className="h-6 w-6" /> <XMarkIcon className="h-6 w-6" />
</button> </button>
</div> </div>
</div> </div>
<div className="mt-6 flex flex-col overflow-y-scroll w-full h-full scrollbar-hide"> <div className="mt-2 flex flex-col overflow-y-scroll w-full h-full scrollbar-hide">
{notificationList.length !== 0 ? {notificationList.length !== 0 ?
notificationList.map((alertItem, index) => ( notificationList.map((alertItem, index) => (
<SingleAlert key={index} dropItem={alertItem} removeAlert={removeFromNotificationList} /> <SingleAlert key={alertItem.id} dropItem={alertItem} removeAlert={removeFromNotificationList} />
)) ))
: :
<div className="h-full w-full pb-16 text-gray-500 flex justify-center items-center"> <div className="h-full w-full pb-16 text-gray-500 flex justify-center items-center">
@ -59,6 +50,5 @@ export default function AlertDropdown({closeFunction, open}: AlertDropdownType)
} }
</div> </div>
</div> </div>
</Transition>
); );
} }

View file

@ -20,6 +20,7 @@ export default function Header(){
preferX: "left", preferX: "left",
triggerOffset: 10, triggerOffset: 10,
containerOffset: 12, containerOffset: 12,
overflowContainer:false,
arrowOffset: 4, arrowOffset: 4,
}) })
const {dark, setDark} = useContext(darkContext); const {dark, setDark} = useContext(darkContext);
@ -42,7 +43,7 @@ export default function Header(){
{notificationCenter&&<div className='absolute top-[2px] w-2 h-2 rounded-full bg-red-600 right-[7px]'></div>} {notificationCenter&&<div className='absolute top-[2px] w-2 h-2 rounded-full bg-red-600 right-[7px]'></div>}
<BellIcon className="h-6 w-6" aria-hidden="true" /> <BellIcon className="h-6 w-6" aria-hidden="true" />
</button>{renderLayer(<div {...layerProps}><AlertDropdown closeFunction={()=>setIsOpen(false)} open={isOpen}></AlertDropdown></div>)} </button>{renderLayer(<div {...layerProps}></div>)}
</span> </span>
</div> </div>
</div> </div>

View file

@ -12,13 +12,13 @@ export default function ContextWrapper({ children }:{children:ReactNode}) {
<> <>
<DarkProvider> <DarkProvider>
<LocationProvider> <LocationProvider>
<AlertProvider>
<PopUpProvider> <PopUpProvider>
<TypesProvider> <TypesProvider>
<TabsProvider> <TabsProvider>{children}</TabsProvider>
<AlertProvider>{children}</AlertProvider>
</TabsProvider>
</TypesProvider> </TypesProvider>
</PopUpProvider> </PopUpProvider>
</AlertProvider>
</LocationProvider> </LocationProvider>
</DarkProvider> </DarkProvider>
</> </>

View file

@ -29,7 +29,7 @@ export default function TabComponent({ selected, flow, onClick }:{flow:FlowType,
</button> </button>
</div> </div>
) : ( ) : (
<div className="bg-white dark:text-white dark:bg-gray-700 flex select-none justify-between w-44 items-center border border-b-0 border-gray-300 dark:border-gray-600 px-4 py-1.5 rounded-t-xl -ml-px"> <div className="bg-white dark:text-white dark:bg-gray-700 flex select-none justify-between w-44 items-center border border-b-0 border-gray-300 dark:border-gray-600 px-4 py-1 rounded-t-xl -ml-px">
{isRename ? ( {isRename ? (
<input <input
autoFocus autoFocus

View file

@ -1,11 +1,21 @@
import { useContext, useEffect } from "react"; import { useContext, useEffect, useState } from "react";
import { ReactFlowProvider } from "reactflow"; import { ReactFlowProvider } from "reactflow";
import TabComponent from "../tabComponent"; import TabComponent from "../tabComponent";
import { TabsContext } from "../../../../contexts/tabsContext"; import { TabsContext } from "../../../../contexts/tabsContext";
import FlowPage from "../.."; import FlowPage from "../..";
import { darkContext } from "../../../../contexts/darkContext";
import { BellIcon, MoonIcon, SunIcon } from "@heroicons/react/24/outline";
import { PopUpContext } from "../../../../contexts/popUpContext";
import AlertDropdown from "../../../../alerts/alertDropDown";
import { alertContext } from "../../../../contexts/alertContext";
export default function TabsManagerComponent() { export default function TabsManagerComponent() {
const { flows, addFlow, tabIndex, setTabIndex } = useContext(TabsContext); const { flows, addFlow, tabIndex, setTabIndex } = useContext(TabsContext);
const { openPopUp } = useContext(PopUpContext);
const AlertWidth = 224
const { dark, setDark } = useContext(darkContext);
const [isOpen, setIsOpen] = useState(false);
const {notificationCenter, setNotificationCenter} = useContext(alertContext)
useEffect(() => { useEffect(() => {
//create the first flow //create the first flow
if (flows.length === 0) { if (flows.length === 0) {
@ -33,6 +43,32 @@ export default function TabsManagerComponent() {
selected={false} selected={false}
flow={null} flow={null}
/> />
<div className="ml-auto mr-2 flex gap-3">
<button
className="text-gray-400 hover:text-gray-500 "
onClick={() => {
setDark(!dark);
}}
>
{dark ? (
<SunIcon className="h-5 w-5" />
) : (
<MoonIcon className="h-5 w-5" />
)}
</button>
<button
className="text-gray-400 hover:text-gray-500 relative"
onClick={(event: React.MouseEvent<HTMLElement>) => {
setNotificationCenter(false)
const top = (event.target as Element).getBoundingClientRect().top
const left = (event.target as Element).getBoundingClientRect().left
openPopUp(<div className="z-10 absolute" style={{top:top+20, left:left-AlertWidth}}><AlertDropdown/></div>)
}}
>
{notificationCenter&&<div className='absolute w-1.5 h-1.5 rounded-full bg-red-600 right-[3px]'></div>}
<BellIcon className="h-5 w-5" aria-hidden="true" />
</button>
</div>
</div> </div>
<div className="w-full h-full"> <div className="w-full h-full">
<ReactFlowProvider> <ReactFlowProvider>

View file

@ -3,8 +3,6 @@ export type NoticeAlertType = {title:string,link:string,id:string,removeAlert:(i
export type SuccessAlertType = {title:string,id:string, removeAlert:(id:string)=>void} export type SuccessAlertType = {title:string,id:string, removeAlert:(id:string)=>void}
export type SingleAlertComponentType = {dropItem:AlertItemType,removeAlert:(index:string)=>void} export type SingleAlertComponentType = {dropItem:AlertItemType,removeAlert:(index:string)=>void}
export type AlertDropdownType = { export type AlertDropdownType = {
closeFunction: () => void;
open?: boolean;
}; };
export type AlertItemType = { export type AlertItemType = {
type: "notice" | "error" | "success"; type: "notice" | "error" | "success";