@brightspace-ui/core 3.64.3 → 3.66.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,6 +2,7 @@ import { css, html, LitElement } from 'lit';
2
2
 
3
3
  /**
4
4
  * A button container component for button toggles.
5
+ * @fires click - Internal event
5
6
  */
6
7
  class ButtonToggle extends LitElement {
7
8
 
@@ -78,17 +79,28 @@ class ButtonToggle extends LitElement {
78
79
  elem.focus();
79
80
  }
80
81
 
82
+ _clickCancelled(e) {
83
+ e.stopPropagation();
84
+ const customClick = new CustomEvent('click', {
85
+ cancelable: true
86
+ });
87
+ e.target.dispatchEvent(customClick);
88
+ return customClick.defaultPrevented;
89
+ }
90
+
81
91
  async _handleClick(pressed) {
82
92
  this.pressed = pressed;
83
93
  await this.updateComplete;
84
94
  this.focus();
85
95
  }
86
96
 
87
- _handleNotPressedClick() {
97
+ _handleNotPressedClick(e) {
98
+ if (this._clickCancelled(e)) return;
88
99
  this._handleClick(true);
89
100
  }
90
101
 
91
- _handlePressedClick() {
102
+ _handlePressedClick(e) {
103
+ if (this._clickCancelled(e)) return;
92
104
  this._handleClick(false);
93
105
  }
94
106
 
@@ -54,6 +54,30 @@
54
54
  </template>
55
55
  </d2l-demo-snippet>
56
56
 
57
+ <h2>Toggle Button (consumer manages state)</h2>
58
+
59
+ <d2l-demo-snippet>
60
+ <template>
61
+ <d2l-button-toggle id="toggle-button-icon-consumer-manage-state">
62
+ <d2l-button-icon slot="not-pressed" icon="tier1:pin-hollow" text="Unpinned, click to pin." id="button-icon-not-pressed"></d2l-button-icon>
63
+ <d2l-button-icon slot="pressed" icon="tier1:pin-filled" text="Pinned, click to unpin." id="button-icon-pressed"></d2l-button-icon>
64
+ </d2l-button-toggle>
65
+ <script>
66
+ const buttonToggle = document.querySelector('#toggle-button-icon-consumer-manage-state');
67
+ buttonToggle.addEventListener('d2l-button-toggle-change', e => console.log(e));
68
+
69
+ document.querySelector('#button-icon-not-pressed').addEventListener('click', (e) => {
70
+ e.preventDefault();
71
+ buttonToggle.pressed = true;
72
+ });
73
+ document.querySelector('#button-icon-pressed').addEventListener('click', (e) => {
74
+ e.preventDefault();
75
+ buttonToggle.pressed = false;
76
+ });
77
+ </script>
78
+ </template>
79
+ </d2l-demo-snippet>
80
+
57
81
  </d2l-demo-page>
58
82
 
59
83
  </body>
@@ -47,8 +47,8 @@ Import and use the `<d2l-link>` web component instead of the native `<a>` elemen
47
47
 
48
48
  | Property | Type | Description |
49
49
  |--|--|--|
50
+ | `aria-label` | String | Label to provide more context for screen reader users when the link text is not enough |
50
51
  | `href` | String, required | URL or URL fragment of the link |
51
- | `aria-label` | String | Sets an accessible label |
52
52
  | `download` | Boolean | Download a URL instead of navigating to it |
53
53
  | `main` | Boolean | Whether to apply the "main" link style |
54
54
  | `lines` | Number | The number of lines to display before truncating text with an ellipsis. The text will not be truncated unless a value is specified. |
@@ -56,14 +56,6 @@ Import and use the `<d2l-link>` web component instead of the native `<a>` elemen
56
56
  | `target` | String | Where to display the linked URL |
57
57
  <!-- docs: end hidden content -->
58
58
 
59
- ### Accessibility Properties
60
-
61
- To make your usage of `d2l-link` accessible, use the following property when applicable:
62
-
63
- | Attribute | Description |
64
- |--|--|
65
- | `aria-label` | Use when text in link does not provide enough context. |
66
-
67
59
  ## Applying link styles to native anchor elements
68
60
 
69
61
  Alternately, you can apply link styles to a native `<a>` element by importing the styles and placing the `d2l-link` CSS class on the element.
@@ -91,3 +83,8 @@ Alternately, you can apply link styles to a native `<a>` element by importing th
91
83
  ```
92
84
 
93
85
  Add the `d2l-link-main` or `d2l-link-small` CSS classes to the `<a>` element to apply those styles.
86
+
87
+ ## Accessibility
88
+ - The `d2l-link` component follows the W3C's best practices for the [Link Pattern](https://www.w3.org/WAI/ARIA/apg/patterns/link/)
89
+ - When `target` is set to `_blank`, the `d2l-link` component follows [WCAG technique G201](https://www.w3.org/TR/WCAG20-TECHS/G201.html), and gives users an advanced warning that interacting with the link will open it in a new window
90
+ - While this is simply read out to screen reader users, it is also visually represented by the `new-window` icon
@@ -58,7 +58,7 @@ class Link extends LocalizeCoreElement(FocusMixin(LitElement)) {
58
58
  static get properties() {
59
59
  return {
60
60
  /**
61
- * Sets an accessible label
61
+ * ACCESSIBILITY: Label to provide more context for screen reader users when the link text is not enough
62
62
  * @type {string}
63
63
  */
64
64
  ariaLabel: { type: String, attribute: 'aria-label' },
@@ -739,6 +739,10 @@
739
739
  }
740
740
  ],
741
741
  "events": [
742
+ {
743
+ "name": "click",
744
+ "description": "Internal event"
745
+ },
742
746
  {
743
747
  "name": "d2l-button-toggle-change",
744
748
  "description": "Dispatched when the pressed state changes"
@@ -7806,7 +7810,7 @@
7806
7810
  "attributes": [
7807
7811
  {
7808
7812
  "name": "aria-label",
7809
- "description": "Sets an accessible label",
7813
+ "description": "ACCESSIBILITY: Label to provide more context for screen reader users when the link text is not enough",
7810
7814
  "type": "string"
7811
7815
  },
7812
7816
  {
@@ -7848,7 +7852,7 @@
7848
7852
  {
7849
7853
  "name": "ariaLabel",
7850
7854
  "attribute": "aria-label",
7851
- "description": "Sets an accessible label",
7855
+ "description": "ACCESSIBILITY: Label to provide more context for screen reader users when the link text is not enough",
7852
7856
  "type": "string"
7853
7857
  },
7854
7858
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "3.64.3",
3
+ "version": "3.66.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",