Skip to content

Commit

Permalink
Adds content to alert group react examples. (patternfly#7763)
Browse files Browse the repository at this point in the history
* Adds content to alert group react examples.

* Adjusts headings.

* Updates heading level.

* Updates alertgroup content.

* Incorporates feedback and edits content for readability and simplicity.

* Small wording change.
  • Loading branch information
edonehoo authored and andyyvo committed Sep 9, 2022
1 parent 726632f commit 3916c82
Showing 1 changed file with 52 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,74 @@ propComponents: ['Alert', 'AlertGroup', 'AlertActionCloseButton', 'AlertActionLi
---

## Examples
### Static alert group
These alerts appear on page load and are discoverable from within the normal page content flow, and will not be announced individually/explicitly to assistive technology.

### Variants

Alert groups can be one of the following variants:

| Variant | Description |
| --- | --- |
| Static inline | Static inline alert groups contain alerts that appear when the page loads, and are seen within the normal page content flow. These groups should not contain alerts that will dynamically appear or update. |
| Toast | Toast alert groups contain alerts that typically appear in response to an asynchronous event or user action. These groups are positioned on top of other content at the top right of the page.|
| Dynamic | Dynamic alert groups contain alerts that typically appear in response to a user action, and are seen within the normal page content flow.|

Dynamic alerts that are generated after the page initially loads must be appended to either a toast or dynamic `AlertGroup`, both of which must use the `isLiveRegion` property. New alerts appended to a toast or dynamic group will be announced by assistive technologies the moment the change happens. For information about customizing this announcement, read the [aria-atomic and aria-relevant](/components/alert-group/accessibility#aria-atomic-and-aria-relevant) section of the alert group accessibility documentation.

### Static inline alert group

All alert group variants may combine multiple [alert variants](/components/alert) For example, the following static inline alert group includes one "success" alert and one "info" alert.

```ts file="./AlertGroupStatic.tsx"
```

### Toast alert group
Alerts asynchronously appended into dynamic AlertGroups with `isLiveRegion` will be announced to assistive technology at the moment the change happens, following the strategy used for aria-atomic, which defaults to false. This means only changes of type "addition" will be announced.

Toast alert groups are created by passing in the `isToast` and `isLiveRegion` properties.

Click the buttons in the example below to add alerts to a toast group.

```ts file="./AlertGroupToast.tsx"
```

### Toast alert group with overflow capture
After a specified number of alerts displayed is reached, we will see an overflow message instead of new alerts. Alerts asynchronously appended into dynamic AlertGroups with `isLiveRegion` will be announced to assistive technology at the moment the change happens. When the overflow message appears or is updated in AlertGroups with `isLiveRegion`, the `View 1 more alert` text will be read, but the alert message will not be read. screen reader user or keyboard user will need a way to navigate to and reveal the hidden alerts before they disappear. Alternatively, there should be a place that notifications or alerts are collected to be viewed or read later. In this example we are showing a max of 4 alerts.

Users will see an overflow message once a predefined number of alerts are displayed. They will not see any alerts beyond the display limit, which must be explicitly set.

In the following example, an overflow message will appear when more than 4 alerts would be shown. When a 5th alert would appear, an overflow message is shown instead.

When an overflow message appears in an `AlertGroup` using the `isLiveRegion` property, the "view 1 more alert" text label will be announced, but the alert message will not.

Users navigating via keyboard or another assistive technology will need a way to navigate to and reveal hidden alerts before they disappear. Alternatively, there should be a place where notifications or alerts are collected to be viewed or read later.

```ts file="AlertGroupToastOverflowCapture.tsx" isBeta
```

### Singular dynamic alert group
This alert will appear in the page, most likely in response to a user action.
### Asynchronous alert groups

The following example shows how alerts can be triggered by an asynchronous event in the application. You can customize how an alert will be announced to assistive technology by adjusting the value of the `aria-live` property. Click the "start async" alert button below and then click the buttons in the above toast examples to demonstrate how asynchronous events add alerts to a group. Click the "stop async alerts" button to halt this behavior.

See the [alert group accessibility tab](/components/alert-group/accessibility) for more information on customizing this behavior.

```ts file="./AlertGroupAsync.tsx"
```

### Dynamic alert groups

Click the buttons in the example below to add dynamic alerts to a group.

```ts file="./AlertGroupSingularDynamic.tsx"
```

### Singular dynamic alert group with overflow message
This alert will appear in the page, most likely in response to a user action. In this example we are showing a max of 4 alerts.
### Dynamic alert group with overflow message

In the following example, there can be a maximum of 4 alerts shown at once.

```ts file="AlertGroupSingularDynamicOverflow.tsx" isBeta
```

### Multiple dynamic alert group
These alerts will appear in the page, most likely in response to a user action.
```ts file="./AlertGroupMultipleDynamic.tsx"
```
### Multiple dynamic alert groups

### Async alert group
This shows how an alert could be triggered by an asynchronous event in the application. Note how you can customize how the alert will be announced to assistive technology. See the alert group accessibility tab for more information.
```ts file="./AlertGroupAsync.tsx"
You may add multiple alerts to an alert group at once. Click the "add alert collection" button in the example below to add a batch of 3 toast alerts to a group.

```ts file="./AlertGroupMultipleDynamic.tsx"
```

0 comments on commit 3916c82

Please sign in to comment.