@brightspace-ui/core 1.238.0 → 1.239.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -51,7 +51,7 @@ The `d2l-button` element can be used just like the native button element, but al
51
51
 
52
52
  | Property | Type | Description |
53
53
  |--|--|--|
54
- | `description` | String | A description to be added to the `button` for accessibility |
54
+ | `description` | String | A description to be added to the `button` for accessibility for additional context |
55
55
  | `disabled` | Boolean | Disables the button |
56
56
  | `disabledTooltip` | String | Tooltip text when disabled |
57
57
  | `primary` | Boolean | Styles the button as a primary button |
@@ -130,6 +130,7 @@ The `d2l-button-icon` element can be used just like the native `button`, for ins
130
130
 
131
131
  | Property | Type | Description |
132
132
  |--|--|--|
133
+ | `description` | String | A description to be added to the `button` for accessibility for additional context |
133
134
  | `icon` | String, required | [Preset icon key](../../components/icons#preset-icons) (e.g. `tier1:gear`) |
134
135
  | `text` | String, required | Accessible text for the buton |
135
136
  | `disabled` | Boolean | Disables the button |
@@ -148,6 +149,7 @@ To make your `d2l-button-icon` accessible, use the following properties when app
148
149
  | `aria-expanded` | [Indicate expansion state of a collapsible element](https://www.w3.org/WAI/PF/aria/states_and_properties#aria-expanded). Example: [d2l-more-less](https://github.com/BrightspaceUI/core/blob/f9f30d0975ee5a8479263a84541fc3b781e8830f/components/more-less/more-less.js#L158). |
149
150
  | `aria-haspopup` | [Indicate clicking the button opens a menu](https://www.w3.org/WAI/PF/aria/states_and_properties#aria-haspopup). Example: [d2l-dropdown](https://github.com/BrightspaceUI/core/blob/main/components/dropdown/dropdown-opener-mixin.js#L46). |
150
151
  | `aria-label` | Acts as a primary label. If `text` AND `aria-label` are provided, `aria-label` is used as the primary label, `text` is used as the tooltip. |
152
+ | `description` | Use when text on button does not provide enough context. |
151
153
 
152
154
  ## Floating Buttons [d2l-floating-buttons]
153
155
 
@@ -17,6 +17,12 @@ class ButtonIcon extends ThemeMixin(ButtonMixin(VisibleOnAncestorMixin(RtlMixin(
17
17
 
18
18
  static get properties() {
19
19
  return {
20
+ /**
21
+ * A description to be added to the button for accessibility when text on button does not provide enough context
22
+ * @type {string}
23
+ */
24
+ description: { type: String },
25
+
20
26
  /**
21
27
  * Aligns the leading edge of text if value is set to "text"
22
28
  * @type {'text'|''}
@@ -146,11 +152,14 @@ class ButtonIcon extends ThemeMixin(ButtonMixin(VisibleOnAncestorMixin(RtlMixin(
146
152
 
147
153
  /** @internal */
148
154
  this._buttonId = getUniqueId();
155
+ /** @internal */
156
+ this._describedById = getUniqueId();
149
157
  }
150
158
 
151
159
  render() {
152
160
  return html`
153
161
  <button
162
+ aria-describedby="${ifDefined(this.description ? this._describedById : undefined)}"
154
163
  aria-disabled="${ifDefined(this.disabled && this.disabledTooltip ? 'true' : undefined)}"
155
164
  aria-expanded="${ifDefined(this.ariaExpanded)}"
156
165
  aria-haspopup="${ifDefined(this.ariaHaspopup)}"
@@ -170,6 +179,7 @@ class ButtonIcon extends ThemeMixin(ButtonMixin(VisibleOnAncestorMixin(RtlMixin(
170
179
  type="${this._getType()}">
171
180
  <d2l-icon icon="${ifDefined(this.icon)}" class="d2l-button-icon"></d2l-icon>
172
181
  </button>
182
+ ${this.description ? html`<span id="${this._describedById}" hidden>${this.description}</span>` : null}
173
183
  ${this.disabled && this.disabledTooltip ? html`<d2l-tooltip for="${this._buttonId}">${this.disabledTooltip}</d2l-tooltip>` : ''}
174
184
  `;
175
185
  }
@@ -155,6 +155,8 @@ class ButtonSubtle extends ButtonMixin(RtlMixin(LitElement)) {
155
155
 
156
156
  /** @internal */
157
157
  this._buttonId = getUniqueId();
158
+ /** @internal */
159
+ this._describedById = getUniqueId();
158
160
  }
159
161
 
160
162
  render() {
@@ -162,10 +164,11 @@ class ButtonSubtle extends ButtonMixin(RtlMixin(LitElement)) {
162
164
  html`<d2l-icon icon="${this.icon}" class="d2l-button-subtle-icon"></d2l-icon>` : '';
163
165
  return html`
164
166
  <button
167
+ aria-describedby="${ifDefined(this.description ? this._describedById : undefined)}"
165
168
  aria-disabled="${ifDefined(this.disabled && this.disabledTooltip ? 'true' : undefined)}"
166
169
  aria-expanded="${ifDefined(this.ariaExpanded)}"
167
170
  aria-haspopup="${ifDefined(this.ariaHaspopup)}"
168
- aria-label="${ifDefined(this.description || this.ariaLabel)}"
171
+ aria-label="${ifDefined(this.ariaLabel)}"
169
172
  ?autofocus="${this.autofocus}"
170
173
  class="d2l-label-text"
171
174
  ?disabled="${this.disabled && !this.disabledTooltip}"
@@ -182,6 +185,7 @@ class ButtonSubtle extends ButtonMixin(RtlMixin(LitElement)) {
182
185
  <span class="d2l-button-subtle-content">${this.text}</span>
183
186
  <slot></slot>
184
187
  </button>
188
+ ${this.description ? html`<span id="${this._describedById}" hidden>${this.description}</span>` : null}
185
189
  ${this.disabled && this.disabledTooltip ? html`<d2l-tooltip for="${this._buttonId}">${this.disabledTooltip}</d2l-tooltip>` : ''}
186
190
  `;
187
191
  }
@@ -90,15 +90,18 @@ class Button extends ButtonMixin(LitElement) {
90
90
 
91
91
  /** @internal */
92
92
  this._buttonId = getUniqueId();
93
+ /** @internal */
94
+ this._describedById = getUniqueId();
93
95
  }
94
96
 
95
97
  render() {
96
98
  return html`
97
99
  <button
100
+ aria-describedby="${ifDefined(this.description ? this._describedById : undefined)}"
98
101
  aria-disabled="${ifDefined(this.disabled && this.disabledTooltip ? 'true' : undefined)}"
99
102
  aria-expanded="${ifDefined(this.ariaExpanded)}"
100
103
  aria-haspopup="${ifDefined(this.ariaHaspopup)}"
101
- aria-label="${ifDefined(this.description || this.ariaLabel)}"
104
+ aria-label="${ifDefined(this.ariaLabel)}"
102
105
  ?autofocus="${this.autofocus}"
103
106
  class="d2l-label-text"
104
107
  ?disabled="${this.disabled && !this.disabledTooltip}"
@@ -113,6 +116,7 @@ class Button extends ButtonMixin(LitElement) {
113
116
  type="${this._getType()}">
114
117
  <slot></slot>
115
118
  </button>
119
+ ${this.description ? html`<span id="${this._describedById}" hidden>${this.description}</span>` : null}
116
120
  ${this.disabled && this.disabledTooltip ? html`<d2l-tooltip for="${this._buttonId}">${this.disabledTooltip}</d2l-tooltip>` : ''}
117
121
  `;
118
122
  }
@@ -336,6 +336,11 @@
336
336
  "path": "./components/button/button-icon.js",
337
337
  "description": "A button component that can be used just like the native button for instances where only an icon is displayed.",
338
338
  "attributes": [
339
+ {
340
+ "name": "description",
341
+ "description": "A description to be added to the button for accessibility when text on button does not provide enough context",
342
+ "type": "string"
343
+ },
339
344
  {
340
345
  "name": "h-align",
341
346
  "description": "Aligns the leading edge of text if value is set to \"text\"",
@@ -370,6 +375,12 @@
370
375
  }
371
376
  ],
372
377
  "properties": [
378
+ {
379
+ "name": "description",
380
+ "attribute": "description",
381
+ "description": "A description to be added to the button for accessibility when text on button does not provide enough context",
382
+ "type": "string"
383
+ },
373
384
  {
374
385
  "name": "hAlign",
375
386
  "attribute": "h-align",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "1.238.0",
3
+ "version": "1.239.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",