import React from 'react'; import { Avatar, Brand, Breadcrumb, BreadcrumbItem, Button, ButtonVariant, Content, Divider, Dropdown, DropdownItem, DropdownList, EmptyState, EmptyStateActions, EmptyStateBody, EmptyStateFooter, EmptyStateVariant, MenuToggle, Nav, NavItem, NavList, NotificationBadge, NotificationDrawer, NotificationDrawerBody, NotificationDrawerGroup, NotificationDrawerGroupList, NotificationDrawerHeader, NotificationDrawerList, NotificationDrawerListItem, NotificationDrawerListItemBody, NotificationDrawerListItemHeader, Page, PageSection, PageSidebar, PageSidebarBody, SkipToContent, PageToggleButton, Masthead, MastheadMain, MastheadBrand, MastheadToggle, MastheadContent, MastheadLogo, Toolbar, ToolbarItem, ToolbarGroup, ToolbarContent } from '@patternfly/react-core'; import BellIcon from '@patternfly/react-icons/dist/esm/icons/bell-icon'; import CogIcon from '@patternfly/react-icons/dist/esm/icons/cog-icon'; import BarsIcon from '@patternfly/react-icons/dist/esm/icons/bars-icon'; import HelpIcon from '@patternfly/react-icons/dist/esm/icons/help-icon'; import SearchIcon from '@patternfly/react-icons/dist/esm/icons/search-icon'; import QuestionCircleIcon from '@patternfly/react-icons/dist/esm/icons/question-circle-icon'; import EllipsisVIcon from '@patternfly/react-icons/dist/esm/icons/ellipsis-v-icon'; import imgAvatar from '@patternfly/react-core/src/components/assets/avatarImg.svg'; import pfLogo from '@patternfly/react-core/src/demos/assets/pf-logo.PF-HorizontalLogo-Color.svg'; export const NotificationDrawerGrouped: React.FunctionComponent = () => { const drawerRef = React.useRef(null); const [isDropdownOpen, setIsDropdownOpen] = React.useState(false); const [isKebabDropdownOpen, setIsKebabDropdownOpen] = React.useState(false); const [isDrawerExpanded, setIsDrawerExpanded] = React.useState(false); const [firstDrawerGroupExpanded, setFirstDrawerGroupExpanded] = React.useState(false); const [secondDrawerGroupExpanded, setSecondDrawerGroupExpanded] = React.useState(true); const [thirdDrawerGroupExpanded, setThirdDrawerGroupExpanded] = React.useState(false); interface UnreadMap { [groupName: string]: { [notificationId: string]: boolean; } | null; } const [activeItem, setActiveItem] = React.useState(0); const [isUnreadMap, setIsUnreadMap] = React.useState({ 'group-1': { 'notification-5': true, 'notification-6': true }, 'group-2': { 'notification-9': true, 'notification-10': true }, 'group-3': null }); const [shouldShowNotifications, setShouldShowNotifications] = React.useState(true); interface ActionsMenu { [toggleId: string]: boolean; } const [isActionsMenuOpen, setIsActionsMenuOpen] = React.useState({}); const onNavSelect = ( _event: React.FormEvent, selectedItem: { groupId: number | string; itemId: number | string; to: string; } ) => setActiveItem(selectedItem.itemId); const onDropdownToggle = () => setIsDropdownOpen((prevState) => !prevState); const onDropdownSelect = () => setIsDropdownOpen(false); const onKebabDropdownToggle = () => setIsKebabDropdownOpen((prevState) => !prevState); const onKebabDropdownSelect = () => setIsKebabDropdownOpen(false); const onCloseNotificationDrawer = (_event: any) => setIsDrawerExpanded((prevState) => !prevState); const onToggle = (id: string) => { setIsActionsMenuOpen({ [id]: !isActionsMenuOpen[id] }); }; const closeActionsMenu = () => setIsActionsMenuOpen({}); const onListItemClick = (groupId: string, id: string) => { if (isUnreadMap === null) { return; } if (!isUnreadMap[groupId]) { setIsUnreadMap({ ...isUnreadMap, [groupId]: { [id]: false } }); } else { setIsUnreadMap({ ...isUnreadMap, [groupId]: { ...isUnreadMap[groupId], [id]: false } }); } }; const isUnread = (groupId: string, id: string) => isUnreadMap && isUnreadMap[groupId] !== null && isUnreadMap[groupId][id]; const getNumberUnread = (groupId: string | null) => { if (!isUnreadMap) { return 0; } if (groupId) { const group = isUnreadMap[groupId]; if (!group) { return 0; } return Object.values(group).reduce((count, value) => (value ? count + 1 : count), 0); } return Object.keys(isUnreadMap).reduce((count, groupId) => { const group = isUnreadMap[groupId]; if (!group) { return count; } return Object.values(group).reduce((groupCount, value) => (value ? groupCount + 1 : groupCount), count); }, 0); }; const markAllRead = () => setIsUnreadMap(null); const showNotifications = (showNotifications: boolean) => { setIsUnreadMap(null); setShouldShowNotifications(showNotifications); }; const toggleFirstDrawer = (_event: any, value: boolean | ((prevState: boolean) => boolean)) => { setFirstDrawerGroupExpanded(value); }; const toggleSecondDrawer = (_event: any, value: boolean | ((prevState: boolean) => boolean)) => { setSecondDrawerGroupExpanded(value); }; const toggleThirdDrawer = (_event: any, value: boolean | ((prevState: boolean) => boolean)) => { setThirdDrawerGroupExpanded(value); }; const focusDrawer = (_event: any) => { if (drawerRef.current === null) { return; } // Prevent the NotificationDrawer from receiving focus if a drawer group item is opened if (!document.activeElement?.closest(`.${drawerRef.current.className}`)) { const firstTabbableItem = drawerRef.current.querySelector('a, button') as | HTMLAnchorElement | HTMLButtonElement | null; firstTabbableItem?.focus(); } }; const PageNav = ( ); const kebabDropdownItems = ( <> Settings Help ); const userDropdownItems = ( <> My profile User management Logout ); const headerToolbar = ( onCloseNotificationDrawer(event)} aria-label="Notifications" isExpanded={isDrawerExpanded} > )} {!shouldShowNotifications && ( There are currently no alerts. There may be silenced critical alerts however. )} ); return ( | KeyboardEvent | React.TransitionEvent ) => focusDrawer(event)} skipToContent={PageSkipToContent} breadcrumb={PageBreadcrumb} mainContainerId={pageId} >

Main title

Body text should be Red Hat Text at 1rem(16px). It should have leading of 1.5rem(24px) because
of its relative line height of 1.5.

Panel section content
); };