@brightspace-ui/core 2.116.0 → 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.
@@ -21,6 +21,7 @@ const defaultHeading = 3;
21
21
  /**
22
22
  * A container with a title that can be expanded/collapsed to show/hide content.
23
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
24
25
  * @slot summary - Slot for the summary of the expanded content. Only accepts `d2l-collapsible-panel-summary-item`
25
26
  * @slot default - Slot for the expanded content
26
27
  * @slot actions - Slot for buttons and dropdown openers to be placed in top right corner of header
@@ -77,6 +78,7 @@ class CollapsiblePanel extends SkeletonMixin(FocusMixin(RtlMixin(LitElement))) {
77
78
  */
78
79
  noSticky: { attribute: 'no-sticky', type: Boolean },
79
80
  _focused: { state: true },
81
+ _hasBefore: { state: true },
80
82
  _hasSummary: { state: true },
81
83
  _scrolled: { state: true },
82
84
  };
@@ -122,8 +124,19 @@ class CollapsiblePanel extends SkeletonMixin(FocusMixin(RtlMixin(LitElement))) {
122
124
  :host([heading-style="4"]) {
123
125
  --d2l-collapsible-panel-header-spacing: 0.3rem;
124
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
+ }
125
134
  .d2l-collapsible-panel-header {
126
135
  border-radius: 0.4rem;
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
  }
129
142
  :host(:not([skeleton])) .d2l-collapsible-panel-header {
@@ -155,6 +168,9 @@ class CollapsiblePanel extends SkeletonMixin(FocusMixin(RtlMixin(LitElement))) {
155
168
  overflow-y: hidden;
156
169
  user-select: none;
157
170
  }
171
+ .d2l-collapsible-panel.has-before .d2l-collapsible-panel-title {
172
+ margin-inline-start: 0.75rem;
173
+ }
158
174
 
159
175
  .d2l-collapsible-panel.focused {
160
176
  outline: var(--d2l-collapsible-panel-focus-outline);
@@ -172,8 +188,12 @@ class CollapsiblePanel extends SkeletonMixin(FocusMixin(RtlMixin(LitElement))) {
172
188
  }
173
189
  .d2l-collapsible-panel-header-secondary {
174
190
  display: flex;
191
+ margin-inline-end: var(--d2l-collapsible-panel-spacing-inline);
175
192
  margin-inline-start: var(--d2l-collapsible-panel-spacing-inline);
176
193
  }
194
+ .d2l-collapsible-panel.has-before .d2l-collapsible-panel-header-secondary {
195
+ margin-inline-start: 0.75rem;
196
+ }
177
197
  .d2l-collapsible-panel-header-secondary ::slotted(*) {
178
198
  cursor: default;
179
199
  }
@@ -289,6 +309,7 @@ class CollapsiblePanel extends SkeletonMixin(FocusMixin(RtlMixin(LitElement))) {
289
309
  'd2l-collapsible-panel': true,
290
310
  'focused': this._focused,
291
311
  'has-summary': this._hasSummary,
312
+ 'has-before': this._hasBefore,
292
313
  'scrolled': this._scrolled,
293
314
  };
294
315
  const expandCollapseLabel = this.expandCollapseLabel || this.panelTitle;
@@ -344,6 +365,12 @@ class CollapsiblePanel extends SkeletonMixin(FocusMixin(RtlMixin(LitElement))) {
344
365
  }
345
366
  }
346
367
 
368
+ _handleBeforeSlotChange(e) {
369
+ const content = e.target.assignedNodes({ flatten: true });
370
+
371
+ this._hasBefore = content?.length > 0;
372
+ }
373
+
347
374
  _handleExpandCollapse(e) {
348
375
  const eventPromise = this.expanded ? e.detail.expandComplete : e.detail.collapseComplete;
349
376
  const event = `d2l-collapsible-panel-${this.expanded ? 'expand' : 'collapse' }`;
@@ -390,6 +417,9 @@ class CollapsiblePanel extends SkeletonMixin(FocusMixin(RtlMixin(LitElement))) {
390
417
  _renderHeader() {
391
418
  return html`
392
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>
393
423
  <div class="d2l-collapsible-panel-header-primary">
394
424
  ${this._renderPanelTitle()}
395
425
  <div class="d2l-collapsible-panel-header-actions" @click="${this._handleActionsClick}">
@@ -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>
@@ -1317,6 +1317,10 @@
1317
1317
  "name": "header",
1318
1318
  "description": "Slot for supporting header content"
1319
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
+ },
1320
1324
  {
1321
1325
  "name": "summary",
1322
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.116.0",
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",