@brightspace-ui/core 2.143.1 → 2.144.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.
@@ -139,6 +139,24 @@ To make your `d2l-button-icon` accessible, use the following properties when app
139
139
  | `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. |
140
140
  | `description` | Use when text on button does not provide enough context. |
141
141
 
142
+ ### Icon Button with Custom Icon
143
+
144
+ <!-- docs: demo code -->
145
+ ```html
146
+ <script type="module">
147
+ import '@brightspace-ui/core/components/button/button-icon.js';
148
+ import '@brightspace-ui/core/components/icons/icon-custom.js';
149
+ </script>
150
+ <d2l-button-icon text="Custom Icon Button">
151
+ <d2l-icon-custom slot="icon">
152
+ <svg xmlns="http://www.w3.org/2000/svg" mirror-in-rtl="true">
153
+ <path fill="#494c4e" d="M18 12v5a1 1 0 0 1-1 1H1a1 1 0 0 1-1-1v-5a1 1 0 0 1 2 0v4h14v-4a1 1 0 0 1 2 0z"/>
154
+ <path fill="#494c4e" d="M13.85 3.15l-2.99-3A.507.507 0 0 0 10.5 0H5.4A1.417 1.417 0 0 0 4 1.43v11.14A1.417 1.417 0 0 0 5.4 14h7.2a1.417 1.417 0 0 0 1.4-1.43V3.5a.47.47 0 0 0-.15-.35zM7 2h1a1 1 0 0 1 0 2H7a1 1 0 0 1 0-2zm4 10H7a1 1 0 0 1 0-2h4a1 1 0 0 1 0 2zm0-4H7a1 1 0 0 1 0-2h4a1 1 0 0 1 0 2z"/>
155
+ </svg>
156
+ </d2l-icon-custom>
157
+ </d2l-button-icon>
158
+ ```
159
+
142
160
  ## Floating Buttons [d2l-floating-buttons]
143
161
 
144
162
  See [floating buttons](https://github.com/BrightspaceUI/core/tree/main/components/button/floating-buttons.md).
@@ -1,7 +1,7 @@
1
1
  import '../colors/colors.js';
2
2
  import '../icons/icon.js';
3
3
  import '../tooltip/tooltip.js';
4
- import { css, html, LitElement, unsafeCSS } from 'lit';
4
+ import { css, html, LitElement, nothing, unsafeCSS } from 'lit';
5
5
  import { VisibleOnAncestorMixin, visibleOnAncestorStyles } from '../../mixins/visible-on-ancestor/visible-on-ancestor-mixin.js';
6
6
  import { ButtonMixin } from './button-mixin.js';
7
7
  import { buttonStyles } from './button-styles.js';
@@ -13,6 +13,7 @@ import { ThemeMixin } from '../../mixins/theme/theme-mixin.js';
13
13
 
14
14
  /**
15
15
  * A button component that can be used just like the native button for instances where only an icon is displayed.
16
+ * @slot icon - Optional slot for a custom icon
16
17
  */
17
18
  class ButtonIcon extends ThemeMixin(ButtonMixin(VisibleOnAncestorMixin(RtlMixin(LitElement)))) {
18
19
 
@@ -117,7 +118,15 @@ class ButtonIcon extends ThemeMixin(ButtonMixin(VisibleOnAncestorMixin(RtlMixin(
117
118
  box-shadow: var(--d2l-button-icon-focus-box-shadow);
118
119
  }
119
120
 
120
- .d2l-button-icon {
121
+ slot[name="icon"]::slotted(*) {
122
+ display: none;
123
+ }
124
+ slot[name="icon"]::slotted(d2l-icon-custom) {
125
+ display: inline-flex;
126
+ }
127
+
128
+ d2l-icon,
129
+ slot[name="icon"]::slotted(d2l-icon-custom) {
121
130
  height: 0.9rem;
122
131
  width: 0.9rem;
123
132
  }
@@ -155,6 +164,7 @@ class ButtonIcon extends ThemeMixin(ButtonMixin(VisibleOnAncestorMixin(RtlMixin(
155
164
  }
156
165
 
157
166
  render() {
167
+ const icon = this.icon ? html`<d2l-icon icon="${this.icon}"></d2l-icon>` : nothing;
158
168
  return html`
159
169
  <button
160
170
  aria-describedby="${ifDefined(this.description ? this._describedById : undefined)}"
@@ -174,7 +184,7 @@ class ButtonIcon extends ThemeMixin(ButtonMixin(VisibleOnAncestorMixin(RtlMixin(
174
184
  name="${ifDefined(this.name)}"
175
185
  title="${ifDefined(this.text)}"
176
186
  type="${this._getType()}">
177
- <d2l-icon icon="${ifDefined(this.icon)}" class="d2l-button-icon"></d2l-icon>
187
+ <slot name="icon">${icon}</slot>
178
188
  </button>
179
189
  ${this.description ? html`<span id="${this._describedById}" hidden>${this.description}</span>` : null}
180
190
  ${this.disabled && this.disabledTooltip ? html`<d2l-tooltip for="${this._buttonId}">${this.disabledTooltip}</d2l-tooltip>` : ''}
@@ -6,6 +6,7 @@
6
6
  <link rel="stylesheet" href="../../demo/styles.css" type="text/css">
7
7
  <script type="module">
8
8
  import '../../demo/demo-page.js';
9
+ import '../../icons/icon-custom.js';
9
10
  import '../button-icon.js';
10
11
  </script>
11
12
  <style>
@@ -137,6 +138,21 @@
137
138
  <d2l-button-icon icon="tier1:search" text="Search" class="custom"></d2l-button-icon>
138
139
  </template>
139
140
  </d2l-demo-snippet>
141
+
142
+ <h2>Icon Button with Custom Icon</h2>
143
+
144
+ <d2l-demo-snippet>
145
+ <template>
146
+ <d2l-button-icon text="Custom Icon Button">
147
+ <d2l-icon-custom slot="icon">
148
+ <svg xmlns="http://www.w3.org/2000/svg" mirror-in-rtl="true">
149
+ <path fill="#494c4e" d="M18 12v5a1 1 0 0 1-1 1H1a1 1 0 0 1-1-1v-5a1 1 0 0 1 2 0v4h14v-4a1 1 0 0 1 2 0z"/>
150
+ <path fill="#494c4e" d="M13.85 3.15l-2.99-3A.507.507 0 0 0 10.5 0H5.4A1.417 1.417 0 0 0 4 1.43v11.14A1.417 1.417 0 0 0 5.4 14h7.2a1.417 1.417 0 0 0 1.4-1.43V3.5a.47.47 0 0 0-.15-.35zM7 2h1a1 1 0 0 1 0 2H7a1 1 0 0 1 0-2zm4 10H7a1 1 0 0 1 0-2h4a1 1 0 0 1 0 2zm0-4H7a1 1 0 0 1 0-2h4a1 1 0 0 1 0 2z"/>
151
+ </svg>
152
+ </d2l-icon-custom>
153
+ </d2l-button-icon>
154
+ </template>
155
+ </d2l-demo-snippet>
140
156
  </d2l-demo-page>
141
157
 
142
158
  <script>
@@ -436,6 +436,12 @@
436
436
  "type": "boolean",
437
437
  "default": "false"
438
438
  }
439
+ ],
440
+ "slots": [
441
+ {
442
+ "name": "icon",
443
+ "description": "Optional slot for a custom icon"
444
+ }
439
445
  ]
440
446
  },
441
447
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "2.143.1",
3
+ "version": "2.144.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",