Skip to content

Commit eda65bb

Browse files
committed
add user documantation README
1 parent dfbda93 commit eda65bb

File tree

3 files changed

+89
-3
lines changed

3 files changed

+89
-3
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
This is prototype of an alternate version of `<mat-progress-spinner>` built on top of
2+
[MDC Web](https://github.com/material-components/material-components-web). It demonstrates how
3+
Angular Material could use MDC Web under the hood while still exposing the same API Angular users as
4+
the existing `<mat-progress-spinner>`. This component is experimental and should not be used in
5+
production.
6+
7+
## How to use
8+
Assuming your application is already up and running using Angular Material, you can add this
9+
component by following these steps:
10+
11+
1. Install Angular Material Experimental & MDC WEB:
12+
13+
```bash
14+
npm i material-components-web @angular/material-experimental
15+
```
16+
17+
2. In your `angular.json`, make sure `node_modules/` is listed as a Sass include path. This is
18+
needed for the Sass compiler to be able to find the MDC Web Sass files.
19+
20+
```json
21+
...
22+
"styles": [
23+
"src/styles.scss"
24+
],
25+
"stylePreprocessorOptions": {
26+
"includePaths": [
27+
"node_modules/"
28+
]
29+
},
30+
...
31+
```
32+
33+
3. Import the experimental `MatProgressSpinnerModule` and add it to the module that declares your
34+
component:
35+
36+
```ts
37+
import {MatProgressSpinnerModule} from '@angular/material-experimental/mdc-progress-spinner';
38+
39+
@NgModule({
40+
declarations: [MyComponent],
41+
imports: [MatProgressSpinnerModule],
42+
})
43+
export class MyModule {}
44+
```
45+
46+
4. Add use `<mat-progress-spinner>` in your component's template, just like you would the normal
47+
`<mat-progress-spinner>`:
48+
49+
```html
50+
<mat-progress-spinner [value]="42"></mat-progress-spinner>
51+
```
52+
53+
5. Add the theme and typography mixins to your Sass. (There is currently no pre-built CSS option for
54+
the experimental `<mat-progress-spinner>`):
55+
56+
```scss
57+
@import '~@angular/material/theming';
58+
@import '~@angular/material-experimental/mdc-progress-spinner';
59+
60+
$my-primary: mat-palette($mat-indigo);
61+
$my-accent: mat-palette($mat-pink, A200, A100, A400);
62+
$my-theme: mat-light-theme((
63+
color: (
64+
primary: $my-primary,
65+
accent: $my-accent
66+
)
67+
));
68+
69+
@include mat-mdc-progress-spinner-theme($my-theme);
70+
@include mat-mdc-progress-spinner-typography();
71+
```
72+
73+
## Replacing the standard progress spinner in an existing app
74+
Because the experimental API mirrors the API for the standard progress spinner, it can easily be swapped
75+
in by just changing the import paths. There is currently no schematic for this, but you can run the
76+
following string replace across your TypeScript files:
77+
78+
```bash
79+
grep -lr --include="*.ts" --exclude-dir="node_modules" \
80+
--exclude="*.d.ts" "['\"]@angular/material/progress-spinner['\"]" | xargs sed -i \
81+
"s/['\"]@angular\/material\/progress-spinner['\"]/'@angular\/material-experimental\/mdc-progress-spinner'/g"
82+
```
83+
84+
CSS styles and tests that depend on implementation details of mat-progress-spinner (such as getting
85+
elements from the template by class name) will need to be manually updated.
86+
87+
There are some small visual differences between this progress and the standard `mat-progress-spinner`.
88+
This progress spinner has slightly different animation timings and easing curves.

src/material-experimental/mdc-progress-spinner/progress-spinner.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
cx="50%" cy="50%"/>
2121
</svg>
2222
</div>
23+
<!--TODO: figure out why there are 3 separate svgs-->
2324
<div class="mdc-circular-progress__indeterminate-container">
2425
<div class="mdc-circular-progress__spinner-layer">
2526
<div class="mdc-circular-progress__circle-clipper mdc-circular-progress__circle-left">

src/material-experimental/mdc-progress-spinner/progress-spinner.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,6 @@ export class MatProgressSpinner extends _MatProgressSpinnerMixinBase implements
8181
/** Implements all of the logic of the MDC circular progress. */
8282
_foundation: MDCCircularProgressFoundation;
8383

84-
/** Root element of MDCCircularProgress. */
85-
// @ViewChild('spinnerRoot') _elementRef: ElementRef<HTMLElement>;
86-
8784
/** The element of the determinate spinner. */
8885
@ViewChild('determinateSpinner') _determinateCircle: ElementRef<HTMLElement>;
8986

0 commit comments

Comments
 (0)