Skip to content

Commit 01d7775

Browse files
author
Eric Olkowski
committed
chore(Alert): updated examples to enable animations
1 parent 06f0914 commit 01d7775

File tree

10 files changed

+35
-21
lines changed

10 files changed

+35
-21
lines changed

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

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,21 @@ 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`, which can be seen on all examples and demos where alerts are dynamically added. By default this is opt-in, as enabling animations may require updates to tests. You can pass the `hasAnimations` property to enable or disable the animations as needed. Additionally, with these 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+
1820
## Alert examples
1921

2022
### Alert variants
2123

2224
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".
2325

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 |
26+
| Variant | Description |
27+
| ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
28+
| 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. |
29+
| Info | Use for general informational messages |
30+
| Success | Use to indicate that a task or process has been completed successfully |
31+
| Warning | Use to indicate that a non-critical error has occurred |
32+
| Danger | Use to indicate that a critical or blocking error has occurred |
3133

3234
```ts
3335
import { Fragment } from 'react';
@@ -148,7 +150,7 @@ const AlertTimeout: React.FunctionComponent = () => {
148150
<Button variant="secondary" onClick={() => setAlerts([])}>
149151
Remove all alerts
150152
</Button>
151-
<AlertGroup isLiveRegion>{alerts}</AlertGroup>
153+
<AlertGroup hasAnimations isLiveRegion>{alerts}</AlertGroup>
152154
</Fragment>
153155
);
154156
};
@@ -405,11 +407,11 @@ An alert group stacks and positions 2 or more alerts in a live region, either in
405407
406408
Alert groups can be one of the following variants:
407409
408-
| Variant | Description |
409-
| --- | --- |
410+
| Variant | Description |
411+
| ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
410412
| 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.|
413+
| 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. |
414+
| Dynamic | Dynamic alert groups contain alerts that typically appear in response to a user action, and are seen within the normal page content flow. |
413415
414416
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.
415417

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)