forked from andreasbm/weightless
-
Notifications
You must be signed in to change notification settings - Fork 0
/
progress-bar.ts
48 lines (43 loc) · 1.67 KB
/
progress-bar.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import { customElement, html, TemplateResult } from "lit-element";
import { IProgressBehaviorProperties, ProgressBehavior, ProgressMode } from "../behavior/progress/progress-behavior";
import { cssResult } from "../util/css";
import styles from "./progress-bar.scss";
/**
* Properties of the progress bar.
*/
export interface IProgressBarProperties extends IProgressBehaviorProperties {
}
/**
* Fills a bar from 0% to 100%.
* @cssprop --progress-bar-height - Height
* @cssprop --progress-bar-bg - Background
* @cssprop --progress-bar-color - Color
* @cssprop --progress-bar-buffer-color - Color of the buffer
* @cssprop --progress-bar-determinate-transition - Transition when determinate
* @cssprop --progress-bar-indeterminate-duration - Duration of the indeterminate animation
* @cssprop --progress-bar-indeterminate-short-delay - Delay of the short bar of indeterminate animation
* @cssprop --progress-bar-indeterminate-timing-function - Timing function of the indeterminate animation
*/
@customElement("wl-progress-bar")
export class ProgressBar extends ProgressBehavior implements IProgressBarProperties {
static styles = [...ProgressBehavior.styles, cssResult(styles)];
/**
* Returns the template for the element.
*/
protected render (): TemplateResult {
return html`
${this.bufferPerc > 0 ? html`
<div id="buffer" style="transform: scaleX(${this.bufferPerc})"></div>`
: ""}
<div id="progress" style="${this.mode === ProgressMode.DETERMINATE ? `transform: scaleX(${this.progressPerc})` : ""}">
<div id="before"></div>
<div id="after"></div>
</div>
`;
}
}
declare global {
interface HTMLElementTagNameMap {
"wl-progress-bar": ProgressBar;
}
}