Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/demo-app/slider/slider-demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ <h1>Default Slider</h1>
Label <md-slider #slidey></md-slider>
{{slidey.value}}

<h1>Colors</h1>
<md-slider color="primary" value="50" thumbLabel></md-slider>
<md-slider color="accent" value="50" thumbLabel></md-slider>
<md-slider color="warn" value="50" thumbLabel></md-slider>

<h1>Slider with Min and Max</h1>
<input [(ngModel)]="min">
<md-slider [min]="min" [max]="max" tickInterval="5" #slider2></md-slider>
Expand Down
36 changes: 26 additions & 10 deletions src/lib/slider/_slider-theme.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@


@mixin mat-slider-theme($theme) {
$primary: map-get($theme, primary);
$accent: map-get($theme, accent);
$warn: map-get($theme, warn);

$mat-slider-off-color: rgba(black, 0.26);
$mat-slider-off-focused-color: rgba(black, 0.38);
Expand All @@ -17,24 +19,38 @@
background-color: $mat-slider-off-color;
}

.mat-slider-track-fill {
background-color: mat-color($accent);
.mat-slider-track-fill,
.mat-slider-thumb,
.mat-slider-thumb-label {
.mat-primary & {
background-color: mat-color($primary);
}

.mat-accent & {
background-color: mat-color($accent);
}

.mat-warn & {
background-color: mat-color($warn);
}
}

.mat-slider-focus-ring {
background-color: $mat-slider-focus-ring-color;
}

.mat-slider-thumb {
background-color: mat-color($accent);
}
.mat-slider-thumb-label-text {
.mat-primary & {
color: mat-color($primary, default-contrast);
}

.mat-slider-thumb-label {
background-color: mat-color($accent);
}
.mat-accent & {
color: mat-color($accent, default-contrast);
}

.mat-slider-thumb-label-text {
color: mat-color($accent, default-contrast);
.mat-warn & {
color: mat-color($warn, default-contrast);
}
}

.mat-slider:hover,
Expand Down
5 changes: 5 additions & 0 deletions src/lib/slider/slider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ export class MdSliderChange {
'[attr.aria-valuemax]': 'max',
'[attr.aria-valuemin]': 'min',
'[attr.aria-valuenow]': 'value',
'[class.mat-primary]': 'color == "primary"',
'[class.mat-accent]': 'color != "primary" && color != "warn"',
'[class.mat-warn]': 'color == "warn"',
'[class.mat-slider-disabled]': 'disabled',
'[class.mat-slider-has-ticks]': 'tickInterval',
'[class.mat-slider-horizontal]': '!vertical',
Expand Down Expand Up @@ -204,6 +207,8 @@ export class MdSlider implements ControlValueAccessor, OnDestroy {
set vertical(value: any) { this._vertical = coerceBooleanProperty(value); }
private _vertical = false;

@Input() color: 'primary' | 'accent' | 'warn' = 'accent';

/** Event emitted when the slider value has changed. */
@Output() change = new EventEmitter<MdSliderChange>();

Expand Down