-
Notifications
You must be signed in to change notification settings - Fork 904
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
5 changed files
with
99 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/** | ||
* @license | ||
* Copyright 2023 Google LLC | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
import {html, LitElement, nothing, TemplateResult} from 'lit'; | ||
import {property} from 'lit/decorators.js'; | ||
import {classMap} from 'lit/directives/class-map.js'; | ||
|
||
import {ARIAMixinStrict} from '../../internal/aria/aria.js'; | ||
import {requestUpdateOnAriaChange} from '../../internal/aria/delegate.js'; | ||
|
||
/** | ||
* A progress component. | ||
*/ | ||
export abstract class Progress extends LitElement { | ||
static { | ||
requestUpdateOnAriaChange(this); | ||
} | ||
|
||
/** | ||
* Progress to display, a fraction between 0 and 1. | ||
*/ | ||
@property({type: Number}) progress = 0; | ||
|
||
/** | ||
* Whether or not to display indeterminate progress, which gives no indication | ||
* to how long an activity will take. | ||
*/ | ||
@property({type: Boolean}) indeterminate = false; | ||
|
||
/** | ||
* Whether or not to render indeterminate mode using 4 colors instead of one. | ||
*/ | ||
@property({type: Boolean, attribute: 'four-color'}) fourColor = false; | ||
|
||
protected override render() { | ||
// Needed for closure conformance | ||
const {ariaLabel} = this as ARIAMixinStrict; | ||
return html` | ||
<div class="progress ${classMap(this.getRenderClasses())}" | ||
role="progressbar" | ||
aria-label="${ariaLabel || nothing}" | ||
aria-valuemin="0" | ||
aria-valuemax="1" | ||
aria-valuenow=${this.indeterminate ? nothing : this.progress} | ||
>${this.renderIndicator()}</div> | ||
`; | ||
} | ||
|
||
protected getRenderClasses() { | ||
return { | ||
'indeterminate': this.indeterminate, | ||
'four-color': this.fourColor, | ||
}; | ||
} | ||
|
||
protected abstract renderIndicator(): TemplateResult; | ||
} |