@brightspace-ui/core 3.333.6 → 3.334.1

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.
@@ -436,11 +436,10 @@ class Filter extends FocusMixin(LocalizeCoreElement(LitElement)) {
436
436
  }
437
437
  return this._dimensions.map((dimension) => {
438
438
  const builtDimension = this._buildDimension(dimension);
439
- const countBadgeId = `filters-applied-count-${dimension.key}`;
440
439
  const filtersAppliedText = `${this.localize('components.filter.filterCountDescription', { number: dimension.appliedCount })}`;
441
- return html`<d2l-menu-item text="${dimension.text}" description="${dimension.text}." aria-describedby="${countBadgeId}">
440
+ return html`<d2l-menu-item text="${dimension.text}" description="${dimension.text}. ${filtersAppliedText}">
442
441
  <div slot="supporting">
443
- <d2l-count-badge id="${countBadgeId}" number="${dimension.appliedCount}" max-digits="2" text="${filtersAppliedText}" hide-zero></d2l-count-badge>
442
+ <d2l-count-badge number="${dimension.appliedCount}" max-digits="2" text="${filtersAppliedText}" hide-zero></d2l-count-badge>
444
443
  </div>
445
444
  ${builtDimension}
446
445
  </d2l-menu-item>`;
@@ -45,6 +45,8 @@ A segmented component to switch between views. Use a view switcher to change bet
45
45
  |---|---|---|
46
46
  |`key` | String, required | Key for the button. |
47
47
  |`text`| String, required | Text for the button. |
48
+ |`text-hidden`| Boolean, default: `false` | Hides the text visually. Will reset to false unless an icon is set |
49
+ | `icon` | String | [Preset icon key](../../components/icons#preset-icons) (e.g. `tier1:gear`) |
48
50
  |`selected`| Boolean, default: `false` | Indicates if the item is selected. |
49
51
 
50
52
  ### Events
@@ -1,16 +1,20 @@
1
1
  import '../colors/colors.js';
2
- import { css, html, LitElement, unsafeCSS } from 'lit';
2
+ import { css, html, LitElement, nothing, unsafeCSS } from 'lit';
3
3
  import { buttonStyles } from '../button/button-styles.js';
4
4
  import { FocusMixin } from '../../mixins/focus/focus-mixin.js';
5
5
  import { getFocusPseudoClass } from '../../helpers/focus.js';
6
+ import { ifDefined } from 'lit/directives/if-defined.js';
6
7
  import { labelStyles } from '../typography/styles.js';
7
8
  import { PropertyRequiredMixin } from '../../mixins/property-required/property-required-mixin.js';
9
+ import { SlottedIconMixin } from '../icons/slotted-icon-mixin.js';
10
+ import { styleMap } from 'lit/directives/style-map.js';
8
11
 
9
12
  /**
10
13
  * A button component to be used in d2l-view-switcher.
11
14
  * @fires d2l-view-switcher-select - Dispatched when the item is selected
15
+ * @slot icon - Optional slot for a custom icon
12
16
  */
13
- class ViewSwitcherButton extends PropertyRequiredMixin(FocusMixin(LitElement)) {
17
+ class ViewSwitcherButton extends PropertyRequiredMixin(FocusMixin(SlottedIconMixin(LitElement))) {
14
18
 
15
19
  static properties = {
16
20
  /**
@@ -28,6 +32,11 @@ class ViewSwitcherButton extends PropertyRequiredMixin(FocusMixin(LitElement)) {
28
32
  * @type {boolean}
29
33
  */
30
34
  selected: { type: Boolean, reflect: true },
35
+ /**
36
+ * Hides the text visually
37
+ * @type {boolean}
38
+ */
39
+ textHidden: { type: Boolean, attribute: 'text-hidden' }
31
40
  };
32
41
 
33
42
  static styles = [labelStyles, buttonStyles, css`
@@ -39,7 +48,8 @@ class ViewSwitcherButton extends PropertyRequiredMixin(FocusMixin(LitElement)) {
39
48
  button {
40
49
  background-color: transparent;
41
50
  border-radius: 0.2rem;
42
- display: block;
51
+ column-gap: 0.3rem;
52
+ display: inline-flex;
43
53
  font-family: inherit;
44
54
  min-height: auto;
45
55
  padding-block: 0.3rem;
@@ -58,11 +68,16 @@ class ViewSwitcherButton extends PropertyRequiredMixin(FocusMixin(LitElement)) {
58
68
  background-color: var(--d2l-color-tungsten);
59
69
  color: #ffffff;
60
70
  }
71
+ :host([selected]) d2l-icon,
72
+ :host([selected]) ::slotted(d2l-icon-custom) {
73
+ color: #ffffff;
74
+ }
61
75
  `];
62
76
 
63
77
  constructor() {
64
78
  super();
65
79
  this.selected = false;
80
+ this.textHidden = false;
66
81
  }
67
82
 
68
83
  static get focusElementSelector() {
@@ -70,13 +85,21 @@ class ViewSwitcherButton extends PropertyRequiredMixin(FocusMixin(LitElement)) {
70
85
  }
71
86
 
72
87
  render() {
88
+ const hideText = this.textHidden && this.hasIcon();
89
+ const label = hideText ? this.text : undefined;
90
+ const iconPaddingOverride = {
91
+ paddingInline: hideText ? '0.3rem' : (this.hasIcon() ? '0.6rem' : undefined)
92
+ };
73
93
  return html`
74
94
  <button
95
+ aria-label="${ifDefined(label)}"
75
96
  aria-pressed="${this.selected ? 'true' : 'false'}"
76
97
  class="d2l-label-text"
77
98
  @click="${this.#handleClick}"
99
+ style="${styleMap(iconPaddingOverride)}"
78
100
  type="button">
79
- ${this.text}
101
+ ${this._renderIcon()}
102
+ ${hideText ? nothing : this.text}
80
103
  </button>
81
104
  `;
82
105
  }
@@ -18159,6 +18159,17 @@
18159
18159
  "description": "Indicates if the item is selected",
18160
18160
  "type": "boolean",
18161
18161
  "default": "false"
18162
+ },
18163
+ {
18164
+ "name": "text-hidden",
18165
+ "description": "Hides the text visually",
18166
+ "type": "boolean",
18167
+ "default": "false"
18168
+ },
18169
+ {
18170
+ "name": "icon",
18171
+ "description": "Preset icon key (e.g. \"tier1:gear\")",
18172
+ "type": "string"
18162
18173
  }
18163
18174
  ],
18164
18175
  "properties": [
@@ -18185,6 +18196,19 @@
18185
18196
  "description": "Indicates if the item is selected",
18186
18197
  "type": "boolean",
18187
18198
  "default": "false"
18199
+ },
18200
+ {
18201
+ "name": "textHidden",
18202
+ "attribute": "text-hidden",
18203
+ "description": "Hides the text visually",
18204
+ "type": "boolean",
18205
+ "default": "false"
18206
+ },
18207
+ {
18208
+ "name": "icon",
18209
+ "attribute": "icon",
18210
+ "description": "Preset icon key (e.g. \"tier1:gear\")",
18211
+ "type": "string"
18188
18212
  }
18189
18213
  ],
18190
18214
  "events": [
@@ -18192,6 +18216,12 @@
18192
18216
  "name": "d2l-view-switcher-select",
18193
18217
  "description": "Dispatched when the item is selected"
18194
18218
  }
18219
+ ],
18220
+ "slots": [
18221
+ {
18222
+ "name": "icon",
18223
+ "description": "Optional slot for a custom icon"
18224
+ }
18195
18225
  ]
18196
18226
  },
18197
18227
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "3.333.6",
3
+ "version": "3.334.1",
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",