diff --git a/packages/react-core/src/components/AlertGroup/AlertGroup.tsx b/packages/react-core/src/components/Alert/AlertGroup.tsx similarity index 100% rename from packages/react-core/src/components/AlertGroup/AlertGroup.tsx rename to packages/react-core/src/components/Alert/AlertGroup.tsx diff --git a/packages/react-core/src/components/AlertGroup/AlertGroupInline.tsx b/packages/react-core/src/components/Alert/AlertGroupInline.tsx similarity index 100% rename from packages/react-core/src/components/AlertGroup/AlertGroupInline.tsx rename to packages/react-core/src/components/Alert/AlertGroupInline.tsx diff --git a/packages/react-core/src/components/AlertGroup/__tests__/AlertGroup.test.tsx b/packages/react-core/src/components/Alert/__tests__/AlertGroup.test.tsx similarity index 98% rename from packages/react-core/src/components/AlertGroup/__tests__/AlertGroup.test.tsx rename to packages/react-core/src/components/Alert/__tests__/AlertGroup.test.tsx index 89e54553919..deee28f7748 100644 --- a/packages/react-core/src/components/AlertGroup/__tests__/AlertGroup.test.tsx +++ b/packages/react-core/src/components/Alert/__tests__/AlertGroup.test.tsx @@ -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', () => { diff --git a/packages/react-core/src/components/AlertGroup/__tests__/Generated/AlertGroup.test.tsx b/packages/react-core/src/components/Alert/__tests__/Generated/AlertGroup.test.tsx similarity index 100% rename from packages/react-core/src/components/AlertGroup/__tests__/Generated/AlertGroup.test.tsx rename to packages/react-core/src/components/Alert/__tests__/Generated/AlertGroup.test.tsx diff --git a/packages/react-core/src/components/AlertGroup/__tests__/Generated/AlertGroupInline.test.tsx b/packages/react-core/src/components/Alert/__tests__/Generated/AlertGroupInline.test.tsx similarity index 100% rename from packages/react-core/src/components/AlertGroup/__tests__/Generated/AlertGroupInline.test.tsx rename to packages/react-core/src/components/Alert/__tests__/Generated/AlertGroupInline.test.tsx diff --git a/packages/react-core/src/components/AlertGroup/__tests__/Generated/__snapshots__/AlertGroup.test.tsx.snap b/packages/react-core/src/components/Alert/__tests__/Generated/__snapshots__/AlertGroup.test.tsx.snap similarity index 100% rename from packages/react-core/src/components/AlertGroup/__tests__/Generated/__snapshots__/AlertGroup.test.tsx.snap rename to packages/react-core/src/components/Alert/__tests__/Generated/__snapshots__/AlertGroup.test.tsx.snap diff --git a/packages/react-core/src/components/AlertGroup/__tests__/Generated/__snapshots__/AlertGroupInline.test.tsx.snap b/packages/react-core/src/components/Alert/__tests__/Generated/__snapshots__/AlertGroupInline.test.tsx.snap similarity index 100% rename from packages/react-core/src/components/AlertGroup/__tests__/Generated/__snapshots__/AlertGroupInline.test.tsx.snap rename to packages/react-core/src/components/Alert/__tests__/Generated/__snapshots__/AlertGroupInline.test.tsx.snap diff --git a/packages/react-core/src/components/AlertGroup/__tests__/__snapshots__/AlertGroup.test.tsx.snap b/packages/react-core/src/components/Alert/__tests__/__snapshots__/AlertGroup.test.tsx.snap similarity index 100% rename from packages/react-core/src/components/AlertGroup/__tests__/__snapshots__/AlertGroup.test.tsx.snap rename to packages/react-core/src/components/Alert/__tests__/__snapshots__/AlertGroup.test.tsx.snap diff --git a/packages/react-core/src/components/Alert/examples/Alert.md b/packages/react-core/src/components/Alert/examples/Alert.md index 5aaf0bbab29..fc6a0c85682 100644 --- a/packages/react-core/src/components/Alert/examples/Alert.md +++ b/packages/react-core/src/components/Alert/examples/Alert.md @@ -2,7 +2,7 @@ id: Alert section: components cssPrefix: pf-c-alert -propComponents: ['Alert', 'AlertActionCloseButton', 'AlertActionLink'] +propComponents: ['Alert', 'AlertGroup', 'AlertActionCloseButton', 'AlertActionLink'] ouia: true --- @@ -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". @@ -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" +``` diff --git a/packages/react-core/src/components/AlertGroup/examples/AlertGroupAsync.tsx b/packages/react-core/src/components/Alert/examples/AlertGroupAsync.tsx similarity index 100% rename from packages/react-core/src/components/AlertGroup/examples/AlertGroupAsync.tsx rename to packages/react-core/src/components/Alert/examples/AlertGroupAsync.tsx diff --git a/packages/react-core/src/components/AlertGroup/examples/AlertGroupMultipleDynamic.tsx b/packages/react-core/src/components/Alert/examples/AlertGroupMultipleDynamic.tsx similarity index 100% rename from packages/react-core/src/components/AlertGroup/examples/AlertGroupMultipleDynamic.tsx rename to packages/react-core/src/components/Alert/examples/AlertGroupMultipleDynamic.tsx diff --git a/packages/react-core/src/components/AlertGroup/examples/AlertGroupSingularDynamic.tsx b/packages/react-core/src/components/Alert/examples/AlertGroupSingularDynamic.tsx similarity index 100% rename from packages/react-core/src/components/AlertGroup/examples/AlertGroupSingularDynamic.tsx rename to packages/react-core/src/components/Alert/examples/AlertGroupSingularDynamic.tsx diff --git a/packages/react-core/src/components/AlertGroup/examples/AlertGroupSingularDynamicOverflow.tsx b/packages/react-core/src/components/Alert/examples/AlertGroupSingularDynamicOverflow.tsx similarity index 100% rename from packages/react-core/src/components/AlertGroup/examples/AlertGroupSingularDynamicOverflow.tsx rename to packages/react-core/src/components/Alert/examples/AlertGroupSingularDynamicOverflow.tsx diff --git a/packages/react-core/src/components/AlertGroup/examples/AlertGroupStatic.tsx b/packages/react-core/src/components/Alert/examples/AlertGroupStatic.tsx similarity index 100% rename from packages/react-core/src/components/AlertGroup/examples/AlertGroupStatic.tsx rename to packages/react-core/src/components/Alert/examples/AlertGroupStatic.tsx diff --git a/packages/react-core/src/components/AlertGroup/examples/AlertGroupToast.tsx b/packages/react-core/src/components/Alert/examples/AlertGroupToast.tsx similarity index 100% rename from packages/react-core/src/components/AlertGroup/examples/AlertGroupToast.tsx rename to packages/react-core/src/components/Alert/examples/AlertGroupToast.tsx diff --git a/packages/react-core/src/components/AlertGroup/examples/AlertGroupToastOverflowCapture.tsx b/packages/react-core/src/components/Alert/examples/AlertGroupToastOverflowCapture.tsx similarity index 100% rename from packages/react-core/src/components/AlertGroup/examples/AlertGroupToastOverflowCapture.tsx rename to packages/react-core/src/components/Alert/examples/AlertGroupToastOverflowCapture.tsx diff --git a/packages/react-core/src/components/Alert/index.ts b/packages/react-core/src/components/Alert/index.ts index 0c84bd74c44..5122cae9524 100644 --- a/packages/react-core/src/components/Alert/index.ts +++ b/packages/react-core/src/components/Alert/index.ts @@ -2,3 +2,4 @@ export * from './Alert'; export * from './AlertContext'; export * from './AlertActionCloseButton'; export * from './AlertActionLink'; +export * from './AlertGroup'; \ No newline at end of file diff --git a/packages/react-core/src/components/AlertGroup/examples/AlertGroup.md b/packages/react-core/src/components/AlertGroup/examples/AlertGroup.md deleted file mode 100644 index 4d4ae9a7027..00000000000 --- a/packages/react-core/src/components/AlertGroup/examples/AlertGroup.md +++ /dev/null @@ -1,79 +0,0 @@ ---- -id: Alert group -section: components -cssPrefix: pf-c-alert-group -propComponents: ['Alert', 'AlertGroup', 'AlertActionCloseButton', 'AlertActionLink'] ---- - -## Examples - -### 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" -``` diff --git a/packages/react-core/src/components/AlertGroup/index.ts b/packages/react-core/src/components/AlertGroup/index.ts deleted file mode 100644 index 02e94577fcb..00000000000 --- a/packages/react-core/src/components/AlertGroup/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { AlertGroup } from './AlertGroup'; diff --git a/packages/react-core/src/components/index.ts b/packages/react-core/src/components/index.ts index bdd2f2166e6..2966f26f337 100644 --- a/packages/react-core/src/components/index.ts +++ b/packages/react-core/src/components/index.ts @@ -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'; diff --git a/packages/react-core/src/demos/AlertGroup.md b/packages/react-core/src/demos/AlertGroup.md index 922b97801cb..d9f3fb68d7d 100644 --- a/packages/react-core/src/demos/AlertGroup.md +++ b/packages/react-core/src/demos/AlertGroup.md @@ -1,5 +1,5 @@ --- -id: Alert group +id: Alert section: components ---