Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@
- article:
- text: Headline
- paragraph: Neutral
- article:
- alert:
- text: Headline
- paragraph: Critical
- article:
- status:
- text: Headline
- paragraph: Informational
- article:
- status:
- text: Headline
- paragraph: Successful
- article:
- alert:
- text: Headline
- paragraph: Warning
- link "Closeable"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@
- article:
- text: Headline
- paragraph: Neutral
- article:
- alert:
- text: Headline
- paragraph: Critical
- article:
- status:
- text: Headline
- paragraph: Informational
- article:
- status:
- text: Headline
- paragraph: Successful
- article:
- alert:
- text: Headline
- paragraph: Warning
- link "Closeable"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@
- article:
- text: Headline
- paragraph: Neutral
- article:
- alert:
- text: Headline
- paragraph: Critical
- article:
- status:
- text: Headline
- paragraph: Informational
- article:
- status:
- text: Headline
- paragraph: Successful
- article:
- alert:
- text: Headline
- paragraph: Warning
- link "Closeable"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@
- article:
- text: Headline
- paragraph: Neutral
- article:
- alert:
- text: Headline
- paragraph: Critical
- article:
- status:
- text: Headline
- paragraph: Informational
- article:
- status:
- text: Headline
- paragraph: Successful
- article:
- alert:
- text: Headline
- paragraph: Warning
- link "Closeable"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@
- article:
- text: Headline
- paragraph: Neutral
- article:
- alert:
- text: Headline
- paragraph: Critical
- article:
- status:
- text: Headline
- paragraph: Informational
- article:
- status:
- text: Headline
- paragraph: Successful
- article:
- alert:
- text: Headline
- paragraph: Warning
- link "Closeable"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,16 @@
- article:
- text: Headline
- paragraph: Neutral
- article:
- alert:
- text: Headline
- paragraph: Critical
- article:
- status:
- text: Headline
- paragraph: Informational
- article:
- status:
- text: Headline
- paragraph: Successful
- article:
- alert:
- text: Headline
- paragraph: Warning
- link "Closeable"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
cls,
getBoolean,
getBooleanAsString,
getNotificationRole,
stringPropVisible
} from '../../utils';
import DBButton from '../button/button.lite';
Expand Down Expand Up @@ -41,6 +42,7 @@ export default function DBNotification(props: DBNotificationProps) {
ref={_ref}
id={props.id}
class={cls('db-notification', props.className)}
role={getNotificationRole(props.semantic)}
aria-live={props.ariaLive}
data-semantic={props.semantic}
data-variant={props.variant}
Expand Down
18 changes: 18 additions & 0 deletions packages/components/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,3 +178,21 @@ export const isKeyboardEvent = <T>(
event?: ClickEvent<T> | GeneralKeyboardEvent<T>
): event is GeneralKeyboardEvent<T> =>
(event as GeneralKeyboardEvent<T>).key !== undefined;

/**
* Maps semantic values to appropriate ARIA roles for notifications
* @param semantic - The semantic type of the notification
* @returns The appropriate ARIA role or undefined for default behavior
*/
export const getNotificationRole = (semantic?: string): string | undefined => {
switch (semantic) {
case 'critical':
case 'warning':
return 'alert';
case 'informational':
case 'successful':
return 'status';
default:
return undefined;
}
};
Loading