@brightspace-ui/core 2.152.0 → 2.153.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.
package/README.md
CHANGED
@@ -123,29 +123,14 @@ npm run test:headless:watch
|
|
123
123
|
|
124
124
|
Note: The axe tests require `prefers-reduced-motion` emulation to be turned on in the dev console if debugging in a local browser.
|
125
125
|
|
126
|
-
|
127
|
-
|
128
|
-
This repo uses the [@brightspace-ui/visual-diff utility](https://github.com/BrightspaceUI/visual-diff/) to compare current snapshots against a set of golden snapshots stored in source control.
|
129
|
-
|
130
|
-
The golden snapshots in source control must be updated by the [visual-diff GitHub Action](https://github.com/BrightspaceUI/actions/tree/main/visual-diff). If a pull request results in visual differences, a draft pull request with the new goldens will automatically be opened against its branch.
|
131
|
-
|
132
|
-
To run the tests locally to help troubleshoot or develop new tests, first install these dependencies:
|
126
|
+
This repo uses [@brightspace-ui/testing](https://github.com/BrightspaceUI/testing)'s vdiff command to perform visual regression testing:
|
133
127
|
|
134
128
|
```shell
|
135
|
-
|
136
|
-
|
129
|
+
# vdiff
|
130
|
+
npm run test:vdiff
|
137
131
|
|
138
|
-
|
139
|
-
|
140
|
-
Then run the tests:
|
141
|
-
|
142
|
-
```shell
|
143
|
-
# run visual-diff tests
|
144
|
-
npx mocha './**/*.visual-diff.js' -t 10000
|
145
|
-
# subset of visual-diff tests:
|
146
|
-
npx mocha './**/*.visual-diff.js' -t 10000 -g some-pattern
|
147
|
-
# update visual-diff goldens
|
148
|
-
npx mocha './**/*.visual-diff.js' -t 10000 --golden
|
132
|
+
# re-generate goldens
|
133
|
+
npm run test:vdiff golden
|
149
134
|
```
|
150
135
|
|
151
136
|
## Versioning & Releasing
|
@@ -6,6 +6,13 @@ import ResizeObserver from 'resize-observer-polyfill/dist/ResizeObserver.es.js';
|
|
6
6
|
import { styleMap } from 'lit/directives/style-map.js';
|
7
7
|
|
8
8
|
const reduceMotion = matchMedia('(prefers-reduced-motion: reduce)').matches;
|
9
|
+
let activeReduceMotion = reduceMotion;
|
10
|
+
export function disableReducedMotionForTesting() {
|
11
|
+
activeReduceMotion = false;
|
12
|
+
}
|
13
|
+
export function restoreReducedMotionForTesting() {
|
14
|
+
activeReduceMotion = reduceMotion;
|
15
|
+
}
|
9
16
|
|
10
17
|
const states = {
|
11
18
|
CLOSED: 'closed', // the toast is closed
|
@@ -331,10 +338,10 @@ class AlertToast extends LitElement {
|
|
331
338
|
this._totalSiblingHeightBelow += e.detail.heightDifference;
|
332
339
|
if (e.detail.opening) {
|
333
340
|
this._numAlertsBelow += 1;
|
334
|
-
if (!
|
341
|
+
if (!activeReduceMotion) this._state = states.SLIDING;
|
335
342
|
} else if (e.detail.closing) {
|
336
343
|
this._numAlertsBelow -= 1;
|
337
|
-
if (!
|
344
|
+
if (!activeReduceMotion) this._state = states.SLIDING;
|
338
345
|
}
|
339
346
|
}
|
340
347
|
|
@@ -396,7 +403,7 @@ class AlertToast extends LitElement {
|
|
396
403
|
if (this._state === states.CLOSING) {
|
397
404
|
this._state = states.OPENING;
|
398
405
|
} else if (this._state === states.CLOSED) {
|
399
|
-
if (!
|
406
|
+
if (!activeReduceMotion) {
|
400
407
|
this._state = states.PREOPENING;
|
401
408
|
// pause before running the opening animation because transitions won't run when changing from 'diplay: none' to 'display: block'
|
402
409
|
this._preopenFrame = requestAnimationFrame(() => {
|
@@ -412,7 +419,7 @@ class AlertToast extends LitElement {
|
|
412
419
|
} else {
|
413
420
|
if (!this._innerContainer) return;
|
414
421
|
|
415
|
-
if (
|
422
|
+
if (activeReduceMotion || this._state === states.PREOPENING) {
|
416
423
|
cancelAnimationFrame(this._preopenFrame);
|
417
424
|
this.removeAttribute('role');
|
418
425
|
} else if (this._state === states.OPENING || this._state === states.OPEN || this._state === states.SLIDING) {
|
@@ -425,7 +432,7 @@ class AlertToast extends LitElement {
|
|
425
432
|
requestAnimationFrame(() => {
|
426
433
|
const bottom = this._innerContainer.getBoundingClientRect().bottom;
|
427
434
|
|
428
|
-
if (
|
435
|
+
if (activeReduceMotion || this._state === states.PREOPENING) {
|
429
436
|
this._state = states.CLOSED;
|
430
437
|
this._totalSiblingHeightBelow = 0;
|
431
438
|
this._numAlertsBelow = 0;
|
@@ -444,8 +451,14 @@ class AlertToast extends LitElement {
|
|
444
451
|
}
|
445
452
|
|
446
453
|
_stateChanged(newState, oldState) {
|
447
|
-
|
448
|
-
|
454
|
+
/**
|
455
|
+
* Opening state changes:
|
456
|
+
* - OPENING -> OPEN
|
457
|
+
* - OPENING -> SLIDING (multiple alerts opened rapidly)
|
458
|
+
* - CLOSED -> OPEN (prefers-reduced-motion)
|
459
|
+
*/
|
460
|
+
const newlyOpened = oldState === states.OPENING && (newState === states.OPEN || newState === states.SLIDING);
|
461
|
+
const newlyOpenedReduceMotion = oldState === states.CLOSED && newState === states.OPEN;
|
449
462
|
if (newlyOpened || newlyOpenedReduceMotion) {
|
450
463
|
this._closeTimerStart();
|
451
464
|
} else if (newState !== states.SLIDING && newState !== states.OPEN) {
|
@@ -217,8 +217,8 @@ class InputDateTimeRange extends FocusMixin(SkeletonMixin(FormElementMixin(RtlMi
|
|
217
217
|
const startDateTimeInput = this.shadowRoot && this.shadowRoot.querySelector('.d2l-input-date-time-range-start');
|
218
218
|
const endDateTimeInput = this.shadowRoot && this.shadowRoot.querySelector('.d2l-input-date-time-range-end');
|
219
219
|
|
220
|
-
const tooltipStart = (this.validationError && !this.startOpened && !this.childErrors.has(startDateTimeInput)) ? html`<d2l-tooltip align="start" announced for="${this._startInputId}" position="bottom" state="error">${this.validationError}</d2l-tooltip>` : null;
|
221
|
-
const tooltipEnd = (this.validationError && !this.endOpened && !this.childErrors.has(endDateTimeInput)) ? html`<d2l-tooltip align="start" announced for="${this._endInputId}" position="bottom" state="error">${this.validationError}</d2l-tooltip>` : null;
|
220
|
+
const tooltipStart = (this.validationError && !this.startOpened && !this.childErrors.has(startDateTimeInput)) ? html`<d2l-tooltip align="start" announced for="${this._startInputId}" position="bottom" state="error" class="vdiff-target">${this.validationError}</d2l-tooltip>` : null;
|
221
|
+
const tooltipEnd = (this.validationError && !this.endOpened && !this.childErrors.has(endDateTimeInput)) ? html`<d2l-tooltip align="start" announced for="${this._endInputId}" position="bottom" state="error" class="vdiff-target">${this.validationError}</d2l-tooltip>` : null;
|
222
222
|
return html`
|
223
223
|
${tooltipStart}
|
224
224
|
${tooltipEnd}
|
@@ -236,7 +236,7 @@ class InputDateTimeRange extends FocusMixin(SkeletonMixin(FormElementMixin(RtlMi
|
|
236
236
|
<d2l-input-date-time
|
237
237
|
?novalidate="${this.noValidate}"
|
238
238
|
@change="${this._handleChange}"
|
239
|
-
class="d2l-input-date-time-range-start"
|
239
|
+
class="d2l-input-date-time-range-start vdiff-target"
|
240
240
|
@d2l-input-date-time-dropdown-toggle="${this._handleDropdownToggle}"
|
241
241
|
?disabled="${this.disabled}"
|
242
242
|
.forceInvalid=${this.invalid}
|
@@ -258,7 +258,7 @@ class InputDateTimeRange extends FocusMixin(SkeletonMixin(FormElementMixin(RtlMi
|
|
258
258
|
<d2l-input-date-time
|
259
259
|
?novalidate="${this.noValidate}"
|
260
260
|
@change="${this._handleChange}"
|
261
|
-
class="d2l-input-date-time-range-end"
|
261
|
+
class="d2l-input-date-time-range-end vdiff-target"
|
262
262
|
@d2l-input-date-time-dropdown-toggle="${this._handleDropdownToggle}"
|
263
263
|
?disabled="${this.disabled}"
|
264
264
|
.forceInvalid=${this.invalid}
|
@@ -230,11 +230,12 @@ class InputDateTime extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMi
|
|
230
230
|
|
231
231
|
const dateOpened = this.opened && !this._timeOpened && !this.disabled && !this.skeleton;
|
232
232
|
const parsedValue = this.value ? (this.localized ? this.value : getLocalDateTimeFromUTCDateTime(this.value)) : '';
|
233
|
-
const tooltip = (this.validationError && !this.opened && this.childErrors.size === 0) ? html`<d2l-tooltip align="start" announced for="${this._inputId}" state="error">${this.validationError}</d2l-tooltip>` : null;
|
233
|
+
const tooltip = (this.validationError && !this.opened && this.childErrors.size === 0) ? html`<d2l-tooltip align="start" announced for="${this._inputId}" state="error" class="vdiff-target">${this.validationError}</d2l-tooltip>` : null;
|
234
234
|
const inputTime = !timeHidden ? html`<d2l-input-time
|
235
235
|
?novalidate="${this.noValidate}"
|
236
236
|
@blur="${this._handleInputTimeBlur}"
|
237
237
|
@change="${this._handleTimeChange}"
|
238
|
+
class="vdiff-target"
|
238
239
|
@d2l-input-time-dropdown-toggle="${this._handleDropdownToggle}"
|
239
240
|
default-value="${ifDefined(this.timeDefaultValue)}"
|
240
241
|
?disabled="${this.disabled}"
|
@@ -264,6 +265,7 @@ class InputDateTime extends FocusMixin(LabelledMixin(SkeletonMixin(FormElementMi
|
|
264
265
|
novalidateminmax
|
265
266
|
has-now
|
266
267
|
@change="${this._handleDateChange}"
|
268
|
+
class="vdiff-target"
|
267
269
|
@d2l-input-date-dropdown-toggle="${this._handleDropdownToggle}"
|
268
270
|
?disabled="${this.disabled}"
|
269
271
|
.forceInvalid=${this.invalid}
|
@@ -47,7 +47,7 @@ A loading spinner indicates that something is happening and we don't know how lo
|
|
47
47
|
|
48
48
|
## Future Improvements
|
49
49
|
|
50
|
-
- Ability to "freeze" the spinner at a specified frame to make
|
50
|
+
- Ability to "freeze" the spinner at a specified frame to make vdiff testing easier
|
51
51
|
|
52
52
|
Looking for an enhancement not listed here? Create a GitHub issue!
|
53
53
|
<!-- docs: end hidden content -->
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@brightspace-ui/core",
|
3
|
-
"version": "2.
|
3
|
+
"version": "2.153.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",
|