Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Commit 1cd0108

Browse files
allan-chencopybara-github
authored andcommitted
Add common interface for progress indicators
FUTURE_COPYBARA_INTEGRATE_REVIEW=#5493 from jony666666:master 6a56491 PiperOrigin-RevId: 293228410
1 parent 4c7154b commit 1cd0108

File tree

7 files changed

+173
-2
lines changed

7 files changed

+173
-2
lines changed

packages/mdc-linear-progress/component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@
2222
*/
2323

2424
import {MDCComponent} from '@material/base/component';
25+
import {MDCProgressIndicator} from '@material/progress-indicator/component';
2526
import {MDCLinearProgressAdapter} from './adapter';
2627
import {MDCLinearProgressFoundation} from './foundation';
2728

28-
export class MDCLinearProgress extends MDCComponent<MDCLinearProgressFoundation> {
29+
export class MDCLinearProgress extends
30+
MDCComponent<MDCLinearProgressFoundation> implements MDCProgressIndicator {
2931
static attachTo(root: Element) {
3032
return new MDCLinearProgress(root);
3133
}

packages/mdc-linear-progress/foundation.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,13 @@
2323

2424
import {getCorrectPropertyName} from '@material/animation/util';
2525
import {MDCFoundation} from '@material/base/foundation';
26+
import {MDCProgressIndicatorFoundation} from '@material/progress-indicator/foundation';
2627
import {MDCLinearProgressAdapter} from './adapter';
2728
import {cssClasses, strings} from './constants';
2829

29-
export class MDCLinearProgressFoundation extends MDCFoundation<MDCLinearProgressAdapter> {
30+
export class MDCLinearProgressFoundation extends
31+
MDCFoundation<MDCLinearProgressAdapter> implements
32+
MDCProgressIndicatorFoundation {
3033
static get cssClasses() {
3134
return cssClasses;
3235
}

packages/mdc-linear-progress/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"@material/animation": "^4.0.0",
2222
"@material/base": "^4.0.0",
2323
"@material/feature-targeting": "^4.0.0",
24+
"@material/progress-indicator": "^4.0.0",
2425
"@material/theme": "^4.0.0",
2526
"tslib": "^1.9.3"
2627
},
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<!--docs:
2+
title: "Progress Indicator"
3+
layout: detail
4+
section: components
5+
excerpt: "Material Design-styled progress indicators."
6+
iconId: progress_linear
7+
path: /catalog/progress-indicator/
8+
-->
9+
10+
# Progress Indicators
11+
The MDC Progress Indicator component exposes common foundation and component interfaces for a progress indicator. Components that implement these interfaces include [linear progress](https://github.com/material-components/material-components-web/tree/master/packages/mdc-linear-progress) and circular progress (WIP).
12+
[Material Design progress & activity requirements](https://material.io/go/design-progress-indicators).
13+
14+
## Installation
15+
16+
```
17+
npm install @material/progress-indicator
18+
```
19+
20+
## Basic Usage
21+
22+
### MDCProgressIndicatorFoundation API
23+
24+
MDC Progress Indicator Foundation exposes the following methods:
25+
26+
| Method Signature | Description |
27+
| --- | --- |
28+
| `setDeterminate(value: boolean) => void` | Toggles the component between the determinate and indeterminate state. |
29+
| `setProgress(value: number) => void` | Sets the progress to this value. Value should be between [0, 1]. |
30+
| `open() => void` | Puts the component in the open state. |
31+
| `close() => void` | Puts the component in the closed state. |
32+
33+
### MDCProgressIndicator Component API
34+
35+
MDC Progress Indicator exposes the following API:
36+
37+
| Method Signature | Description |
38+
| --- | --- |
39+
| `determinate: boolean` | Whether the indicator is in the determinate or indeterminate state. |
40+
| `progress: number` | The current progress. Value should be between [0, 1]. |
41+
| `open() => void` | Puts the component in the open state. |
42+
| `close() => void` | Puts the component in the closed state. |
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/**
2+
* @license
3+
* Copyright 2020 Google Inc.
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy
6+
* of this software and associated documentation files (the "Software"), to deal
7+
* in the Software without restriction, including without limitation the rights
8+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
* copies of the Software, and to permit persons to whom the Software is
10+
* furnished to do so, subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in
13+
* all copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
* THE SOFTWARE.
22+
*/
23+
24+
/**
25+
* The interface for MDC's progress indicators.
26+
*
27+
* @public
28+
*/
29+
export interface MDCProgressIndicator {
30+
/**
31+
* Toggles the component between the determinate and indeterminate state.
32+
*/
33+
determinate: boolean;
34+
35+
/**
36+
* The current progress value. Value should be between [0, 1].
37+
*/
38+
progress: number;
39+
40+
/**
41+
* Puts the component in the open state.
42+
*/
43+
open(): void;
44+
45+
/**
46+
* Puts the component in the closed state.
47+
*/
48+
close(): void;
49+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/**
2+
* @license
3+
* Copyright 2020 Google Inc.
4+
*
5+
* Permission is hereby granted, free of charge, to any person obtaining a copy
6+
* of this software and associated documentation files (the "Software"), to deal
7+
* in the Software without restriction, including without limitation the rights
8+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
* copies of the Software, and to permit persons to whom the Software is
10+
* furnished to do so, subject to the following conditions:
11+
*
12+
* The above copyright notice and this permission notice shall be included in
13+
* all copies or substantial portions of the Software.
14+
*
15+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
* THE SOFTWARE.
22+
*/
23+
24+
/**
25+
* The interface for the foundation of MDC's progress indicators.
26+
*
27+
* @public
28+
*/
29+
export interface MDCProgressIndicatorFoundation {
30+
/**
31+
* Toggles the component between the determinate and indeterminate state.
32+
*
33+
* @param isDeterminate - Whether the component is in determinate state
34+
*/
35+
setDeterminate(isDeterminate: boolean): void;
36+
37+
/**
38+
* Sets the current progress value.
39+
*
40+
* @param value - the current progress value, should be between [0,1]
41+
*/
42+
setProgress(value: number): void;
43+
44+
/**
45+
* Puts the component in the open state.
46+
*/
47+
open(): void;
48+
49+
/**
50+
* Puts the component in the closed state.
51+
*/
52+
close(): void;
53+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "@material/progress-indicator",
3+
"description": "The Material Components for the web interface for Progress Indicators",
4+
"version": "4.0.0",
5+
"license": "MIT",
6+
"main": "dist/mdc.progressIndicator.js",
7+
"module": "index.js",
8+
"sideEffects": false,
9+
"types": "dist/mdc.progressIndicator.d.ts",
10+
"repository": {
11+
"type": "git",
12+
"url": "https://github.com/material-components/material-components-web.git",
13+
"directory": "packages/mdc-progress-indicator"
14+
},
15+
"dependencies": {
16+
"tslib": "^1.9.3"
17+
},
18+
"publishConfig": {
19+
"access": "public"
20+
}
21+
}

0 commit comments

Comments
 (0)