@brightspace-ui/core 2.115.1 → 2.117.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.
@@ -1,11 +1,12 @@
1
1
  import '../colors/colors.js';
2
2
  import { css, html, LitElement } from 'lit';
3
3
  import { bodySmallStyles } from '../typography/styles.js';
4
+ import { SkeletonMixin } from '../skeleton/skeleton-mixin.js';
4
5
 
5
6
  /**
6
7
  * A component for a "summary item" child component that describes the content in a collapsible panel.
7
8
  */
8
- class CollapsiblePanelSummaryItem extends LitElement {
9
+ class CollapsiblePanelSummaryItem extends SkeletonMixin(LitElement) {
9
10
 
10
11
  static get properties() {
11
12
  return {
@@ -18,7 +19,7 @@ class CollapsiblePanelSummaryItem extends LitElement {
18
19
  }
19
20
 
20
21
  static get styles() {
21
- return [bodySmallStyles, css`
22
+ return [super.styles, bodySmallStyles, css`
22
23
  :host {
23
24
  color: var(--d2l-color-galena);
24
25
  display: block;
@@ -38,7 +39,7 @@ class CollapsiblePanelSummaryItem extends LitElement {
38
39
  }
39
40
 
40
41
  render() {
41
- return html`<p class="d2l-body-small">${this.text}</p>`;
42
+ return html`<p class="d2l-body-small d2l-skeletize">${this.text}</p>`;
42
43
  }
43
44
  }
44
45
 
@@ -7,6 +7,7 @@ import { classMap } from 'lit/directives/class-map.js';
7
7
  import { FocusMixin } from '../../mixins/focus/focus-mixin.js';
8
8
  import { offscreenStyles } from '../offscreen/offscreen.js';
9
9
  import { RtlMixin } from '../../mixins/rtl/rtl-mixin.js';
10
+ import { SkeletonMixin } from '../skeleton/skeleton-mixin.js';
10
11
 
11
12
  const normalizeHeadingNumber = (number) => {
12
13
  number = parseInt(number);
@@ -20,13 +21,14 @@ const defaultHeading = 3;
20
21
  /**
21
22
  * A container with a title that can be expanded/collapsed to show/hide content.
22
23
  * @slot header - Slot for supporting header content
24
+ * @slot before - Slot for content to be placed at the left side of the header, aligned with the title and header slot
23
25
  * @slot summary - Slot for the summary of the expanded content. Only accepts `d2l-collapsible-panel-summary-item`
24
26
  * @slot default - Slot for the expanded content
25
27
  * @slot actions - Slot for buttons and dropdown openers to be placed in top right corner of header
26
28
  * @fires d2l-collapsible-panel-expand - Dispatched when the panel is expanded
27
29
  * @fires d2l-collapsible-panel-collapse - Dispatched when the panel is collapsed
28
30
  */
29
- class CollapsiblePanel extends FocusMixin(RtlMixin(LitElement)) {
31
+ class CollapsiblePanel extends SkeletonMixin(FocusMixin(RtlMixin(LitElement))) {
30
32
 
31
33
  static get properties() {
32
34
  return {
@@ -76,13 +78,14 @@ class CollapsiblePanel extends FocusMixin(RtlMixin(LitElement)) {
76
78
  */
77
79
  noSticky: { attribute: 'no-sticky', type: Boolean },
78
80
  _focused: { state: true },
81
+ _hasBefore: { state: true },
79
82
  _hasSummary: { state: true },
80
83
  _scrolled: { state: true },
81
84
  };
82
85
  }
83
86
 
84
87
  static get styles() {
85
- return [heading1Styles, heading2Styles, heading3Styles, heading4Styles, offscreenStyles, css`
88
+ return [super.styles, heading1Styles, heading2Styles, heading3Styles, heading4Styles, offscreenStyles, css`
86
89
  :host {
87
90
  --d2l-collapsible-panel-focus-outline: solid 2px var(--d2l-color-celestine);
88
91
  --d2l-collapsible-panel-spacing-inline: 0.9rem;
@@ -101,7 +104,7 @@ class CollapsiblePanel extends FocusMixin(RtlMixin(LitElement)) {
101
104
  border: 1px solid var(--d2l-color-mica);
102
105
  border-radius: 0.4rem;
103
106
  }
104
- :host(:not([expanded])) .d2l-collapsible-panel {
107
+ :host(:not([expanded]):not([skeleton])) .d2l-collapsible-panel {
105
108
  cursor: pointer;
106
109
  }
107
110
  :host([type="subtle"]) .d2l-collapsible-panel {
@@ -121,11 +124,24 @@ class CollapsiblePanel extends FocusMixin(RtlMixin(LitElement)) {
121
124
  :host([heading-style="4"]) {
122
125
  --d2l-collapsible-panel-header-spacing: 0.3rem;
123
126
  }
127
+ .d2l-collapsible-panel-before {
128
+ grid-row: 1/-1;
129
+ }
130
+ .d2l-collapsible-panel.has-before .d2l-collapsible-panel-before {
131
+ margin: 0.3rem 0;
132
+ margin-inline-start: var(--d2l-collapsible-panel-spacing-inline);
133
+ }
124
134
  .d2l-collapsible-panel-header {
125
135
  border-radius: 0.4rem;
126
136
  cursor: pointer;
137
+ display: grid;
138
+ grid-template-columns: auto 1fr;
139
+ grid-template-rows: auto auto;
127
140
  padding: var(--d2l-collapsible-panel-header-spacing) 0;
128
141
  }
142
+ :host(:not([skeleton])) .d2l-collapsible-panel-header {
143
+ cursor: pointer;
144
+ }
129
145
  :host([type="inline"]) .d2l-collapsible-panel-header {
130
146
  border-radius: 0;
131
147
  outline-offset: -2px;
@@ -152,6 +168,9 @@ class CollapsiblePanel extends FocusMixin(RtlMixin(LitElement)) {
152
168
  overflow-y: hidden;
153
169
  user-select: none;
154
170
  }
171
+ .d2l-collapsible-panel.has-before .d2l-collapsible-panel-title {
172
+ margin-inline-start: 0.75rem;
173
+ }
155
174
 
156
175
  .d2l-collapsible-panel.focused {
157
176
  outline: var(--d2l-collapsible-panel-focus-outline);
@@ -169,8 +188,12 @@ class CollapsiblePanel extends FocusMixin(RtlMixin(LitElement)) {
169
188
  }
170
189
  .d2l-collapsible-panel-header-secondary {
171
190
  display: flex;
191
+ margin-inline-end: var(--d2l-collapsible-panel-spacing-inline);
172
192
  margin-inline-start: var(--d2l-collapsible-panel-spacing-inline);
173
193
  }
194
+ .d2l-collapsible-panel.has-before .d2l-collapsible-panel-header-secondary {
195
+ margin-inline-start: 0.75rem;
196
+ }
174
197
  .d2l-collapsible-panel-header-secondary ::slotted(*) {
175
198
  cursor: default;
176
199
  }
@@ -286,6 +309,7 @@ class CollapsiblePanel extends FocusMixin(RtlMixin(LitElement)) {
286
309
  'd2l-collapsible-panel': true,
287
310
  'focused': this._focused,
288
311
  'has-summary': this._hasSummary,
312
+ 'has-before': this._hasBefore,
289
313
  'scrolled': this._scrolled,
290
314
  };
291
315
  const expandCollapseLabel = this.expandCollapseLabel || this.panelTitle;
@@ -341,6 +365,12 @@ class CollapsiblePanel extends FocusMixin(RtlMixin(LitElement)) {
341
365
  }
342
366
  }
343
367
 
368
+ _handleBeforeSlotChange(e) {
369
+ const content = e.target.assignedNodes({ flatten: true });
370
+
371
+ this._hasBefore = content?.length > 0;
372
+ }
373
+
344
374
  _handleExpandCollapse(e) {
345
375
  const eventPromise = this.expanded ? e.detail.expandComplete : e.detail.collapseComplete;
346
376
  const event = `d2l-collapsible-panel-${this.expanded ? 'expand' : 'collapse' }`;
@@ -387,13 +417,16 @@ class CollapsiblePanel extends FocusMixin(RtlMixin(LitElement)) {
387
417
  _renderHeader() {
388
418
  return html`
389
419
  <div class="d2l-collapsible-panel-header" @click="${this._handleHeaderClick}">
420
+ <div class="d2l-collapsible-panel-before">
421
+ <slot name="before" @slotchange="${this._handleBeforeSlotChange}"></slot>
422
+ </div>
390
423
  <div class="d2l-collapsible-panel-header-primary">
391
424
  ${this._renderPanelTitle()}
392
425
  <div class="d2l-collapsible-panel-header-actions" @click="${this._handleActionsClick}">
393
426
  <slot name="actions"></slot>
394
427
  </div>
395
428
  <div class="d2l-collapsible-panel-opener">
396
- <d2l-icon-custom size="tier1">
429
+ <d2l-icon-custom size="tier1" class="d2l-skeletize">
397
430
  <svg xmlns="http://www.w3.org/2000/svg" width="10" height="18" fill="none" viewBox="0 0 10 18">
398
431
  <path stroke="var(--d2l-color-tungsten)" stroke-linejoin="round" stroke-width="2" d="m9 9-8 8V1l8 8Z"/>
399
432
  </svg>
@@ -414,6 +447,7 @@ class CollapsiblePanel extends FocusMixin(RtlMixin(LitElement)) {
414
447
 
415
448
  const titleClasses = {
416
449
  'd2l-collapsible-panel-title': true,
450
+ 'd2l-skeletize': true,
417
451
  [`d2l-heading-${headingStyle}`]: true,
418
452
  };
419
453
 
@@ -449,6 +483,7 @@ class CollapsiblePanel extends FocusMixin(RtlMixin(LitElement)) {
449
483
  }
450
484
 
451
485
  _toggleExpand() {
486
+ if (this.skeleton) return;
452
487
  this.expanded = !this.expanded;
453
488
  }
454
489
  }
@@ -106,9 +106,10 @@
106
106
  </d2l-collapsible-panel>
107
107
  </d2l-demo-snippet>
108
108
 
109
- <h2>With custom action and header content</h2>
109
+ <h2>With custom action, before and header content</h2>
110
110
  <d2l-demo-snippet>
111
111
  <d2l-collapsible-panel panel-title="Session: January 1, 2021: 10:00 AM" expand-collapse-label="Session on January 1">
112
+ <d2l-icon icon="tier3:assignments" slot="before"></d2l-icon>
112
113
  <d2l-button-icon slot="actions" icon="tier1:fullscreen"></d2l-button-icon><d2l-button-icon slot="actions" icon="tier1:download"></d2l-button-icon><d2l-dropdown-more slot="actions">
113
114
  <d2l-dropdown-menu>
114
115
  <d2l-menu>
@@ -1156,6 +1156,12 @@
1156
1156
  "description": "REQUIRED: Text that is displayed",
1157
1157
  "type": "string",
1158
1158
  "default": "\"\""
1159
+ },
1160
+ {
1161
+ "name": "skeleton",
1162
+ "description": "Renders the input as a [skeleton loader](https://github.com/BrightspaceUI/core/tree/main/components/skeleton)",
1163
+ "type": "boolean",
1164
+ "default": "false"
1159
1165
  }
1160
1166
  ],
1161
1167
  "properties": [
@@ -1165,6 +1171,13 @@
1165
1171
  "description": "REQUIRED: Text that is displayed",
1166
1172
  "type": "string",
1167
1173
  "default": "\"\""
1174
+ },
1175
+ {
1176
+ "name": "skeleton",
1177
+ "attribute": "skeleton",
1178
+ "description": "Renders the input as a [skeleton loader](https://github.com/BrightspaceUI/core/tree/main/components/skeleton)",
1179
+ "type": "boolean",
1180
+ "default": "false"
1168
1181
  }
1169
1182
  ]
1170
1183
  },
@@ -1218,6 +1231,12 @@
1218
1231
  "description": "Disables sticky positioning for the header",
1219
1232
  "type": "boolean",
1220
1233
  "default": "false"
1234
+ },
1235
+ {
1236
+ "name": "skeleton",
1237
+ "description": "Renders the input as a [skeleton loader](https://github.com/BrightspaceUI/core/tree/main/components/skeleton)",
1238
+ "type": "boolean",
1239
+ "default": "false"
1221
1240
  }
1222
1241
  ],
1223
1242
  "properties": [
@@ -1274,6 +1293,13 @@
1274
1293
  "description": "Disables sticky positioning for the header",
1275
1294
  "type": "boolean",
1276
1295
  "default": "false"
1296
+ },
1297
+ {
1298
+ "name": "skeleton",
1299
+ "attribute": "skeleton",
1300
+ "description": "Renders the input as a [skeleton loader](https://github.com/BrightspaceUI/core/tree/main/components/skeleton)",
1301
+ "type": "boolean",
1302
+ "default": "false"
1277
1303
  }
1278
1304
  ],
1279
1305
  "events": [
@@ -1291,6 +1317,10 @@
1291
1317
  "name": "header",
1292
1318
  "description": "Slot for supporting header content"
1293
1319
  },
1320
+ {
1321
+ "name": "before",
1322
+ "description": "Slot for content to be placed at the left side of the header, aligned with the title and header slot"
1323
+ },
1294
1324
  {
1295
1325
  "name": "summary",
1296
1326
  "description": "Slot for the summary of the expanded content. Only accepts `d2l-collapsible-panel-summary-item`"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "2.115.1",
3
+ "version": "2.117.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",