-
Notifications
You must be signed in to change notification settings - Fork 6.8k
feat(material-experimental/mdc-slider): implement MatSlider #21680
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
wagnermaciel
merged 8 commits into
angular:mdc-slider
from
wagnermaciel:slider-thumb-decorator
Feb 8, 2021
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
4dfee9b
feat(material-experimental/mdc-slider): create MatSliderThumbDecorator
wagnermaciel 9fd3f2e
feat(material-experimental/mdc-slider): implement MatSlider
wagnermaciel 60f7368
fix(material-experimental/mdc-slider): code review changes
wagnermaciel 8256d35
fix(material-experimental/mdc-slider): code review changes
wagnermaciel 019afec
fix(material-experimental/mdc-slider): accidentally had _showTickMark…
wagnermaciel ea86c61
fix(material-experimental/mdc-slider): code review changes
wagnermaciel 3173e1b
fix(material-experimental/mdc-slider): undo circular dep
wagnermaciel 3ebf3bc
fix(material-experimental/mdc-slider): code review changes
wagnermaciel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
src/material-experimental/mdc-slider/slider-thumb-decorator.html
This file contains hidden or 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,10 @@ | ||
<ng-container *ngIf="isDiscrete"> | ||
<div class="mdc-slider__value-indicator-container"> | ||
<div class="mdc-slider__value-indicator"> | ||
<span class="mdc-slider__value-indicator-text"> | ||
{{ valueIndicatorText }} | ||
wagnermaciel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
</span> | ||
</div> | ||
</div> | ||
</ng-container> | ||
<div class="mdc-slider__thumb-knob" #knob></div> |
74 changes: 74 additions & 0 deletions
74
src/material-experimental/mdc-slider/slider-thumb-decorator.ts
This file contains hidden or 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,74 @@ | ||
/** | ||
* @license | ||
* Copyright Google LLC All Rights Reserved. | ||
* | ||
* Use of this source code is governed by an MIT-style license that can be | ||
* found in the LICENSE file at https://angular.io/license | ||
*/ | ||
|
||
import { | ||
ChangeDetectionStrategy, | ||
ChangeDetectorRef, | ||
Component, | ||
ElementRef, | ||
EventEmitter, | ||
Input, | ||
Output, | ||
ViewChild, | ||
ViewEncapsulation, | ||
} from '@angular/core'; | ||
import {Thumb} from '@material/slider'; | ||
|
||
/** | ||
* Handles displaying the slider knobs and their value indicators. | ||
*/ | ||
@Component({ | ||
selector: 'mat-slider-start-thumb-decorator, mat-slider-end-thumb-decorator', | ||
wagnermaciel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
templateUrl: 'slider-thumb-decorator.html', | ||
host: { | ||
'class': 'mdc-slider__thumb', | ||
'(mouseenter)': '_mouseenter.emit()', | ||
wagnermaciel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
'(mouseleave)': '_mouseleave.emit()', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would these need to account for touch devices? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. Would it be acceptable for me to add a TODO here and implement the support for this in a later PR? |
||
}, | ||
encapsulation: ViewEncapsulation.None, | ||
changeDetection: ChangeDetectionStrategy.OnPush, | ||
}) | ||
export class MatSliderThumbDecorator { | ||
/** Whether the slider is discrete. */ | ||
@Input() isDiscrete: boolean; | ||
|
||
/** The text content of the value indicator for a discrete slider. */ | ||
@Input() | ||
get valueIndicatorText(): string { return this._valueIndicatorText; } | ||
set valueIndicatorText(v: string) { | ||
this._valueIndicatorText = v; | ||
this._cdr.detectChanges(); | ||
wagnermaciel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
private _valueIndicatorText: string; | ||
|
||
/** Event emitted every time the cursor moves onto the MatSliderThumbDecorator. */ | ||
@Output() mouseenter: EventEmitter<void> = new EventEmitter<void>(); | ||
|
||
/** Event emitted every time the cursor moves away from the MatSliderThumbDecorator. */ | ||
@Output() mouseleave: EventEmitter<void> = new EventEmitter<void>(); | ||
|
||
/** The visible circle for the slider thumb. This reference is used by the SliderAdapter. */ | ||
@ViewChild('knob') _knob: ElementRef<HTMLElement>; | ||
|
||
constructor( | ||
private _cdr: ChangeDetectorRef, | ||
private _elementRef: ElementRef<HTMLElement>, | ||
) {} | ||
|
||
/** Returns the thumb that this decorator corresponds to. */ | ||
_getThumb(): Thumb { | ||
return this._getHostElement().tagName === 'MAT-SLIDER-END-THUMB-DECORATOR' | ||
wagnermaciel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
? Thumb.END | ||
: Thumb.START; | ||
} | ||
|
||
/** Returns the hosts native HTML element. */ | ||
_getHostElement(): HTMLElement { | ||
return this._elementRef.nativeElement; | ||
} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.