File tree Expand file tree Collapse file tree 2 files changed +20
-0
lines changed
Expand file tree Collapse file tree 2 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import {
1212 cls ,
1313 getBoolean ,
1414 getBooleanAsString ,
15+ getNotificationRole ,
1516 stringPropVisible
1617} from '../../utils' ;
1718import DBButton from '../button/button.lite' ;
@@ -41,6 +42,7 @@ export default function DBNotification(props: DBNotificationProps) {
4142 ref = { _ref }
4243 id = { props . id }
4344 class = { cls ( 'db-notification' , props . className ) }
45+ role = { getNotificationRole ( props . semantic ) }
4446 aria-live = { props . ariaLive }
4547 data-semantic = { props . semantic }
4648 data-variant = { props . variant }
Original file line number Diff line number Diff line change @@ -157,3 +157,21 @@ export const isKeyboardEvent = <T>(
157157 event ?: ClickEvent < T > | GeneralKeyboardEvent < T >
158158) : event is GeneralKeyboardEvent < T > =>
159159 ( event as GeneralKeyboardEvent < T > ) . key !== undefined ;
160+
161+ /**
162+ * Maps semantic values to appropriate ARIA roles for notifications
163+ * @param semantic - The semantic type of the notification
164+ * @returns The appropriate ARIA role or undefined for default behavior
165+ */
166+ export const getNotificationRole = ( semantic ?: string ) : string | undefined => {
167+ switch ( semantic ) {
168+ case 'critical' :
169+ case 'warning' :
170+ return 'alert' ;
171+ case 'informational' :
172+ case 'successful' :
173+ return 'status' ;
174+ default :
175+ return undefined ;
176+ }
177+ } ;
You can’t perform that action at this time.
0 commit comments