Skip to content
Merged
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 @@ -4,7 +4,7 @@ import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';

import { Alert } from '../../Alert';
import { AlertGroup } from '../../AlertGroup';
import { AlertGroup } from '../../Alert';
import { AlertActionCloseButton } from '../../../components/Alert/AlertActionCloseButton';

describe('AlertGroup', () => {
Expand Down
81 changes: 78 additions & 3 deletions packages/react-core/src/components/Alert/examples/Alert.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
id: Alert
section: components
cssPrefix: pf-c-alert
propComponents: ['Alert', 'AlertActionCloseButton', 'AlertActionLink']
propComponents: ['Alert', 'AlertGroup', 'AlertActionCloseButton', 'AlertActionLink']
ouia: true
---

Expand All @@ -13,9 +13,9 @@ import DatabaseIcon from '@patternfly/react-icons/dist/esm/icons/database-icon';
import ServerIcon from '@patternfly/react-icons/dist/esm/icons/server-icon';
import LaptopIcon from '@patternfly/react-icons/dist/esm/icons/laptop-icon';

## Examples
## Alert examples

### Variant examples
### Alert variants

PatternFly supports several alert variants for different scenarios. Each variant has an associated status icon, background, and alert title coded to communicate the severity of an alert. Use the `variant` property to apply the following styling options. If no `variant` is specified, then the variant will be set to "default".

Expand Down Expand Up @@ -364,3 +364,78 @@ Alerts that are asynchronously appended into dynamic [alert groups](/components/
This example shows how an alert could be triggered by an asynchronous event in the application. Note that you can customize how the alert will be announced to assistive technology. See the [https://www.patternfly.org/v4/components/alert/accessibility](alert accessibility) for more information.
```ts file="AlertAsyncLiveRegion.tsx"
```

## Alert group examples

An alert group stacks and positions 2 or more alerts in a live region, either in a layer over the main content of a page or inline with the page content. Alert groups should always rank alerts by age, stacking new alerts on top of old ones as they surface.

### Alert group 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

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

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"
```

### 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"
```

### 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"
```

### Multiple dynamic alert groups

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"
```
1 change: 1 addition & 0 deletions packages/react-core/src/components/Alert/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export * from './Alert';
export * from './AlertContext';
export * from './AlertActionCloseButton';
export * from './AlertActionLink';
export * from './AlertGroup';

This file was deleted.

1 change: 0 additions & 1 deletion packages/react-core/src/components/AlertGroup/index.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/react-core/src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ export * from './AboutModal';
export * from './Accordion';
export * from './ActionList';
export * from './Alert';
export * from './AlertGroup';
export * from './Avatar';
export * from './BackToTop';
export * from './Backdrop';
Expand Down
2 changes: 1 addition & 1 deletion packages/react-core/src/demos/AlertGroup.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
id: Alert group
id: Alert
section: components
---

Expand Down