@brightspace-ui/core 3.208.6 → 3.209.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.
|
@@ -133,7 +133,7 @@ export const OverflowGroupMixin = superclass => class extends LocalizeCoreElemen
|
|
|
133
133
|
|
|
134
134
|
const containerStyles = {
|
|
135
135
|
flexWrap: this._wrapping ? 'wrap' : 'nowrap',
|
|
136
|
-
minHeight: this.autoShow ? '
|
|
136
|
+
minHeight: this.autoShow ? 'auto' : (this._itemHeight ? `${this._itemHeight}px` : 'auto'),
|
|
137
137
|
maxHeight: this.autoShow ? 'none' : (this._itemHeight ? `${this._itemHeight}px` : 'auto')
|
|
138
138
|
};
|
|
139
139
|
|
|
@@ -68,22 +68,32 @@
|
|
|
68
68
|
|
|
69
69
|
<d2l-demo-snippet>
|
|
70
70
|
<template>
|
|
71
|
-
<button>Start Animation</button>
|
|
72
|
-
<d2l-progress label="
|
|
71
|
+
<button id="start">Start Animation</button><button id="reset">Reset</button>
|
|
72
|
+
<d2l-progress label="Waiting..." announce-label></d2l-progress>
|
|
73
73
|
<script data-demo-hide>
|
|
74
74
|
(demo => {
|
|
75
|
-
const
|
|
75
|
+
const startButton = demo.querySelector('#start');
|
|
76
|
+
const resetButton = demo.querySelector('#reset');
|
|
76
77
|
const progress = demo.querySelector('d2l-progress');
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
78
|
+
let to = null;
|
|
79
|
+
startButton.addEventListener('click', () => {
|
|
80
|
+
let i = 0;
|
|
81
|
+
const step = () => {
|
|
82
|
+
console.log(i);
|
|
83
|
+
|
|
84
|
+
if (i === 4) progress.label = 'Complete';
|
|
85
|
+
else if (i >= 2) progress.label = 'Validating...';
|
|
86
|
+
else progress.label = 'Uploading...';
|
|
87
|
+
progress.value = i * 25;
|
|
88
|
+
i++;
|
|
89
|
+
if (i < 5) to = setTimeout(step, 1000);
|
|
90
|
+
};
|
|
91
|
+
step();
|
|
92
|
+
});
|
|
93
|
+
resetButton.addEventListener('click', () => {
|
|
94
|
+
clearTimeout(to);
|
|
95
|
+
progress.value = undefined;
|
|
96
|
+
progress.label = 'Waiting...';
|
|
87
97
|
});
|
|
88
98
|
})(document.currentScript.parentNode);
|
|
89
99
|
</script>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import '../../components/colors/colors.js';
|
|
2
2
|
import { bodyCompactStyles, bodySmallStyles } from '../typography/styles.js';
|
|
3
|
-
import { css, html, LitElement, unsafeCSS } from 'lit';
|
|
3
|
+
import { css, html, LitElement, nothing, unsafeCSS } from 'lit';
|
|
4
4
|
import { classMap } from 'lit/directives/class-map.js';
|
|
5
5
|
import { formatPercent } from '@brightspace-ui/intl';
|
|
6
6
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
@@ -19,7 +19,7 @@ class Progress extends LocalizeCoreElement(LitElement) {
|
|
|
19
19
|
* The current value of the progress bar
|
|
20
20
|
* @type {number}
|
|
21
21
|
*/
|
|
22
|
-
value: { type: Number },
|
|
22
|
+
value: { type: Number, reflect: true },
|
|
23
23
|
/**
|
|
24
24
|
* REQUIRED: Label for the progress bar
|
|
25
25
|
* @type {string}
|
|
@@ -39,7 +39,7 @@ class Progress extends LocalizeCoreElement(LitElement) {
|
|
|
39
39
|
* Hide the bar's value
|
|
40
40
|
* @type {boolean}
|
|
41
41
|
*/
|
|
42
|
-
valueHidden: { type: Boolean, attribute: 'value-hidden' },
|
|
42
|
+
valueHidden: { type: Boolean, attribute: 'value-hidden', reflect: true },
|
|
43
43
|
/**
|
|
44
44
|
* The size of the progress bar
|
|
45
45
|
* @type {'small'|'medium'|'large'}
|
|
@@ -52,19 +52,20 @@ class Progress extends LocalizeCoreElement(LitElement) {
|
|
|
52
52
|
return [bodySmallStyles, bodyCompactStyles, css`
|
|
53
53
|
:host {
|
|
54
54
|
align-items: center;
|
|
55
|
-
display:
|
|
56
|
-
|
|
55
|
+
display: grid;
|
|
56
|
+
grid-template: auto auto / 1fr auto;
|
|
57
|
+
grid-template-areas:
|
|
58
|
+
"label label"
|
|
59
|
+
"bar value";
|
|
57
60
|
min-width: 6rem;
|
|
58
61
|
}
|
|
59
62
|
:host([hidden]) {
|
|
60
63
|
display: none;
|
|
61
64
|
}
|
|
62
|
-
:host([value-hidden]) {
|
|
63
|
-
row-gap: 0.3rem;
|
|
64
|
-
}
|
|
65
65
|
|
|
66
66
|
#label {
|
|
67
|
-
|
|
67
|
+
grid-area: label;
|
|
68
|
+
width: 100%;
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
progress {
|
|
@@ -73,38 +74,41 @@ class Progress extends LocalizeCoreElement(LitElement) {
|
|
|
73
74
|
-webkit-appearance: none;
|
|
74
75
|
appearance: none;
|
|
75
76
|
background-color: var(--d2l-color-gypsum);
|
|
77
|
+
box-shadow: inset 0 2px var(--d2l-color-mica);
|
|
78
|
+
width: 100%;
|
|
79
|
+
}
|
|
80
|
+
.bar {
|
|
76
81
|
border: none;
|
|
77
82
|
border-radius: 0.9rem;
|
|
78
|
-
box-shadow: inset 0 2px var(--d2l-color-mica);
|
|
79
83
|
display: block;
|
|
80
|
-
|
|
84
|
+
grid-area: bar;
|
|
81
85
|
height: 0.6rem;
|
|
82
|
-
margin-inline-end: 0.4rem;
|
|
83
86
|
}
|
|
84
87
|
.value {
|
|
88
|
+
grid-area: value;
|
|
89
|
+
margin-inline-start: 0.4rem;
|
|
85
90
|
text-align: end;
|
|
86
91
|
width: 2.42rem;
|
|
87
92
|
}
|
|
88
93
|
|
|
89
94
|
:host([size="small"]) {
|
|
90
|
-
|
|
95
|
+
.bar {
|
|
91
96
|
height: 0.3rem;
|
|
92
|
-
margin-inline-end: 0.3rem;
|
|
93
97
|
}
|
|
94
98
|
|
|
95
99
|
.value {
|
|
100
|
+
margin-inline-start: 0.3rem;
|
|
96
101
|
width: 2.15rem;
|
|
97
102
|
}
|
|
98
103
|
}
|
|
99
104
|
|
|
100
105
|
:host([size="large"]) {
|
|
101
106
|
line-height: 1.5rem;
|
|
102
|
-
|
|
107
|
+
.bar {
|
|
103
108
|
height: 0.9rem;
|
|
104
|
-
margin-inline-end: 0.5rem;
|
|
105
109
|
}
|
|
106
|
-
|
|
107
110
|
.value {
|
|
111
|
+
margin-inline-start: 0.5rem;
|
|
108
112
|
width: 2.82rem;
|
|
109
113
|
}
|
|
110
114
|
}
|
|
@@ -116,6 +120,33 @@ class Progress extends LocalizeCoreElement(LitElement) {
|
|
|
116
120
|
progress::-webkit-progress-bar {
|
|
117
121
|
background-color: transparent;
|
|
118
122
|
}
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
:host(:not([value-hidden]):not([value])) .bar {
|
|
126
|
+
margin-bottom: 0.3rem;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
:host(:not([value]):not([label-hidden])),
|
|
130
|
+
:host([value-hidden]:not([label-hidden])) {
|
|
131
|
+
row-gap: 0.3rem;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.indeterminate-bar-container {
|
|
135
|
+
overflow: hidden;
|
|
136
|
+
}
|
|
137
|
+
.indeterminate-bar {
|
|
138
|
+
--d2l-progress-indeterminate-width: calc(100% / 3);
|
|
139
|
+
animation: 1450ms 50ms ease-in-out indeterminateState alternate infinite;
|
|
140
|
+
background-color: var(--d2l-color-celestine);
|
|
141
|
+
height: 100%;
|
|
142
|
+
margin-inline-start: calc(var(--d2l-progress-indeterminate-width) * -0.75);
|
|
143
|
+
width: var(--d2l-progress-indeterminate-width);
|
|
144
|
+
}
|
|
145
|
+
@keyframes indeterminateState {
|
|
146
|
+
100% {
|
|
147
|
+
margin-inline-start: calc(100% - var(--d2l-progress-indeterminate-width) * 0.25);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
119
150
|
`,
|
|
120
151
|
/* comma separating the selectors for these pseudo-elements causes them to break */
|
|
121
152
|
/* note: unable to get firefox to animate the width... seems animation is not implemented for progress in FF */
|
|
@@ -127,9 +158,14 @@ class Progress extends LocalizeCoreElement(LitElement) {
|
|
|
127
158
|
transition: width 0.4s ease-out;
|
|
128
159
|
}
|
|
129
160
|
/* these are necessary to avoid showing border when value is 0 */
|
|
161
|
+
progress:not([value])::${unsafeCSS(selector)},
|
|
130
162
|
progress[value="0"]::${unsafeCSS(selector)} {
|
|
131
163
|
border: none;
|
|
132
164
|
}
|
|
165
|
+
|
|
166
|
+
progress:not([value])::${unsafeCSS(selector)} {
|
|
167
|
+
transition: none;
|
|
168
|
+
}
|
|
133
169
|
@media (prefers-reduced-motion: reduce) {
|
|
134
170
|
progress::${unsafeCSS(selector)} {
|
|
135
171
|
transition: none;
|
|
@@ -145,7 +181,6 @@ class Progress extends LocalizeCoreElement(LitElement) {
|
|
|
145
181
|
this.labelHidden = false;
|
|
146
182
|
this.max = 100;
|
|
147
183
|
this.size = 'medium';
|
|
148
|
-
this.value = 0;
|
|
149
184
|
this.valueHidden = false;
|
|
150
185
|
}
|
|
151
186
|
|
|
@@ -155,26 +190,33 @@ class Progress extends LocalizeCoreElement(LitElement) {
|
|
|
155
190
|
|
|
156
191
|
render() {
|
|
157
192
|
const classes = {
|
|
158
|
-
'complete': this.isComplete
|
|
193
|
+
'complete': this.isComplete,
|
|
194
|
+
'bar': true
|
|
159
195
|
};
|
|
160
196
|
const textClasses = {
|
|
161
197
|
'd2l-body-small': this.size === 'small',
|
|
162
198
|
'd2l-body-compact': this.size === 'medium'
|
|
163
199
|
};
|
|
164
200
|
const valueClasses = { ...textClasses, value: true };
|
|
201
|
+
const isIndeterminate = this.value === undefined;
|
|
165
202
|
|
|
166
|
-
const percentageText = formatPercent(this.isComplete ? 1 : Math.floor(100 * this.value / this.max) / 100);
|
|
203
|
+
const percentageText = isIndeterminate ? undefined : formatPercent(this.isComplete ? 1 : Math.floor(100 * this.value / this.max) / 100);
|
|
167
204
|
return html`
|
|
168
205
|
<div aria-live=${this.announceLabel ? 'polite' : 'off'} ?hidden=${this.labelHidden} id="label" class=${classMap(textClasses)}>${this.label}</div>
|
|
169
206
|
<progress
|
|
170
207
|
aria-labelledby="${ifDefined(this.labelHidden ? undefined : 'label')}"
|
|
171
208
|
aria-label="${ifDefined(this.labelHidden ? this.label : undefined)}"
|
|
172
|
-
aria-valuetext="${percentageText}"
|
|
209
|
+
aria-valuetext="${ifDefined(percentageText)}"
|
|
173
210
|
class="${classMap(classes)}"
|
|
174
|
-
value="${this.value}"
|
|
211
|
+
value="${ifDefined(this.value)}"
|
|
175
212
|
max="${this.max}">
|
|
176
213
|
</progress>
|
|
177
|
-
|
|
214
|
+
${isIndeterminate ? html`
|
|
215
|
+
<div class="indeterminate-bar-container bar">
|
|
216
|
+
<div class="indeterminate-bar bar"></div>
|
|
217
|
+
</div>
|
|
218
|
+
` : nothing}
|
|
219
|
+
<div ?hidden=${this.valueHidden || isIndeterminate} class=${classMap(valueClasses)}>${percentageText}</div>
|
|
178
220
|
`;
|
|
179
221
|
}
|
|
180
222
|
|
package/custom-elements.json
CHANGED
|
@@ -12389,6 +12389,11 @@
|
|
|
12389
12389
|
"name": "d2l-progress",
|
|
12390
12390
|
"path": "./components/progress/progress.js",
|
|
12391
12391
|
"attributes": [
|
|
12392
|
+
{
|
|
12393
|
+
"name": "value",
|
|
12394
|
+
"description": "The current value of the progress bar",
|
|
12395
|
+
"type": "number"
|
|
12396
|
+
},
|
|
12392
12397
|
{
|
|
12393
12398
|
"name": "label",
|
|
12394
12399
|
"description": "REQUIRED: Label for the progress bar",
|
|
@@ -12418,12 +12423,6 @@
|
|
|
12418
12423
|
"type": "'small'|'medium'|'large'",
|
|
12419
12424
|
"default": "\"medium\""
|
|
12420
12425
|
},
|
|
12421
|
-
{
|
|
12422
|
-
"name": "value",
|
|
12423
|
-
"description": "The current value of the progress bar",
|
|
12424
|
-
"type": "number",
|
|
12425
|
-
"default": "0"
|
|
12426
|
-
},
|
|
12427
12426
|
{
|
|
12428
12427
|
"name": "value-hidden",
|
|
12429
12428
|
"description": "Hide the bar's value",
|
|
@@ -12432,6 +12431,12 @@
|
|
|
12432
12431
|
}
|
|
12433
12432
|
],
|
|
12434
12433
|
"properties": [
|
|
12434
|
+
{
|
|
12435
|
+
"name": "value",
|
|
12436
|
+
"attribute": "value",
|
|
12437
|
+
"description": "The current value of the progress bar",
|
|
12438
|
+
"type": "number"
|
|
12439
|
+
},
|
|
12435
12440
|
{
|
|
12436
12441
|
"name": "label",
|
|
12437
12442
|
"attribute": "label",
|
|
@@ -12470,13 +12475,6 @@
|
|
|
12470
12475
|
"type": "'small'|'medium'|'large'",
|
|
12471
12476
|
"default": "\"medium\""
|
|
12472
12477
|
},
|
|
12473
|
-
{
|
|
12474
|
-
"name": "value",
|
|
12475
|
-
"attribute": "value",
|
|
12476
|
-
"description": "The current value of the progress bar",
|
|
12477
|
-
"type": "number",
|
|
12478
|
-
"default": "0"
|
|
12479
|
-
},
|
|
12480
12478
|
{
|
|
12481
12479
|
"name": "valueHidden",
|
|
12482
12480
|
"attribute": "value-hidden",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@brightspace-ui/core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.209.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",
|