* initial changes * redesign the sidebar + nav drawer * changes to sidebar items * finish up sidebar redesign * support new sidebar in resources * general fixes * integrate in ui * support api reference * refactor * integrate in user guide * docs: fix build errors * fix user guide build * more refactoring * added banner * added bottom logo + icon * fix up sidebar * fix up paddings * fix shadow bottom * docs: add table of content (#8445) * add toc types * implement toc functionality * finished toc redesign * redesigned table of content * mobile fixes * truncate text in toc * mobile fixes * merge fixes * implement redesign * add hide sidebar * add menu action item * finish up hide sidebar design * implement redesign in resources * integrate in api reference * integrate changes in ui * fixes to api reference scrolling * fix build error * fix build errors * fixes * fixes to sidebar * general fixes * fix active category not closing * fix long titles
72 lines
1.9 KiB
TypeScript
72 lines
1.9 KiB
TypeScript
import {
|
|
NotificationContextType,
|
|
NotificationItemType,
|
|
useNotifications,
|
|
} from "@/providers"
|
|
import React from "react"
|
|
import { NotificationItem } from "./Item"
|
|
import { CSSTransition, TransitionGroup } from "react-transition-group"
|
|
import clsx from "clsx"
|
|
|
|
export const NotificationContainer = () => {
|
|
const { notifications, removeNotification } =
|
|
useNotifications() as NotificationContextType
|
|
|
|
const handleClose = (notification: NotificationItemType) => {
|
|
notification.onClose?.()
|
|
if (notification.id) {
|
|
removeNotification(notification.id)
|
|
}
|
|
}
|
|
|
|
const renderFilteredNotifications = (
|
|
condition: (notificaiton: NotificationItemType) => boolean,
|
|
className?: string
|
|
) => {
|
|
return (
|
|
<TransitionGroup
|
|
className={clsx(
|
|
"flex fixed z-40 flex-col gap-docs_0.5 right-0",
|
|
"md:w-auto w-full overflow-y-auto",
|
|
"max-h-[50%] md:max-h-[calc(100vh-57px)]",
|
|
"max-[768px]:max-h-[50%]",
|
|
className
|
|
)}
|
|
>
|
|
{notifications.filter(condition).map((notification) => (
|
|
<CSSTransition
|
|
key={notification.id}
|
|
timeout={200}
|
|
classNames={{
|
|
enter: "animate-slideInRight animate-fast",
|
|
exit: "animate-slideOutRight animate-fast",
|
|
}}
|
|
>
|
|
<NotificationItem
|
|
{...notification}
|
|
onClose={() => handleClose(notification)}
|
|
className={clsx(
|
|
notification.className,
|
|
"!relative !top-0 !bottom-0 !right-0"
|
|
)}
|
|
/>
|
|
</CSSTransition>
|
|
))}
|
|
</TransitionGroup>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<>
|
|
{renderFilteredNotifications(
|
|
(notification) => notification.placement === "top",
|
|
"top-0"
|
|
)}
|
|
{renderFilteredNotifications(
|
|
(notification) => notification.placement !== "top",
|
|
"bottom-0"
|
|
)}
|
|
</>
|
|
)
|
|
}
|