This repository has been archived by the owner on May 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 166
[terra-alert] Update notification banner documentation #3933
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,7 +13,7 @@ import CustomExample from './example/CustomExample?dev-site-example'; | |
import LongTextExample from './example/LongTextExample?dev-site-example'; | ||
import ActionExample from './example/ActionExample?dev-site-example'; | ||
import DismissibleExample from './example/DismissibleExample?dev-site-example'; | ||
import ActionAndDismissibleExample from './example/ActionAndDismissibleExample?dev-site-example'; | ||
import LiveRegionsExampleCode from './example/LiveRegionsExampleCode'; | ||
|
||
import AlertPropsTable from 'terra-alert/lib/Alert?dev-site-props-table'; | ||
|
||
|
@@ -73,40 +73,18 @@ For further guidance, please view the full [Accessibility Guide](./accessibility | |
<Notice variant="important" ariaLevel="3"> | ||
|
||
- The `alert` notification type will seize keyboard focus by default when an action element is present. This behavior should only be used when absolutely necessary to interrupt the user's workflow. | ||
- Custom notification banners should always have a title provided to the `title` prop. | ||
|
||
</Notice> | ||
|
||
#### Accessibility Guidance: Titles | ||
- Notification banners of type `custom` should always have a title provided to the `title` prop. | ||
- All other notification types will provide a default title. The `title` prop will override the default title and should be avoided. | ||
|
||
#### Accessibility Guidance: Live regions | ||
- For less critical notifications (non-alerts), the notification banner should be in an `aria-live="polite"` region. See example code below. | ||
- Avoid mixing critical alert notifications and less critical notifications in the same region. | ||
|
||
<div aria-label="Example code"> | ||
|
||
import Alert from 'terra-alert'; | ||
|
||
<> | ||
// This less critical notification should be in polite aria-live region so screen reader users are notified. | ||
<div aria-live="polite"> | ||
{isOpen && ( | ||
<Alert type="success"> | ||
This notification is a less critical and should be polite. | ||
</Alert> | ||
)} | ||
</div> | ||
|
||
// Alert notifications are implicitly assertive, no aria-live needed | ||
// It is recommended to keep these separate from polite aria-live regions. | ||
<div> | ||
{isOpen && ( | ||
<Alert type="alert"> | ||
This notification is a critical alert that is interruptive. | ||
</Alert> | ||
)} | ||
</div> | ||
</> | ||
|
||
</div> | ||
<LiveRegionsExampleCode /> | ||
|
||
## Component Features | ||
* [Cross-Browser Support](https://engineering.cerner.com/terra-ui/about/terra-ui/component-standards#cross-browser-support) | ||
|
@@ -125,10 +103,9 @@ For further guidance, please view the full [Accessibility Guide](./accessibility | |
<InfoExample title="Information Notification Banner" /> | ||
<SuccessExample title="Success Notification Banner" /> | ||
<CustomExample title="Custom Notification Banner" /> | ||
<LongTextExample title="Long Text Notification Banner" /> | ||
<ActionExample title="Notification Banner with Action" /> | ||
<DismissibleExample title="Dismissible Notification Banner" /> | ||
<ActionAndDismissibleExample title="Dismissible Notification Banner with Actions" /> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed this since it was a bad example of a custom notification without title and there are already examples of notification with action and dismiss |
||
<LongTextExample title="Long Text Notification Banner" /> | ||
|
||
## Alert Props | ||
<AlertPropsTable /> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 0 additions & 51 deletions
51
...ages/terra-core-docs/src/terra-dev-site/doc/alert/example/ActionAndDismissibleExample.jsx
This file was deleted.
Oops, something went wrong.
19 changes: 12 additions & 7 deletions
19
packages/terra-core-docs/src/terra-dev-site/doc/alert/example/ActionExample.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
packages/terra-core-docs/src/terra-dev-site/doc/alert/example/AdvisoryExample.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
import React from 'react'; | ||
|
||
import Alert from 'terra-alert'; | ||
|
||
const AdvisoryExample = () => ( | ||
<Alert type="advisory">This is an advisory notification banner</Alert> | ||
<Alert type="advisory">This item is typically not used.</Alert> | ||
); | ||
|
||
export default AdvisoryExample; |
3 changes: 2 additions & 1 deletion
3
packages/terra-core-docs/src/terra-dev-site/doc/alert/example/AlertActionFocusDemo.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
packages/terra-core-docs/src/terra-dev-site/doc/alert/example/AlertExample.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
import React from 'react'; | ||
|
||
import Alert from 'terra-alert'; | ||
|
||
const AlertExample = () => ( | ||
<Alert type="alert">This is an alert notification banner</Alert> | ||
<Alert type="alert">Site is down for maintenance.</Alert> | ||
); | ||
|
||
export default AlertExample; |
17 changes: 9 additions & 8 deletions
17
packages/terra-core-docs/src/terra-dev-site/doc/alert/example/CustomExample.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
packages/terra-core-docs/src/terra-dev-site/doc/alert/example/CustomExampleNoTitle.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
packages/terra-core-docs/src/terra-dev-site/doc/alert/example/DismissibleExample.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
packages/terra-core-docs/src/terra-dev-site/doc/alert/example/ErrorExample.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
import React from 'react'; | ||
|
||
import Alert from 'terra-alert'; | ||
|
||
const ErrorExample = () => ( | ||
<Alert type="error">This is an error notification banner</Alert> | ||
<Alert type="error">Unable to save at this time. Please try again later.</Alert> | ||
); | ||
|
||
export default ErrorExample; |
3 changes: 2 additions & 1 deletion
3
packages/terra-core-docs/src/terra-dev-site/doc/alert/example/InfoExample.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
import React from 'react'; | ||
|
||
import Alert from 'terra-alert'; | ||
|
||
const InfoExample = () => ( | ||
<Alert type="info">This is an information notification banner</Alert> | ||
<Alert type="info">This receipt is for a bill-only purchase order.</Alert> | ||
); | ||
|
||
export default InfoExample; |
41 changes: 41 additions & 0 deletions
41
packages/terra-core-docs/src/terra-dev-site/doc/alert/example/LiveRegionsExampleCode.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React from 'react'; | ||
|
||
import ToggleButton from 'terra-toggle-button'; | ||
|
||
const LiveRegionsExampleCode = () => { | ||
const temp = ` | ||
import Alert from 'terra-alert'; | ||
|
||
<> | ||
// This less critical notification should be in polite aria-live region so screen reader users are notified. | ||
<div aria-live="polite"> | ||
{isOpen && ( | ||
<Alert type="success"> | ||
This notification is a less critical and should be polite. | ||
</Alert> | ||
)} | ||
</div> | ||
|
||
// Alert notifications are implicitly assertive, no aria-live needed | ||
// It is recommended to keep these separate from polite aria-live regions. | ||
<div> | ||
{isOpen && ( | ||
<Alert type="alert"> | ||
This notification is a critical alert that is interruptive. | ||
</Alert> | ||
)} | ||
</div> | ||
</> | ||
`; | ||
|
||
return ( | ||
<ToggleButton | ||
closedButtonText="Show live region example code" | ||
openedButtonText="Hide live region example code" | ||
> | ||
<pre>{temp}</pre> | ||
</ToggleButton> | ||
); | ||
}; | ||
|
||
export default LiveRegionsExampleCode; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
packages/terra-core-docs/src/terra-dev-site/doc/alert/example/SuccessExample.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
import React from 'react'; | ||
|
||
import Alert from 'terra-alert'; | ||
|
||
const SuccessExample = () => ( | ||
<Alert type="success">This is a success notification banner</Alert> | ||
<Alert type="success">Changes successfully committed.</Alert> | ||
); | ||
|
||
export default SuccessExample; |
3 changes: 2 additions & 1 deletion
3
packages/terra-core-docs/src/terra-dev-site/doc/alert/example/UnsatisfiedExample.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
import React from 'react'; | ||
|
||
import Alert from 'terra-alert'; | ||
|
||
const Example = () => ( | ||
<Alert type="unsatisfied">This is an unsatisfied notification banner</Alert> | ||
<Alert type="unsatisfied">Only one package must be selected.</Alert> | ||
); | ||
|
||
export default Example; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated to toggle button to show example code rather than leaving code on page by default