@cagov/ds-page-alert
v2.0.3
Published
The page alert gives people important and sometimes time-sensitive information that they need to read, before anything else. It goes beneath the site navigation on any page.
Downloads
245
Keywords
Readme
Page alert
The page alert gives people important and sometimes time-sensitive information that they need to read, before anything else. It goes beneath the site navigation on any page.
The page alert is a yellow band that extends across the width of the page. It includes:
- An icon, selected from a list of options
- A text field, which includes the ability to link to other pages
- A close icon (an X in a circle) that allows people to remove the alert
When and how to use it
Use page alerts sparingly. They alarm people and distract from other content.
Be concise with your page alert content. Use a link to send people to a page with the details.
Only use one page alert on a page. Make sure the alert is relevant to the page it is on. Only duplicate the alert on other pages if it applies to those pages.
Use page alerts to tell people about:
- Services that are down
- Open application periods
- Approaching deadlines
- Planned or unplanned maintenance
Choose an icon that supports the tone of your alert.
How not to use it
Do not put page alerts on every page on your site. If people see page alerts too often, they will start to ignore them and not read page alert content.
Do not put more than one page alert on a page.
Do not use page alerts to simply highlight important content. They are for information that is new, critical, and temporary.
Demo and sample markup
<cagov-page-alert
data-icon="ca-gov-icon-bell"
data-message='Notice: DCC is soliciting proposals for the Local Jurisdiction Assistance Grant Program. <a href="#">Learn more</a>.'
></cagov-page-alert>
Specs
| Property | Value | | ------------ | ---------------- | | Machine name | ds-page-alert | | JavaScript | yes | | SCSS | ./src/index.scss |
Project installation
The instructions assume familiarity with npm package management tool, modern JavaScript techniques, and Sass.
npm i @cagov/ds-page-alert
- Use
import
¹ orrequire
to include the component’s JavaScript in your page or compiler. - Add the sample markup to your HTML.
- Refer to the Content model section for notes on mapping your data to the sample markup.
CDN installation
We recommend using a build system and bundling your JavaScript for faster performance. If you do not use a build system, you can include the code from our CDN with a script tag.
<script type="module" src="https://cdn.designsystem.webstandards.ca.gov/components/ds-page-alert/v2.0.3/dist/index.js"></script>
CSS variables
The following CSS variables are used in this component:
--cagov-highlight
All CSS variables define their own fallback value so you do not have to use additional CSS unless you want to change them. You may define your own value for the variable by adding your own style rules. Here is an example defining the global hex value for a CSS variable named “--primary-700”:
:root {
--primary-700: #165ac2;
}
Other dependencies
This component uses icons from the CAGov font library. Include the font library in your project to ensure the icons appear.
Accessibility
Component-specific accessibility review
- If you are using svg icon at the beginning of the page alert text make sure it has
aria-hidden=”true”
attribute, so screen readers ignore it. - Make sure that close button has
aria-label="Close page alert”
so screen reader users would understand the purpose of the button. - When page alert is dismissed make sure that button has
aria-hidden=”true”
attribute, so the users would not tab to it. - Make sure that page alert links and buttons have solid, 2px outline that uses
--accent2-500
variable on focused state.
Standard accessibility review
As a component in Alpha status, this component must pass the following accessibility reviews every time a new version is published:
- Tested with the axe accessibility tool and passes all automated WCAG Level AA checks
- Reviewed with the VoiceOver screen reader on desktop
- Verified keyboard navigation and that all actionable elements of the component are reachable via keyboard commands only
- Reviewed component layout on a variety of screen sizes
Progressive enhancement
This component uses a custom element defined in JavaScript in addition to HTML and CSS. Edge, Firefox, Safari, and Chrome support custom elements. If the JavaScript for this component is not delivered or supported, the component will not display. This is the desired behavior because this component is not critical for site interaction. It uses CSS variables to inherit design token values. Token definitions are not required because these style rules provide fallback values.
Content model
This component uses the following data attributes. We provide this information to help with integrating the component into backend publishing systems or identifying content that may require translation.
| Name | Attribute name | Data type | Field type | | ------- | -------------- | --------- | ------------------------------------------ | | Icon | data-icon | string | Plain text, Any CaGov font, by class name. | | Message | data-message | string | Rich text |