Skip to content

Commit 0bd626d

Browse files
authored
build: update to latest MDC canary and disable slider (#20054)
Updates to the latest canary version and temporarily disables the MDC-based slider. We have to disable the slider, because MDC have introduced a completely new implementation that will take some work to reintegrate into our current slider and we don't want our CI to fail until then. I went with this approach of disabling the slider where it's basically a no-op, because we can't simply exclude the build target without modifying a ton of shared files which will be hard to clean up once we start to actually implement it.
1 parent 7303780 commit 0bd626d

File tree

9 files changed

+637
-666
lines changed

9 files changed

+637
-666
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"@types/youtube": "^0.0.38",
6060
"@webcomponents/custom-elements": "^1.1.0",
6161
"core-js": "^2.6.9",
62-
"material-components-web": "8.0.0-canary.d850de590.0",
62+
"material-components-web": "8.0.0-canary.abcdbcfeb.0",
6363
"rxjs": "^6.5.3",
6464
"rxjs-tslint-rules": "^4.33.1",
6565
"systemjs": "0.19.43",

src/material-experimental/mdc-slider/_slider-theme.scss

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
1+
// TODO: disabled until we implement the new MDC slider.
2+
// @import '@material/slider/mixins.import';
13
@import '../mdc-helpers/mdc-helpers';
2-
@import '@material/slider/mixins.import';
34

45
@mixin mat-mdc-slider-color($config-or-theme) {
56
$config: mat-get-color-config($config-or-theme);
67
@include mat-using-mdc-theme($config) {
7-
@include mdc-slider-core-styles($query: $mat-theme-styles-query);
8+
// TODO: disabled until we implement the new MDC slider.
9+
// @include mdc-slider-core-styles($query: $mat-theme-styles-query);
810

911
.mat-mdc-slider {
1012
&.mat-primary {
11-
@include mdc-slider-color-accessible(primary, $mat-theme-styles-query);
13+
// TODO: disabled until we implement the new MDC slider.
14+
// @include mdc-slider-color-accessible(primary, $mat-theme-styles-query);
1215
}
1316

1417
&.mat-warn {
15-
@include mdc-slider-color-accessible(error, $mat-theme-styles-query);
18+
// TODO: disabled until we implement the new MDC slider.
19+
// @include mdc-slider-color-accessible(error, $mat-theme-styles-query);
1620
}
1721
}
1822
}
@@ -21,7 +25,8 @@
2125
@mixin mat-mdc-slider-typography($config-or-theme) {
2226
$config: mat-get-typography-config($config-or-theme);
2327
@include mat-using-mdc-typography($config) {
24-
@include mdc-slider-core-styles($query: $mat-typography-styles-query);
28+
// TODO: disabled until we implement the new MDC slider.
29+
// @include mdc-slider-core-styles($query: $mat-typography-styles-query);
2530
}
2631
}
2732

src/material-experimental/mdc-slider/slider.e2e.spec.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import {browser, by, element} from 'protractor';
22

3-
describe('mat-slider', () => {
3+
// TODO: disabled until we implement the new MDC slider.
4+
describe('mat-slider dummy' , () => it('', () => {}));
45

6+
// tslint:disable-next-line:ban
7+
xdescribe('mat-slider', () => {
58
beforeEach(async () => await browser.get('/mdc-slider'));
69

710
it('should show a slider', async () => {
Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1 @@
1-
<div class="mdc-slider__track-container">
2-
<div class="mdc-slider__track" #track></div>
3-
<div class="mdc-slider__track-marker-container" #trackMarker></div>
4-
</div>
5-
<div class="mdc-slider__thumb-container" #thumbContainer>
6-
<div *ngIf="thumbLabel" class="mdc-slider__pin">
7-
<span class="mdc-slider__pin-value-marker">{{displayValue}}</span>
8-
</div>
9-
<svg class="mdc-slider__thumb" focusable="false" width="21" height="21">
10-
<circle cx="10.5" cy="10.5" r="7.875"></circle>
11-
</svg>
12-
<div class="mdc-slider__focus-ring"></div>
13-
</div>
1+
<!-- TODO: to be implemented as a part of the new MDC slider -->

src/material-experimental/mdc-slider/slider.scss

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
@import '@material/slider/mixins.import';
1+
// TODO: disabled until we implement the new MDC slider.
2+
// @import '@material/slider/mixins.import';
23
@import '../mdc-helpers/mdc-helpers';
34
@import '../../cdk/a11y/a11y';
45

56
$mat-slider-min-size: 128px !default;
67
$mat-slider-horizontal-margin: 8px !default;
78

8-
@include mdc-slider-core-styles($query: $mat-base-styles-without-animation-query);
9+
// TODO: disabled until we implement the new MDC slider.
10+
// @include mdc-slider-core-styles($query: $mat-base-styles-without-animation-query);
911

1012
// Overwrites the mdc-slider default styles to match the visual appearance of the
1113
// Angular Material standard slider. This involves making the slider an inline-block
@@ -45,7 +47,8 @@ $mat-slider-horizontal-margin: 8px !default;
4547
// In order to make it possible for developers to disable animations for a slider,
4648
// we only activate the MDC slider animation styles if animations are enabled.
4749
.mat-mdc-slider:not(._mat-animation-noopable) {
48-
@include mdc-slider-core-styles($query: animation);
50+
// TODO: disabled until we implement the new MDC slider.
51+
// @include mdc-slider-core-styles($query: animation);
4952
}
5053

5154
// Sliders without a thumb label (aka non-discrete) currently cannot have ticks

src/material-experimental/mdc-slider/slider.spec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@ import {By} from '@angular/platform-browser';
2727
import {NoopAnimationsModule} from '@angular/platform-browser/animations';
2828
import {MatSlider, MatSliderModule} from './index';
2929

30-
describe('MDC-based MatSlider', () => {
30+
// TODO: disabled until we implement the new MDC slider.
31+
describe('MDC-based MatSlider dummy' , () => it('', () => {}));
32+
33+
// tslint:disable-next-line:ban
34+
xdescribe('MDC-based MatSlider', () => {
3135
function createComponent<T>(component: Type<T>): ComponentFixture<T> {
3236
TestBed.configureTestingModule({
3337
imports: [

src/material-experimental/mdc-slider/slider.ts

Lines changed: 52 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import {
1818
AfterViewInit,
1919
Attribute,
2020
ChangeDetectionStrategy,
21-
ChangeDetectorRef,
2221
Component,
2322
ElementRef,
2423
EventEmitter,
@@ -37,7 +36,7 @@ import {
3736
import {ControlValueAccessor, NG_VALUE_ACCESSOR} from '@angular/forms';
3837
import {ThemePalette} from '@angular/material/core';
3938
import {ANIMATION_MODULE_TYPE} from '@angular/platform-browser/animations';
40-
import {MDCSliderAdapter, MDCSliderFoundation} from '@material/slider';
39+
import {MDCSliderAdapter, MDCSliderFoundation, Thumb} from '@material/slider';
4140
import {Subscription} from 'rxjs';
4241

4342
/**
@@ -53,10 +52,14 @@ const MIN_AUTO_TICK_SEPARATION = 30;
5352
*/
5453
const TICK_MARKER_SIZE = 2;
5554

55+
// TODO: disabled until we implement the new MDC slider.
5656
/** Event options used to bind passive listeners. */
57+
// tslint:disable-next-line:no-unused-variable
5758
const passiveListenerOptions = normalizePassiveListenerOptions({passive: true});
5859

60+
// TODO: disabled until we implement the new MDC slider.
5961
/** Event options used to bind active listeners. */
62+
// tslint:disable-next-line:no-unused-variable
6063
const activeListenerOptions = normalizePassiveListenerOptions({passive: false});
6164

6265
/**
@@ -222,87 +225,35 @@ export class MatSlider implements AfterViewInit, OnChanges, OnDestroy, ControlVa
222225

223226
/** Adapter for the MDC slider foundation. */
224227
private _sliderAdapter: MDCSliderAdapter = {
225-
hasClass: (className) => this._elementRef.nativeElement.classList.contains(className),
226-
addClass: (className) => this._elementRef.nativeElement.classList.add(className),
227-
removeClass: (className) => this._elementRef.nativeElement.classList.remove(className),
228-
getAttribute: (name) => this._elementRef.nativeElement.getAttribute(name),
229-
setAttribute: (name, value) => this._elementRef.nativeElement.setAttribute(name, value),
230-
removeAttribute: (name) => this._elementRef.nativeElement.removeAttribute(name),
231-
computeBoundingRect: () => this._elementRef.nativeElement.getBoundingClientRect(),
232-
getTabIndex: () => this._elementRef.nativeElement.tabIndex,
233-
registerInteractionHandler: (evtType, handler) =>
234-
// Interaction event handlers (which handle keyboard interaction) cannot be passive
235-
// as they will prevent the default behavior. Additionally we can't run these event
236-
// handlers outside of the Angular zone because we rely on the events to cause the
237-
// component tree to be re-checked.
238-
// TODO: take in the event listener options from the adapter once MDC supports it.
239-
this._elementRef.nativeElement.addEventListener(evtType, handler, activeListenerOptions),
240-
deregisterInteractionHandler: (evtType, handler) =>
241-
this._elementRef.nativeElement.removeEventListener(evtType, handler),
242-
registerThumbContainerInteractionHandler: (evtType, handler) => {
243-
// The thumb container interaction handlers are currently just used for transition
244-
// events which don't need to run in the Angular zone.
245-
this._ngZone.runOutsideAngular(() => {
246-
this._thumbContainer.nativeElement
247-
.addEventListener(evtType, handler, passiveListenerOptions);
248-
});
249-
},
250-
deregisterThumbContainerInteractionHandler: (evtType, handler) => {
251-
this._thumbContainer.nativeElement
252-
.removeEventListener(evtType, handler, passiveListenerOptions);
253-
},
254-
registerBodyInteractionHandler: (evtType, handler) =>
255-
// Body event handlers (which handle thumb sliding) cannot be passive as they will
256-
// prevent the default behavior. Additionally we can't run these event handlers
257-
// outside of the Angular zone because we rely on the events to cause the component
258-
// tree to be re-checked.
259-
document.body.addEventListener(evtType, handler),
260-
deregisterBodyInteractionHandler: (evtType, handler) =>
261-
document.body.removeEventListener(evtType, handler),
262-
registerResizeHandler: (handler) => {
263-
// The resize handler is currently responsible for detecting slider dimension
264-
// changes and therefore doesn't cause a value change that needs to be propagated.
265-
this._ngZone.runOutsideAngular(() => window.addEventListener('resize', handler));
266-
},
267-
deregisterResizeHandler: (handler) => window.removeEventListener('resize', handler),
268-
notifyInput:
269-
() => {
270-
const newValue = this._foundation.getValue();
271-
// MDC currently fires the input event multiple times.
272-
// TODO(devversion): remove this check once the input notifications are fixed.
273-
if (newValue !== this.value) {
274-
this.value = newValue;
275-
this.input.emit(this._createChangeEvent(newValue));
276-
}
277-
},
278-
notifyChange:
279-
() => {
280-
// TODO(devversion): bug in MDC where only the "change" event is emitted if a keypress
281-
// updated the value. Material and native range sliders also emit an input event.
282-
// Usually we sync the "value" in the "input" event, but as a workaround we now sync
283-
// the value in the "change" event.
284-
this.value = this._foundation.getValue();
285-
this._emitChangeEvent(this.value!);
286-
},
287-
setThumbContainerStyleProperty:
288-
(propertyName, value) => {
289-
this._thumbContainer.nativeElement.style.setProperty(propertyName, value);
290-
},
291-
setTrackStyleProperty:
292-
(propertyName, value) => {
293-
this._track.nativeElement.style.setProperty(propertyName, value);
294-
},
295-
setMarkerValue:
296-
() => {
297-
// Mark the component for check as the thumb label needs to be re-rendered.
298-
this._changeDetectorRef.markForCheck();
299-
},
300-
setTrackMarkers:
301-
(step, max, min) => {
302-
this._trackMarker.nativeElement.style.setProperty(
303-
'background', this._getTrackMarkersBackground(min, max, step));
304-
},
305-
isRTL: () => this._isRtl(),
228+
hasClass: (_className: string) => false,
229+
addClass: (_className: string) => {},
230+
removeClass: (_className: string) => {},
231+
getAttribute: (_attribute: string) => null,
232+
addThumbClass: (_className: string, _thumb: Thumb) => {},
233+
removeThumbClass: (_className: string, _thumb: Thumb) => {},
234+
getThumbAttribute: (_attribute: string, _thumb: Thumb) => null,
235+
setThumbAttribute: (_attribute: string, _value: string, _thumb: Thumb) => {},
236+
getThumbKnobWidth: (_thumb: Thumb) => 0,
237+
isThumbFocused: (_thumb: Thumb) => false,
238+
focusThumb: (_thumb: Thumb) => {},
239+
getThumbBoundingClientRect: (_thumb: Thumb) => null!,
240+
getBoundingClientRect: () => null!,
241+
isRTL: () => false,
242+
setThumbStyleProperty: (_propertyName: string, _value: string, _thumb: Thumb) => {},
243+
setTrackActiveStyleProperty: (_propertyName: string, _value: string) => {},
244+
setValueIndicatorText: (_value: number, _thumb: Thumb) => {},
245+
updateTickMarks: () => {},
246+
setPointerCapture: (_pointerId: number) => {},
247+
emitChangeEvent: (_value: number, _thumb: Thumb) => {},
248+
emitInputEvent: (_value: number, _thumb: Thumb) => {},
249+
registerEventHandler: () => {},
250+
deregisterEventHandler: () => {},
251+
registerThumbEventHandler: () => {},
252+
deregisterThumbEventHandler: () => {},
253+
registerBodyEventHandler: () => {},
254+
deregisterBodyEventHandler: () => {},
255+
registerWindowEventHandler: () => {},
256+
deregisterWindowEventHandler: () => {},
306257
};
307258

308259
/** Instance of the MDC slider foundation for this slider. */
@@ -327,7 +278,6 @@ export class MatSlider implements AfterViewInit, OnChanges, OnDestroy, ControlVa
327278

328279
constructor(
329280
private _elementRef: ElementRef<HTMLElement>,
330-
private _changeDetectorRef: ChangeDetectorRef,
331281
private _ngZone: NgZone,
332282
private _platform: Platform,
333283
@Optional() private _dir: Directionality,
@@ -354,7 +304,7 @@ export class MatSlider implements AfterViewInit, OnChanges, OnDestroy, ControlVa
354304
// The MDC slider foundation accesses DOM globals, so we cannot initialize the
355305
// foundation on the server. The foundation would be needed to move the thumb
356306
// to the proper position and to render the ticks.
357-
this._foundation.init();
307+
// this._foundation.init();
358308

359309
// The standard Angular Material slider is always using discrete values. We always
360310
// want to enable discrete values and support ticks, but want to still provide
@@ -437,14 +387,18 @@ export class MatSlider implements AfterViewInit, OnChanges, OnDestroy, ControlVa
437387
return event;
438388
}
439389

390+
// TODO: disabled until we implement the new MDC slider.
440391
/** Emits a change event and notifies the control value accessor. */
392+
// tslint:disable-next-line:no-unused-variable
441393
private _emitChangeEvent(newValue: number) {
442394
this._controlValueAccessorChangeFn(newValue);
443395
this.valueChange.emit(newValue);
444396
this.change.emit(this._createChangeEvent(newValue));
445397
}
446398

399+
// TODO: disabled until we implement the new MDC slider.
447400
/** Computes the CSS background value for the track markers (aka ticks). */
401+
// tslint:disable-next-line:no-unused-variable
448402
private _getTrackMarkersBackground(min: number, max: number, step: number) {
449403
if (!this.tickInterval) {
450404
return '';
@@ -476,32 +430,39 @@ export class MatSlider implements AfterViewInit, OnChanges, OnDestroy, ControlVa
476430
// the markers dynamically. This is a workaround until we can get a public API for it. See:
477431
// https://github.com/material-components/material-components-web/issues/5020
478432
(this._foundation as any).hasTrackMarker_ = this.tickInterval !== 0;
479-
this._foundation.setupTrackMarker();
433+
434+
// TODO: disabled until we implement the new MDC slider.
435+
// this._foundation.setupTrackMarker();
480436
}
481437

482438
/** Syncs the "step" input value with the MDC foundation. */
483439
private _syncStep() {
484-
this._foundation.setStep(this.step);
440+
// TODO: disabled until we implement the new MDC slider.
441+
// this._foundation.setStep(this.step);
485442
}
486443

487444
/** Syncs the "max" input value with the MDC foundation. */
488445
private _syncMax() {
489-
this._foundation.setMax(this.max);
446+
// TODO: disabled until we implement the new MDC slider.
447+
// this._foundation.setMax(this.max);
490448
}
491449

492450
/** Syncs the "min" input value with the MDC foundation. */
493451
private _syncMin() {
494-
this._foundation.setMin(this.min);
452+
// TODO: disabled until we implement the new MDC slider.
453+
// this._foundation.setMin(this.min);
495454
}
496455

497456
/** Syncs the "value" input binding with the MDC foundation. */
498457
private _syncValue() {
499-
this._foundation.setValue(this.value!);
458+
// TODO: disabled until we implement the new MDC slider.
459+
// this._foundation.setValue(this.value!);
500460
}
501461

502462
/** Syncs the "disabled" input value with the MDC foundation. */
503463
private _syncDisabled() {
504-
this._foundation.setDisabled(this.disabled);
464+
// TODO: disabled until we implement the new MDC slider.
465+
// this._foundation.setDisabled(this.disabled);
505466
}
506467

507468
/** Whether the slider is displayed in RTL-mode. */

src/material-experimental/mdc-slider/testing/slider-harness.spec.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,11 @@ import {runHarnessTests} from '@angular/material/slider/testing/shared.spec';
22
import {MatSliderModule} from '../index';
33
import {MatSliderHarness} from './slider-harness';
44

5-
describe('MDC-based MatSliderHarness', () => {
5+
// TODO: disabled until we implement the new MDC slider.
6+
describe('MDC-based MatSliderHarness dummy' , () => it('', () => {}));
7+
8+
// tslint:disable-next-line:ban
9+
xdescribe('MDC-based MatSliderHarness', () => {
610
runHarnessTests(MatSliderModule, MatSliderHarness as any, {
711
supportsVertical: false,
812
supportsInvert: false,

0 commit comments

Comments
 (0)