@brightspace-ui/core 3.57.0 → 3.59.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -34,33 +34,31 @@ Alerts communicate critical information relating to the state of the system and
34
34
 
35
35
  <d2l-button id="open" style="align-self:center;display:none;">Show Alerts</d2l-button>
36
36
  <d2l-alert id="alert" type="default" button-text="Undo" has-close-button>
37
- An inline alert message.
37
+ Inline Alerts can be placed anywhere in the page content
38
38
  </d2l-alert>
39
39
  <d2l-alert-toast id="alert-toast" type="success" open no-auto-close>
40
- A toast alert message.
40
+ Toast Alerts appear at the botttom of the viewport
41
41
  </d2l-alert-toast>
42
42
  ```
43
43
 
44
44
  ## Inline Alert [d2l-alert]
45
45
 
46
- The `d2l-alert` component can be used to communicate important information relating to the state of the system and the user's work flow.
46
+ Use an inline alert if there is important information a user needs to know while performing a task; the alert remains visible until the user takes action or dismisses it.
47
47
 
48
48
  ### Best Practices
49
49
 
50
50
  <!-- docs: start best practices -->
51
51
  <!-- docs: start dos -->
52
- * Do use to let the user know when the system is in a state that will prevent them from completing their action
53
- * Do highlight information that requires the user’s attention and/or action.
54
- * Do provide a clear call to action if it can help resolve the alert
55
- * Do provide a control to dismiss the alert and prevent the message from displaying again, if applicable
56
- * Do use sentence case for alert text, but avoid unnecessary punctuation by not placing periods at the end of single sentences
52
+ * Use an alert to highlight information that requires the user’s action or attention
53
+ * Provide a clear call to action if it can help resolve the alert
54
+ * Use sentence case for alert text and avoid unnecessary punctuation by not placing periods at the end of single sentences
57
55
  <!-- docs: end dos -->
58
56
 
59
57
  <!-- docs: start donts -->
60
- * Dont use an inline alert in isolation for form validation errors – highlight fields with errors in red and ensure that the fields have error tooltips on focus & hover
61
- * Don't display more than one inline alert at a time
62
- * Don't display promotional material or information that is not related to the user’s key work flow
63
- * Don't display more than one paragraph of text in the alert
58
+ * Don't display more than one paragraph of text
59
+ * Avoid overusing them — the more commonly alerts appear, the less effective they will be
60
+ * Don't use them for promotional material or information that is not relevant to the user’s workflow
61
+ * Dont use them for validation errors instead, use the [Form](../../components/form) component for a consistent user experience
64
62
  <!-- docs: end donts -->
65
63
  <!-- docs: end best practices -->
66
64
 
@@ -71,7 +69,7 @@ The `d2l-alert` component can be used to communicate important information relat
71
69
  </script>
72
70
 
73
71
  <d2l-alert type="default" button-text="Undo">
74
- A message.
72
+ An inline alert message
75
73
  </d2l-alert>
76
74
  ```
77
75
  <!-- docs: start hidden content -->
@@ -92,20 +90,20 @@ The `d2l-alert` component can be used to communicate important information relat
92
90
 
93
91
  ## Toast Alert [d2l-alert-toast]
94
92
 
95
- The `d2l-alert-toast` component serves the same purpose as `d2l-alert`; however, it is displayed as
96
- a pop-up at the bottom of the screen that automatically dismisses itself by default.
93
+ Use a toast alert to provide feedback about an operation the user has just initiated when the result of that operation may not be apparent or obvious to the user. Toast alerts appear at the bottom of the viewport and disappear after 4 seconds by default.
94
+
97
95
  ### Best Practices
98
96
  <!-- docs: start best practices -->
99
97
  <!-- docs: start dos -->
100
- * Do make toasts dismissible via the close icon
101
- * Do keep text brief toasts shouldn’t spill onto more than one line at any screen size
102
- * Do use specific language “Assignment saved” is more informative than “Successfully saved”
98
+ * Use to convey results of a user's action when the result is not otherwise obvious
99
+ * Keep text brief toasts should rarely spill onto more than one line at any screen size
100
+ * Use specific language “Assignment saved” is more informative than “Successfully saved”
103
101
  <!-- docs: end dos -->
104
102
  <!-- docs: start donts -->
105
- * Avoid displaying multiple toast alerts - see [Multiple Toast Alerts](#multiple-toast-alerts)
106
- * Don't allow the close button to be blocked by other elements, the user doesn’t want to have to wait for it to go way on it’s own
107
- * Don’t use toasts to provide instructions. Change blindness and transience make them ineffective for these use cases
108
- * Don’t use the thumbnails or two-line variety of inline alert as a toast. Toasts should be super brief!
103
+ * If possible, avoid displaying multiple toasts see [Multiple Toast Alerts](#multiple-toast-alerts)
104
+ * Don't allow the close button to be blocked by other elements; users shouldn't have to wait for the toast alert to go away on its own
105
+ * Don’t use for instructions or critical information since toast alerts disappear and can be easily missed or ignored use an [Inline Alert](#d2l-alert) instead
106
+ * Avoid having two lines with `subtext` toasts should be very brief
109
107
  <!-- docs: end donts -->
110
108
  <!-- docs: end best practices -->
111
109
 
@@ -133,7 +131,7 @@ a pop-up at the bottom of the screen that automatically dismisses itself by defa
133
131
  <d2l-button id="open" style="align-self:center;display:none;">Show Alert</d2l-button>
134
132
  <!-- docs: end hidden content -->
135
133
  <d2l-alert-toast type="default" no-auto-close open>
136
- A default toast alert.
134
+ A default toast alert
137
135
  </d2l-alert-toast>
138
136
  ```
139
137
 
@@ -155,7 +153,7 @@ a pop-up at the bottom of the screen that automatically dismisses itself by defa
155
153
 
156
154
  ### Multiple Toast Alerts
157
155
 
158
- Displaying more than one toast message at a time should be avoided unless absolutely necessary, since they usually disappear after 4 seconds and can be difficult to read for some users. It's often better to use an [inline alert](#d2l-alert) so that users have time to discover and read the message.
156
+ Avoid displaying more than one toast message at a time unless absolutely necessary, since they disappear after 4 seconds and can be difficult to read for some users. It's often better to use an [inline alert](#d2l-alert) so that users have time to discover and read the message.
159
157
 
160
158
  For cases where multiple toast alerts are unavoidable, new toast messages will appear at the bottom and push older messages upward.
161
159
 
@@ -189,3 +187,9 @@ For cases where multiple toast alerts are unavoidable, new toast messages will a
189
187
  Third toast alert
190
188
  </d2l-alert-toast>
191
189
  ```
190
+
191
+ ## Accessibility
192
+
193
+ [Inline Alerts](#d2l-alert) are meant to draw attention without interrupting the user's flow, so they do not use the ARIA `alert` role. This means screen reader users do not hear them until encountering them in the content (as intended).
194
+
195
+ [Toast Alerts](#d2l-alert-toast) leverage the ARIA `alert` role in alignment with the [W3C Alert Pattern](https://www.w3.org/WAI/ARIA/apg/patterns/alert/), so an assertive live region is created which causes the content of the alert to be announced immediately. This can interrupt the user, so it should be used sparingly as per our [Best Practices](#best-practices-1).
@@ -50,58 +50,81 @@ Toggling progressive disclosure is OK
50
50
 
51
51
  Native `<select>` elements can be styled by importing `input-select-styles.js` into your LitElement and applying the `d2l-input-select` CSS class.
52
52
 
53
- Note: in order for RTL to function correctly, make sure your component uses the `RtlMixin`.
53
+ The styles support the pseudo-classes `disabled`, `focus`, and `hover`, as well as the `aria-invalid` attribute.
54
54
 
55
- <!-- docs: demo code properties name:d2l-test-input-select -->
55
+ When applying styles to the native element, we also recommend using the [`SkeletonMixin`](https://github.com/BrightspaceUI/core/tree/main/components/skeleton) to help convey to users that the page, or at least a section of it, has not finished loading yet.
56
+
57
+ <!-- docs: demo code -->
56
58
  ```html
57
59
  <script type="module">
58
- import { css, html, LitElement } from 'lit';
59
- import { RtlMixin } from '@brightspace-ui/core/mixins/rtl/rtl-mixin.js';
60
+ import { html, LitElement } from 'lit';
60
61
  import { selectStyles } from '@brightspace-ui/core/components/inputs/input-select-styles.js';
61
62
  import { SkeletonMixin } from '@brightspace-ui/core/components/skeleton/skeleton-mixin.js';
62
63
 
63
- class TestInputSelect extends SkeletonMixin(RtlMixin(LitElement)) {
64
-
65
- static get properties() {
66
- return {
67
- disabled: { type: Boolean },
68
- invalid: { type: Boolean },
69
- overflow: { type: Boolean }
70
- };
71
- }
72
-
73
- static get styles() {
74
- return [super.styles, selectStyles,
75
- css`
76
- :host {
77
- display: inline-block;
78
- }
79
- :host([overflow]) select {
80
- max-width: 130px;
81
- }
82
- `
83
- ];
84
- }
85
-
86
- render() {
87
- const invalid = this.invalid ? 'true' : 'false';
88
- return html`
89
- <div class="d2l-skeletize">
90
- <select
91
- aria-label="Choose a dinosaur:"
92
- aria-invalid="${invalid}"
93
- class="d2l-input-select"
94
- ?disabled="${this.disabled}">
95
- <option>Tyrannosaurus</option>
96
- <option>Velociraptor</option>
97
- <option>Deinonychus</option>
98
- </select>
99
- </div>
100
- `;
101
- }
64
+ class TestInputSelect extends SkeletonMixin(LitElement) {
65
+ static get styles() {
66
+ return [ super.styles, selectStyles ];
67
+ }
68
+
69
+ render() {
70
+ return html`
71
+ <div class="d2l-skeletize">
72
+ <select
73
+ aria-label="Choose a dinosaur:"
74
+ class="d2l-input-select">
75
+ <option>Tyrannosaurus</option>
76
+ <option>Velociraptor</option>
77
+ <option>Deinonychus</option>
78
+ </select>
79
+ </div>
80
+ `;
81
+ }
102
82
 
103
83
  }
104
84
  customElements.define('d2l-test-input-select', TestInputSelect);
105
85
  </script>
106
86
  <d2l-test-input-select></d2l-test-input-select>
107
87
  ```
88
+
89
+ ### Invalid
90
+
91
+ Use the [`aria-invalid`](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-invalid) attribute to support screenreader users and apply our consistent error styles.
92
+
93
+ <!-- docs: demo -->
94
+ ```html
95
+ <script type="module">
96
+ import { html, LitElement } from 'lit';
97
+ import { selectStyles } from '@brightspace-ui/core/components/inputs/input-select-styles.js';
98
+
99
+ class TestInputSelect extends LitElement {
100
+
101
+ static get styles() {
102
+ return [ selectStyles ];
103
+ }
104
+
105
+ render() {
106
+ return html`
107
+ <select
108
+ aria-label="Choose a dinosaur:"
109
+ aria-invalid="true"
110
+ class="d2l-input-select">
111
+ <option>Tyrannosaurus</option>
112
+ <option>Velociraptor</option>
113
+ <option>Deinonychus</option>
114
+ </select>
115
+ `;
116
+ }
117
+
118
+ }
119
+ customElements.define('d2l-test-input-select', TestInputSelect);
120
+ </script>
121
+ <d2l-test-input-select></d2l-test-input-select>
122
+ ```
123
+
124
+ ## Accessibility
125
+
126
+ - Due to applying styles based on a CSS class rather than being its own component, the accessibility provided by `selectStyles` comes purely in the way of following the guidelines for [contrast](https://www.w3.org/WAI/WCAG21/Understanding/contrast-minimum.html) and [focus](https://www.w3.org/WAI/WCAG21/Understanding/focus-visible.html)
127
+ - There are several things that can be done to make sure your `select` component is accessible, including:
128
+ - Following the W3C [Combobox](https://www.w3.org/WAI/ARIA/apg/patterns/combobox/) pattern
129
+ - Using either the `aria-label` or `aria-labelledby` to appropriately assign a label to your component
130
+ - Using `label` for `optgroup` if you choose to use that element within the select element, so that it can be read out to screenreaders
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "3.57.0",
3
+ "version": "3.59.0",
4
4
  "description": "A collection of accessible, free, open-source web components for building Brightspace applications",
5
5
  "type": "module",
6
6
  "repository": "https://github.com/BrightspaceUI/core.git",