@brightspace-ui/core 2.180.0 → 2.180.2

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.
@@ -43,6 +43,24 @@
43
43
  </template>
44
44
  </d2l-demo-snippet>
45
45
 
46
+ <h5>Empty State Only Button</h5>
47
+ <d2l-demo-snippet>
48
+ <template>
49
+ <d2l-empty-state-simple>
50
+ <d2l-empty-state-action-button text="Create New Assignment"></d2l-empty-state-action-button>
51
+ </d2l-empty-state-simple>
52
+ </template>
53
+ </d2l-demo-snippet>
54
+
55
+ <h5>Empty State Only Link</h5>
56
+ <d2l-demo-snippet>
57
+ <template>
58
+ <d2l-empty-state-simple>
59
+ <d2l-empty-state-action-link text="Create New Assignment" href="https://d2l.com"></d2l-empty-state-action-link>
60
+ </d2l-empty-state-simple>
61
+ </template>
62
+ </d2l-demo-snippet>
63
+
46
64
  <h2>Empty State Illustrated</h2>
47
65
 
48
66
  <h5>No Action</h5>
@@ -27,8 +27,10 @@ class EmptyStateSimple extends PropertyRequiredMixin(RtlMixin(LitElement)) {
27
27
 
28
28
  render() {
29
29
  return html`
30
- <p class="d2l-body-compact d2l-empty-state-description">${this.description}</p>
31
- <slot class="action-slot"></slot>
30
+ <div class="empty-state-container">
31
+ <p class="d2l-body-compact d2l-empty-state-description">${this.description}</p>
32
+ <slot class="action-slot"></slot>
33
+ </div>
32
34
  `;
33
35
  }
34
36
 
@@ -30,14 +30,16 @@ export const emptyStateSimpleStyles = css`
30
30
  padding: 1.2rem 1.5rem;
31
31
  }
32
32
 
33
- :host([dir="rtl"]) .d2l-empty-state-description {
34
- padding-left: 0.5rem;
35
- padding-right: 0;
33
+ :host([description]) .empty-state-container {
34
+ align-items: center;
35
+ column-gap: 0.75rem;
36
+ display: flex;
37
+ flex-wrap: wrap;
38
+ padding-inline-start: 0;
36
39
  }
37
40
 
38
41
  .d2l-empty-state-description {
39
- display: inline;
40
- padding-right: 0.5rem;
42
+ margin: 0;
41
43
  }
42
44
 
43
45
  `;
@@ -66,7 +68,7 @@ export const emptyStateIllustratedStyles = css`
66
68
  .d2l-empty-state-title {
67
69
  margin-bottom: 0.9rem;
68
70
  }
69
-
71
+
70
72
  .d2l-empty-state-title-large {
71
73
  font-size: 1.5rem;
72
74
  line-height: 1.8rem;
@@ -175,7 +175,8 @@ class Filter extends FocusMixin(LocalizeCoreElement(RtlMixin(LitElement))) {
175
175
 
176
176
  .d2l-filter-dimension-info-message {
177
177
  color: var(--d2l-color-ferrite);
178
- text-align: center;
178
+ display: flex;
179
+ justify-content: center;
179
180
  }
180
181
 
181
182
  /* Needed to "undo" the menu-item style for multiple dimensions */
@@ -50,7 +50,7 @@
50
50
  <d2l-demo-snippet>
51
51
  <template>
52
52
  <d2l-more-less blur-color="#f00">
53
- <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum elementum venenatis arcu sit amet varius. Maecenas posuere magna arcu, quis maximus odio fringilla ac. Integer ligula lorem, faucibus sit amet cursus vel, pellentesque a justo. Aliquam urna metus, molestie at tempor eget, vestibulum a purus. Donec aliquet rutrum mi. Duis ornare congue tempor. Nullam sed massa fermentum, tincidunt leo eu, vestibulum orci. Sed ultrices est in lacus venenatis, posuere suscipit arcu scelerisque. In aliquam ipsum rhoncus, lobortis ligula ut, molestie orci. Proin scelerisque tempor posuere. Phasellus consequat, lorem quis hendrerit tempor, sem lectus sagittis nunc, in tristique dui arcu non arcu. Nunc aliquam nisi et sapien commodo lacinia. <a href="">Quisque</a> iaculis orci vel odio varius porta. Fusce tincidunt dolor enim, vitae sollicitudin purus suscipit eu.</p>
53
+ <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. <a href="">Vestibulum</a> elementum venenatis arcu sit amet varius. Maecenas posuere magna arcu, quis maximus odio fringilla ac. Integer ligula lorem, faucibus sit amet cursus vel, pellentesque a justo. Aliquam urna metus, molestie at tempor eget, vestibulum a purus. Donec aliquet rutrum mi. Duis ornare congue tempor. Nullam sed massa fermentum, tincidunt leo eu, vestibulum orci. Sed ultrices est in lacus venenatis, posuere suscipit arcu scelerisque. In aliquam ipsum rhoncus, lobortis ligula ut, molestie orci. Proin scelerisque tempor posuere. Phasellus consequat, lorem quis hendrerit tempor, sem lectus sagittis nunc, in tristique dui arcu non arcu. Nunc aliquam nisi et sapien commodo lacinia. <a href="">Quisque</a> iaculis orci vel odio varius porta. Fusce tincidunt dolor enim, vitae sollicitudin purus suscipit eu.</p>
54
54
  </d2l-more-less>
55
55
  </template>
56
56
  </d2l-demo-snippet>
@@ -2,12 +2,16 @@ import '../button/button-subtle.js';
2
2
  import { css, html, LitElement } from 'lit';
3
3
  import { getComposedChildren, isComposedAncestor } from '../../helpers/dom.js';
4
4
  import { classMap } from 'lit/directives/class-map.js';
5
+ import { getComposedActiveElement } from '../../helpers/focus.js';
5
6
  import { getUniqueId } from '../../helpers/uniqueId.js';
6
7
  import { ifDefined } from 'lit/directives/if-defined.js';
7
8
  import { LocalizeCoreElement } from '../../helpers/localize-core-element.js';
8
9
  import ResizeObserver from 'resize-observer-polyfill/dist/ResizeObserver.es.js';
9
10
  import { styleMap } from 'lit/directives/style-map.js';
10
11
 
12
+ const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
13
+ const transitionDur = matchMedia('(prefers-reduced-motion: reduce)').matches ? 0 : 400;
14
+
11
15
  /**
12
16
  * A component used to minimize the display of long content, while providing a way to reveal the full content.
13
17
  * @slot - Default content placed inside of the component
@@ -61,7 +65,7 @@ class MoreLess extends LocalizeCoreElement(LitElement) {
61
65
  overflow: hidden;
62
66
  }
63
67
  .d2l-more-less-transition {
64
- transition: max-height 400ms cubic-bezier(0, 0.7, 0.5, 1);
68
+ transition: max-height ${transitionDur}ms cubic-bezier(0, 0.7, 0.5, 1);
65
69
  }
66
70
  .d2l-more-less-blur {
67
71
  display: none;
@@ -234,25 +238,49 @@ class MoreLess extends LocalizeCoreElement(LitElement) {
234
238
  this.expanded = true;
235
239
  }
236
240
 
237
- __focusIn() {
241
+ async __focusIn(e) {
238
242
  if (this.inactive || this.expanded) {
239
243
  return;
240
244
  }
241
245
 
242
- this.__expand();
243
- this.__autoExpanded = true;
246
+ const target = e.composedPath()[0] || e.target;
247
+
248
+ if (isSafari) {
249
+ target.scrollIntoViewIfNeeded?.();
250
+ setTimeout(() => this.__content.scrollTo({ top: 0, behavior: 'instant' }), 1);
251
+ }
252
+
253
+ if (this.__content.scrollTop) {
254
+ this.__content.scrollTo({ top: 0, behavior: 'instant' });
255
+ this.__expand();
256
+ this.__autoExpanded = true;
257
+ await (transitionDur && new Promise(r => setTimeout(r, transitionDur)));
258
+ if (target.getRootNode().activeElement === target) {
259
+ target.scrollIntoView({ block: 'center', inline: 'center', behavior: 'instant' });
260
+ }
261
+ }
244
262
  }
245
263
 
246
- __focusOut(e) {
264
+ async __focusOut({ relatedTarget }) {
265
+
247
266
  if (this.inactive
248
267
  || !this.__autoExpanded
249
- || isComposedAncestor(this.__content, e.relatedTarget)
268
+ || isComposedAncestor(this.__content, relatedTarget)
250
269
  ) {
251
270
  return;
252
271
  }
253
272
 
254
273
  this.__shrink();
255
274
  this.__autoExpanded = false;
275
+
276
+ relatedTarget && await new Promise(r => relatedTarget.addEventListener('focus', r, { once: true }));
277
+ const target = getComposedActiveElement();
278
+
279
+ await (transitionDur && new Promise(r => setTimeout(r, transitionDur)));
280
+ const activeElement = getComposedActiveElement();
281
+ if (target === activeElement) {
282
+ target.scrollIntoView({ block: 'center', inline: 'center', behavior: 'instant' });
283
+ }
256
284
  }
257
285
 
258
286
  __init_measureBaseHeight() {
@@ -315,14 +343,6 @@ class MoreLess extends LocalizeCoreElement(LitElement) {
315
343
  }
316
344
 
317
345
  __reactToChanges() {
318
- if (!this.__transitionAdded) {
319
- this.__reactToChanges_setupTransition();
320
- } else {
321
- this.__adjustToContent();
322
- }
323
- }
324
-
325
- __reactToChanges_setupTransition() {
326
346
  this.__transitionAdded = true;
327
347
  this.__adjustToContent();
328
348
  }
@@ -342,6 +362,7 @@ class MoreLess extends LocalizeCoreElement(LitElement) {
342
362
  this.__transitionAdded = true;
343
363
  this.__maxHeight = this.height;
344
364
  this.expanded = false;
365
+ this.__content.scrollTo({ top: 0, behavior: 'instant' });
345
366
  }
346
367
 
347
368
  __startObserving() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@brightspace-ui/core",
3
- "version": "2.180.0",
3
+ "version": "2.180.2",
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",