Skip to content

Commit 1a7ef3e

Browse files
committed
remove separate class for MatSpinner
1 parent 019ca3c commit 1a7ef3e

File tree

5 files changed

+16
-44
lines changed

5 files changed

+16
-44
lines changed

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,7 @@ import {CommonModule} from '@angular/common';
1414
@NgModule({
1515
exports: [MatProgressSpinner, MatSpinner, MatCommonModule],
1616
declarations: [MatProgressSpinner, MatSpinner],
17-
imports: [
18-
CommonModule
19-
]
17+
imports: [CommonModule]
2018
})
2119
export class MatProgressSpinnerModule {
2220
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
xmlns="http://www.w3.org/2000/svg" focusable="false">
44
<circle [attr.r]="_circleRadius()"
55
[style.stroke-dasharray.px]="_strokeCircumference()"
6-
[style.stroke-dashoffset.px]="_strokeCircumference()/2"
6+
[style.stroke-dashoffset.px]="_strokeCircumference() / 2"
77
[style.stroke-width.%]="_circleStrokeWidth()"
88
cx="50%" cy="50%"/>
99
</svg>

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
@include mdc-circular-progress-core-styles($query: $mat-base-styles-without-animation-query);
66

77
.mat-mdc-progress-spinner {
8-
display: block;
98

109
.mdc-circular-progress {
10+
// MDC circular spinner sets width and height to 48px by default.
1111
width: 100%;
1212
height: 100%;
1313
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ describe('MDC-based MatProgressSpinner', () => {
287287
fixture.componentInstance.value = 37;
288288
fixture.detectChanges();
289289

290-
expect(progressElement.nativeElement.getAttribute('aria-valuenow')).toBe('37');
290+
expect(progressElement.nativeElement.getAttribute('aria-valuenow')).toBe('0.37');
291291
});
292292

293293
it('should clear `aria-valuenow` in indeterminate mode', () => {

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

Lines changed: 12 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,17 @@ class ProgressSpinnerAdapter implements MDCCircularProgressAdapter {
8787
}
8888

8989
@Component({
90-
selector: 'mat-progress-spinner',
90+
selector: 'mat-progress-spinner, mat-spinner',
9191
exportAs: 'matProgressSpinner',
9292
host: {
9393
'role': 'progressbar',
9494
'class': 'mat-mdc-progress-spinner',
9595
'[class._mat-animation-noopable]': `_noopAnimations`,
9696
'[style.width.px]': 'diameter',
9797
'[style.height.px]': 'diameter',
98-
'[attr.aria-valuemin]': 'mode === "determinate" ? 0 : null',
99-
'[attr.aria-valuemax]': 'mode === "determinate" ? 100 : null',
100-
'[attr.aria-valuenow]': 'mode === "determinate" ? value : null',
98+
'[attr.aria-valuemin]': '0',
99+
'[attr.aria-valuemax]': '1',
100+
'[attr.aria-valuenow]': 'mode === "determinate" ? value / 100 : null',
101101
'[attr.mode]': 'mode',
102102
},
103103
inputs: ['color'],
@@ -108,9 +108,6 @@ class ProgressSpinnerAdapter implements MDCCircularProgressAdapter {
108108
})
109109
export class MatProgressSpinner extends _MatProgressSpinnerMixinBase implements AfterViewInit,
110110
OnDestroy, CanColor {
111-
static ngAcceptInputType_diameter: NumberInput;
112-
static ngAcceptInputType_strokeWidth: NumberInput;
113-
static ngAcceptInputType_value: NumberInput;
114111

115112
/** Whether the _mat-animation-noopable class should be applied, disabling animations. */
116113
_noopAnimations: boolean;
@@ -155,7 +152,8 @@ export class MatProgressSpinner extends _MatProgressSpinnerMixinBase implements
155152
}
156153
}
157154

158-
private _mode: ProgressSpinnerMode = 'determinate';
155+
private _mode: ProgressSpinnerMode = this._elementRef.nativeElement.nodeName.toLowerCase() ===
156+
'mat-spinner' ? 'indeterminate' : 'determinate';
159157

160158
/**
161159
* Mode of the progress bar.
@@ -165,13 +163,9 @@ export class MatProgressSpinner extends _MatProgressSpinnerMixinBase implements
165163
* Mirrored to mode attribute.
166164
*/
167165
@Input()
168-
get mode(): ProgressSpinnerMode {
169-
return this._mode;
170-
}
166+
get mode(): ProgressSpinnerMode { return this._mode; }
171167

172168
set mode(value: ProgressSpinnerMode) {
173-
// Note that we don't technically need a getter and a setter here,
174-
// but we use it to match the behavior of the existing mat-progress-bar.
175169
this._mode = value;
176170
this._syncFoundation();
177171
}
@@ -265,6 +259,10 @@ export class MatProgressSpinner extends _MatProgressSpinnerMixinBase implements
265259
foundation.setDeterminate(mode === 'determinate');
266260
}
267261
}
262+
263+
static ngAcceptInputType_diameter: NumberInput;
264+
static ngAcceptInputType_strokeWidth: NumberInput;
265+
static ngAcceptInputType_value: NumberInput;
268266
}
269267

270268
/**
@@ -273,28 +271,4 @@ export class MatProgressSpinner extends _MatProgressSpinnerMixinBase implements
273271
* This is a component definition to be used as a convenience reference to create an
274272
* indeterminate `<mat-progress-spinner>` instance.
275273
*/
276-
@Component({
277-
selector: 'mat-spinner',
278-
host: {
279-
'role': 'progressbar',
280-
'mode': 'indeterminate',
281-
'class': 'mat-mdc-spinner mat-mdc-progress-spinner',
282-
'[class._mat-animation-noopable]': `_noopAnimations`,
283-
'[style.width.px]': 'diameter',
284-
'[style.height.px]': 'diameter',
285-
},
286-
inputs: ['color'],
287-
templateUrl: 'progress-spinner.html',
288-
styleUrls: ['progress-spinner.css'],
289-
changeDetection: ChangeDetectionStrategy.OnPush,
290-
encapsulation: ViewEncapsulation.None,
291-
})
292-
export class MatSpinner extends MatProgressSpinner {
293-
constructor(elementRef: ElementRef<HTMLElement>,
294-
@Optional() @Inject(ANIMATION_MODULE_TYPE) animationMode: string,
295-
@Inject(MAT_PROGRESS_SPINNER_DEFAULT_OPTIONS)
296-
defaults?: MatProgressSpinnerDefaultOptions) {
297-
super(elementRef, animationMode, defaults);
298-
this.mode = 'indeterminate';
299-
}
300-
}
274+
export {MatProgressSpinner as MatSpinner}

0 commit comments

Comments
 (0)