11// src/components/Announcement.tsx
22// Reusable right-side drawer that shows Notifications and Announcements
33// Adds Syncfusion Dialog for item details
4-
54import React from 'react' ;
65import './Announcement.css' ;
76import { AnnouncementDetailDialog } from './AnnouncementDetailDialog' ;
7+ import { ButtonComponent } from '@syncfusion/ej2-react-buttons' ;
88
99export type PanelItem = {
1010 id : string | number ;
@@ -14,6 +14,7 @@ export type PanelItem = {
1414 type ?: 'announcement' | 'notification' | 'message' ;
1515 content ?: string ; // full body to show in dialog
1616 read ?: boolean ; // optional read flag
17+ iconClass ?: string ;
1718} ;
1819
1920export type AnnouncementPanelProps = {
@@ -51,7 +52,9 @@ export const AnnouncementPanel: React.FC<AnnouncementPanelProps> = ({
5152 } , [ open , defaultTab ] ) ;
5253
5354 React . useEffect ( ( ) => {
54- const onKey = ( e : KeyboardEvent ) => { if ( e . key === 'Escape' ) onClose ( ) ; } ;
55+ const onKey = ( e : KeyboardEvent ) => {
56+ if ( e . key === 'Escape' ) onClose ( ) ;
57+ } ;
5558 document . addEventListener ( 'keydown' , onKey ) ;
5659 return ( ) => document . removeEventListener ( 'keydown' , onKey ) ;
5760 } , [ onClose ] ) ;
@@ -80,6 +83,22 @@ export const AnnouncementPanel: React.FC<AnnouncementPanelProps> = ({
8083 setSelectedItem ( null ) ;
8184 } ;
8285
86+ const handleMarkAllRead = ( ) => {
87+ // Notify parent (if provided)
88+ onMarkAllRead ?.( tab ) ;
89+
90+ // Keep your existing badge-hiding logic (targets TopNav icon buttons)
91+ const selector =
92+ tab === 'announcements'
93+ ? '.icon-btn.e-icons.e-audio span'
94+ : '.icon-btn.e-icons.e-multiple-comment span' ;
95+ document . querySelectorAll ( selector ) . forEach ( ( el ) => {
96+ const span = el as HTMLElement ;
97+ span . style . display = 'none' ;
98+ span . setAttribute ( 'aria-hidden' , 'true' ) ;
99+ } ) ;
100+ } ;
101+
83102 const items = tab === 'notifications' ? notificationItems : announcementItems ;
84103
85104 return (
@@ -98,31 +117,43 @@ export const AnnouncementPanel: React.FC<AnnouncementPanelProps> = ({
98117 >
99118 < div className = "annc-panel-header" >
100119 < div className = "annc-panel-title" > Notification</ div >
101- < button className = "annc-panel-close" type = "button" aria-label = "Close" onClick = { onClose } title = "Close" >
120+ < ButtonComponent
121+ className = "annc-panel-close"
122+ cssClass = "annc-panel-close"
123+ type = "button"
124+ aria-label = "Close"
125+ onClick = { onClose }
126+ title = "Close"
127+ >
102128 < svg width = "18" height = "18" viewBox = "0 0 24 24" aria-hidden = "true" >
103- < path fill = "currentColor" d = "M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" />
129+ < path
130+ fill = "currentColor"
131+ d = "M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"
132+ />
104133 </ svg >
105- </ button >
134+ </ ButtonComponent >
106135 </ div >
107136
108137 < div className = "annc-panel-tabs" role = "tablist" aria-label = "Notification categories" >
109- < button role = "tab" aria-selected = { tab === 'notifications' } className = { tab === 'notifications' ? 'active' : '' } onClick = { ( ) => setActiveTab ( 'notifications' ) } title = "Notifications" >
110- < svg width = "18" height = "18" viewBox = "0 0 24 24" aria-hidden = "true" >
111- < path fill = "currentColor" d = "M12 22a2 2 0 0 0 2-2h-4a2 2 0 0 0 2 2zm6-6V11a6 6 0 1 0-12 0v5l-2 2v1h16v-1l-2-2z" />
112- </ svg >
138+ < button role = "tab" aria-selected = { tab === 'notifications' } className = { tab === 'notifications' ? 'active e-icons e-multiple-comment' : 'e-icons e-multiple-comment' } onClick = { ( ) => setActiveTab ( 'notifications' ) } title = "Notifications" >
113139 </ button >
114- < button role = "tab" aria-selected = { tab === 'announcements' } className = { tab === 'announcements' ? 'active' : '' } onClick = { ( ) => setActiveTab ( 'announcements' ) } title = "Announcements" >
115- < svg width = "18" height = "18" viewBox = "0 0 24 24" aria-hidden = "true" >
116- < path fill = "currentColor" d = "M3 10v4a1 1 0 0 0 1 1h1l3.89 2.6a2 2 0 0 0 3.11-1.65V7.05A2 2 0 0 0 8.89 5.4L5 8H4a1 1 0 0 0-1 1zm18-4v12l-8-4V10l8-4z" />
117- </ svg >
140+ < button role = "tab" aria-selected = { tab === 'announcements' } className = { tab === 'announcements' ? 'active e-icons e-audio' : 'e-icons e-audio' } onClick = { ( ) => setActiveTab ( 'announcements' ) } title = "Announcements" >
118141 </ button >
119142 </ div >
120143
121144 < div className = "annc-panel-subhead" >
122- { tab === 'notifications' ? < span > Notifications for the last 15 days</ span > : < span > Announcements</ span > }
123- < button className = "annc-panel-cta" type = "button" onClick = { ( ) => onMarkAllRead ?.( tab ) } >
145+ { tab === 'notifications' ? (
146+ < span > Notifications for the last 15 days</ span >
147+ ) : (
148+ < span > Announcements</ span >
149+ ) }
150+ < ButtonComponent
151+ cssClass = "annc-panel-cta"
152+ type = "button"
153+ onClick = { handleMarkAllRead }
154+ >
124155 Mark all read
125- </ button >
156+ </ ButtonComponent >
126157 </ div >
127158
128159 < div className = "annc-panel-content" role = "region" aria-live = "polite" >
@@ -138,17 +169,8 @@ export const AnnouncementPanel: React.FC<AnnouncementPanelProps> = ({
138169 onKeyDown = { ( e ) => e . key === 'Enter' && openDetail ( it ) }
139170 title = "View details"
140171 >
141- < span className = { `annc-item-icon ${ tab === 'announcements' ? 'bullhorn' : '' } ` } >
142- < svg width = "16" height = "16" viewBox = "0 0 24 24" aria-hidden = "true" >
143- < path
144- fill = "currentColor"
145- d = {
146- tab === 'announcements'
147- ? 'M3 10v4a1 1 0 0 0 1 1h1l3.89 2.6a2 2 0 0 0 3.11-1.65V7.05A2 2 0 0 0 8.89 5.4L5 8H4a1 1 0 0 0-1 1zm18-4v12l-8-4V10l8-4z'
148- : 'M12 22a2 2 0 0 0 2-2h-4a2 2 0 0 0 2 2zm6-6V11a6 6 0 1 0-12 0v5l-2 2v1h16v-1l-2-2z'
149- }
150- />
151- </ svg >
172+ < span className = "panel-item-icon" aria-hidden = "true" >
173+ < i className = { it . iconClass ?? ( it . type === 'announcement' ? 'e-icons e-audio' : 'e-icons e-multiple-comment' ) } />
152174 </ span >
153175 < div className = "annc-item-body" >
154176 < div className = "annc-item-title" > { it . title } </ div >
@@ -164,7 +186,9 @@ export const AnnouncementPanel: React.FC<AnnouncementPanelProps> = ({
164186 </ ul >
165187 ) : (
166188 < div className = "annc-panel-empty" >
167- { tab === 'notifications' ? 'No notification for the last 15 days.' : 'No announcements for the last 15 days.' }
189+ { tab === 'notifications'
190+ ? 'No notification for the last 15 days.'
191+ : 'No announcements for the last 15 days.' }
168192 </ div >
169193 ) }
170194 </ div >
0 commit comments