import { useRef } from 'react'; import classnames from 'classnames'; import { useDragResize } from 'hooks/useDragResize'; import { usePersistedState } from 'hooks/usePersistedState'; import Modal from 'components/Modal/index'; import Portal from 'components/Portal'; import StyledWrapper from './StyledWrapper'; import NotificationTabs from './NotificationTabs'; import NotificationList from './NotificationList'; import NotificationDetail from './NotificationDetail'; const DEFAULT_SIDEBAR_WIDTH = 260; const SIDEBAR_MIN = 200; // Reserved for the detail pane; caps the sidebar at ~420px in the 800px modal. const DETAIL_MIN = 380; const NotificationsModal = ({ notifications, onClose }) => { const { visibleNotifications, listed, unreadCount, activeTab, selectedNotification, onTabChange, onSelect, onMarkAllRead, onClearAll } = notifications; const containerRef = useRef(null); const [sidebarWidth, setSidebarWidth] = usePersistedState({ key: 'notification-sidebar', default: DEFAULT_SIDEBAR_WIDTH }); const { dragging, dragWidth, dragbarProps } = useDragResize({ containerRef, width: sidebarWidth, onWidthChange: (w) => setSidebarWidth(w ?? DEFAULT_SIDEBAR_WIDTH), minLeft: SIDEBAR_MIN, minRight: DETAIL_MIN }); const effectiveWidth = dragging ? dragWidth : sidebarWidth; const isEmpty = visibleNotifications.length === 0; return (
{isEmpty ? (
You are all caught up!
) : ( )} ); }; export default NotificationsModal;