Skip to content

Commit 3a5246e

Browse files
chore(Alert): updated examples to enable animations (#11705)
* chore(Alert): updated examples to enable animations * Updated docs verbiage per Erin
1 parent 06f0914 commit 3a5246e

File tree

10 files changed

+37
-21
lines changed

10 files changed

+37
-21
lines changed

packages/react-core/src/components/Alert/examples/Alert.md

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,23 @@ import ServerIcon from '@patternfly/react-icons/dist/esm/icons/server-icon';
1515
import LaptopIcon from '@patternfly/react-icons/dist/esm/icons/laptop-icon';
1616
import buttonStyles from '@patternfly/react-styles/css/components/Button/button';
1717

18+
Micro animations have been added for `<Alert>` components within an `<AlertGroup>`. By default, you must opt into animations, since they can require updates to tests. To enable or disable animations as needed, use the `hasAnimations` property. With animations enabled, we recommend you ensure that dynamically-added alerts are prepended to a list of alerts, rather than appended to the end of it.
19+
20+
Micro animations are turned on for all examples and demos where alerts are dynamically added.
21+
1822
## Alert examples
1923

2024
### Alert variants
2125

2226
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 "custom".
2327

24-
| Variant | Description |
25-
|---|---|
26-
| Custom | Use for generic messages that should have a custom color set by the associated CSS variable. Should be used when the message has no associated severity. |
27-
| Info | Use for general informational messages |
28-
| Success | Use to indicate that a task or process has been completed successfully |
29-
| Warning | Use to indicate that a non-critical error has occurred|
30-
| Danger | Use to indicate that a critical or blocking error has occurred |
28+
| Variant | Description |
29+
| ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
30+
| Custom | Use for generic messages that should have a custom color set by the associated CSS variable. Should be used when the message has no associated severity. |
31+
| Info | Use for general informational messages |
32+
| Success | Use to indicate that a task or process has been completed successfully |
33+
| Warning | Use to indicate that a non-critical error has occurred |
34+
| Danger | Use to indicate that a critical or blocking error has occurred |
3135

3236
```ts
3337
import { Fragment } from 'react';
@@ -148,7 +152,7 @@ const AlertTimeout: React.FunctionComponent = () => {
148152
<Button variant="secondary" onClick={() => setAlerts([])}>
149153
Remove all alerts
150154
</Button>
151-
<AlertGroup isLiveRegion>{alerts}</AlertGroup>
155+
<AlertGroup hasAnimations isLiveRegion>{alerts}</AlertGroup>
152156
</Fragment>
153157
);
154158
};
@@ -405,11 +409,11 @@ An alert group stacks and positions 2 or more alerts in a live region, either in
405409
406410
Alert groups can be one of the following variants:
407411
408-
| Variant | Description |
409-
| --- | --- |
412+
| Variant | Description |
413+
| ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
410414
| 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. |
411-
| 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.|
412-
| Dynamic | Dynamic alert groups contain alerts that typically appear in response to a user action, and are seen within the normal page content flow.|
415+
| 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. |
416+
| Dynamic | Dynamic alert groups contain alerts that typically appear in response to a user action, and are seen within the normal page content flow. |
413417
414418
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/accessibility#aria-atomic-and-aria-relevant) section of the alert accessibility documentation.
415419

packages/react-core/src/components/Alert/examples/AlertAsyncLiveRegion.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export const AsyncLiveRegionAlert: React.FunctionComponent = () => {
5151
onChange={() => setIsActive(false)}
5252
/>
5353
</ToggleGroup>
54-
<AlertGroup isLiveRegion>
54+
<AlertGroup hasAnimations isLiveRegion>
5555
{alerts.map(({ title, variant, key }) => (
5656
<Alert variant={variant} title={title} key={key} />
5757
))}

packages/react-core/src/components/Alert/examples/AlertDynamicLiveRegion.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export const DynamicLiveRegionAlert: React.FunctionComponent = () => {
5252
Add single danger alert
5353
</button>
5454
</InputGroup>
55-
<AlertGroup isLiveRegion aria-live="polite" aria-relevant="additions text" aria-atomic="false">
55+
<AlertGroup hasAnimations isLiveRegion aria-live="polite" aria-relevant="additions text" aria-atomic="false">
5656
{alerts.map(({ title, variant, key }) => (
5757
<Alert variant={variant} title={title} key={key} />
5858
))}

packages/react-core/src/components/Alert/examples/AlertGroupAsync.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export const AlertGroupAsync: React.FunctionComponent = () => {
5858
</button>
5959
</InputGroupItem>
6060
</InputGroup>
61-
<AlertGroup isToast isLiveRegion aria-live="assertive">
61+
<AlertGroup hasAnimations isToast isLiveRegion aria-live="assertive">
6262
{alerts.map(({ title, variant, key }) => (
6363
<Alert
6464
variant={AlertVariant[variant]}

packages/react-core/src/components/Alert/examples/AlertGroupMultipleDynamic.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const AlertGroupMultipleDynamic: React.FunctionComponent = () => {
4242
</button>
4343
</InputGroupItem>
4444
</InputGroup>
45-
<AlertGroup isToast isLiveRegion>
45+
<AlertGroup hasAnimations isToast isLiveRegion>
4646
{alerts.map(({ title, variant, key }) => (
4747
<Alert
4848
variant={AlertVariant[variant]}

packages/react-core/src/components/Alert/examples/AlertGroupSingularDynamic.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export const AlertGroupSingularDynamic: React.FunctionComponent = () => {
5656
</button>
5757
</InputGroupItem>
5858
</InputGroup>
59-
<AlertGroup isLiveRegion>
59+
<AlertGroup hasAnimations isLiveRegion>
6060
{alerts.map(({ title, variant, key }) => (
6161
<Alert
6262
isInline

packages/react-core/src/components/Alert/examples/AlertGroupSingularDynamicOverflow.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ export const AlertGroupSingularDynamicOverflow: React.FunctionComponent = () =>
7575
</button>
7676
</InputGroupItem>
7777
</InputGroup>
78-
<AlertGroup isLiveRegion onOverflowClick={onOverflowClick} overflowMessage={overflowMessage}>
78+
<AlertGroup hasAnimations isLiveRegion onOverflowClick={onOverflowClick} overflowMessage={overflowMessage}>
7979
{alerts.slice(0, maxDisplayed).map(({ key, variant, title }) => (
8080
<Alert
8181
isInline

packages/react-core/src/components/Alert/examples/AlertGroupToast.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export const AlertGroupToast: React.FunctionComponent = () => {
5656
</button>
5757
</InputGroupItem>
5858
</InputGroup>
59-
<AlertGroup isToast isLiveRegion>
59+
<AlertGroup hasAnimations isToast isLiveRegion>
6060
{alerts.map(({ key, variant, title }) => (
6161
<Alert
6262
variant={AlertVariant[variant]}

packages/react-core/src/components/Alert/examples/AlertGroupToastOverflowCapture.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,13 @@ export const AlertGroupToastOverflowCapture: React.FunctionComponent = () => {
7575
</button>
7676
</InputGroupItem>
7777
</InputGroup>
78-
<AlertGroup isToast isLiveRegion onOverflowClick={onOverflowClick} overflowMessage={overflowMessage}>
78+
<AlertGroup
79+
hasAnimations
80+
isToast
81+
isLiveRegion
82+
onOverflowClick={onOverflowClick}
83+
overflowMessage={overflowMessage}
84+
>
7985
{alerts.slice(0, maxDisplayed).map(({ key, variant, title }) => (
8086
<Alert
8187
variant={AlertVariant[variant]}

packages/react-core/src/demos/examples/AlertGroup/AlertGroupToastWithNotificationDrawer.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,13 @@ export const AlertGroupToastWithNotificationDrawer: React.FunctionComponent = ()
365365
/>
366366
</PageSection>
367367
<PageSection>
368-
<AlertGroup isToast isLiveRegion onOverflowClick={onAlertGroupOverflowClick} overflowMessage={overflowMessage}>
368+
<AlertGroup
369+
hasAnimations
370+
isToast
371+
isLiveRegion
372+
onOverflowClick={onAlertGroupOverflowClick}
373+
overflowMessage={overflowMessage}
374+
>
369375
{alerts.slice(0, maxDisplayed)}
370376
</AlertGroup>
371377
</PageSection>

0 commit comments

Comments
 (0)