Skip to content

Commit ca2ebc7

Browse files
committed
Update sass variables and export slider directives + nits
1 parent 019d0c5 commit ca2ebc7

File tree

5 files changed

+49
-45
lines changed

5 files changed

+49
-45
lines changed

src/components/slider/slider.scss

Lines changed: 35 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
@import 'default-theme';
2+
@import '_variables';
23

34
// This refers to the thickness of the slider. On a horizontal slider this is the height, on a
45
// vertical slider this is the width.
5-
$slider-thickness: 20px !default;
6-
$slider-min-size: 128px !default;
6+
$md-slider-thickness: 20px !default;
7+
$md-slider-min-size: 128px !default;
8+
$md-slider-padding: 8px !default;
79

8-
$slider-track-height: 2px !default;
9-
$slider-thumb-size: 20px !default;
10+
$md-slider-track-height: 2px !default;
11+
$md-slider-thumb-size: 20px !default;
1012

11-
$slider-thumb-default-scale: 0.7 !default;
12-
$slider-thumb-focus-scale: 1 !default;
13+
$md-slider-thumb-default-scale: 0.7 !default;
14+
$md-slider-thumb-focus-scale: 1 !default;
1315

1416
// TODO(iveysaur): Find an implementation to hide the track under a disabled thumb.
15-
$slider-off-color: rgba(black, 0.26);
16-
$slider-focused-color: rgba(black, 0.38);
17-
$slider-disabled-color: rgba(black, 0.26);
17+
$md-slider-off-color: rgba(black, 0.26);
18+
$md-slider-focused-color: rgba(black, 0.38);
19+
$md-slider-disabled-color: rgba(black, 0.26);
1820

1921
/**
2022
* Uses a container height and an item height to center an item vertically within the container.
@@ -26,17 +28,17 @@ $slider-disabled-color: rgba(black, 0.26);
2628
/**
2729
* Positions the thumb based on its width and height.
2830
*/
29-
@mixin slider-thumb-position($width: $slider-thumb-size, $height: $slider-thumb-size) {
31+
@mixin slider-thumb-position($width: $md-slider-thumb-size, $height: $md-slider-thumb-size) {
3032
position: absolute;
31-
top: center-vertically($slider-thickness, $height);
33+
top: center-vertically($md-slider-thickness, $height);
3234
width: $width;
3335
height: $height;
3436
border-radius: max($width, $height);
3537
}
3638

3739
md-slider {
38-
height: $slider-thickness;
39-
min-width: $slider-min-size;
40+
height: $md-slider-thickness;
41+
min-width: $md-slider-min-size;
4042
position: relative;
4143
padding: 0;
4244
display: inline-block;
@@ -56,12 +58,12 @@ md-slider *::after {
5658
.md-slider-wrapper {
5759
width: 100%;
5860
height: 100%;
59-
padding-left: 8px;
60-
padding-right: 8px;
61+
padding-left: $md-slider-padding;
62+
padding-right: $md-slider-padding;
6163
}
6264

6365
/**
64-
* Holds the isActive and isDragging classes as well as help with positioning the children.
66+
* Holds the isActive and isDragging classes as well as helps with positioning the children.
6567
* Cannot be merged with .md-slider-wrapper.
6668
*/
6769
.md-slider-container {
@@ -71,21 +73,21 @@ md-slider *::after {
7173
.md-slider-track-container {
7274
width: 100%;
7375
position: absolute;
74-
top: center-vertically($slider-thickness, $slider-track-height);
75-
height: $slider-track-height;
76+
top: center-vertically($md-slider-thickness, $md-slider-track-height);
77+
height: $md-slider-track-height;
7678
}
7779

7880
.md-slider-track {
7981
position: absolute;
8082
left: 0;
8183
right: 0;
8284
height: 100%;
83-
background-color: $slider-off-color;
85+
background-color: $md-slider-off-color;
8486
}
8587

8688
.md-slider-track-fill {
87-
transition-duration: 400ms;
88-
transition-timing-function: cubic-bezier(0.25, 0.8, 0.25, 1);
89+
transition-duration: $swift-ease-out-duration;
90+
transition-timing-function: $swift-ease-out-timing-function;
8991
transition-property: width, height;
9092
background-color: md-color($md-accent);
9193
}
@@ -95,29 +97,29 @@ md-slider *::after {
9597
left: 0;
9698
top: 50%;
9799
transform: translate3d(-50%, -50%, 0);
98-
transition-duration: 400ms;
99-
transition-timing-function: cubic-bezier(0.25, 0.8, 0.25, 1);
100+
transition-duration: $swift-ease-out-duration;
101+
transition-timing-function: $swift-ease-out-timing-function;
100102
transition-property: left, bottom;
101103
}
102104

103105
.md-slider-thumb-position {
104-
transition: transform 400ms cubic-bezier(0.25, 0.8, 0.25, 1);
106+
transition: transform $swift-ease-out-duration $swift-ease-out-timing-function;
105107
}
106108

107109
.md-slider-thumb {
108110
z-index: 1;
109111

110-
@include slider-thumb-position($slider-thumb-size, $slider-thumb-size);
111-
transform: scale($slider-thumb-default-scale);
112-
transition: transform 400ms cubic-bezier(0.25, 0.8, 0.25, 1);
112+
@include slider-thumb-position($md-slider-thumb-size, $md-slider-thumb-size);
113+
transform: scale($md-slider-thumb-default-scale);
114+
transition: transform $swift-ease-out-duration $swift-ease-out-timing-function;
113115
}
114116

115117
.md-slider-thumb::after {
116118
content: '';
117119
position: absolute;
118-
width: $slider-thumb-size;
119-
height: $slider-thumb-size;
120-
border-radius: max($slider-thumb-size, $slider-thumb-size);
120+
width: $md-slider-thumb-size;
121+
height: $md-slider-thumb-size;
122+
border-radius: max($md-slider-thumb-size, $md-slider-thumb-size);
121123
border-width: 3px;
122124
border-style: solid;
123125
transition: inherit;
@@ -132,10 +134,10 @@ md-slider *::after {
132134
}
133135

134136
.md-slider-active .md-slider-thumb {
135-
transform: scale($slider-thumb-focus-scale);
137+
transform: scale($md-slider-thumb-focus-scale);
136138
}
137139

138140
.md-slider-disabled .md-slider-thumb::after {
139-
background-color: $slider-disabled-color;
140-
border-color: $slider-disabled-color;
141+
background-color: $md-slider-disabled-color;
142+
border-color: $md-slider-disabled-color;
141143
}

src/components/slider/slider.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
import {TestComponentBuilder, ComponentFixture} from '@angular/compiler/testing';
1010
import {Component, DebugElement, provide, ViewEncapsulation} from '@angular/core';
1111
import {By} from '@angular/platform-browser';
12-
import {MdSlider} from './slider';
12+
import {MdSlider, MD_SLIDER_DIRECTIVES} from './slider';
1313
import {HAMMER_GESTURE_CONFIG} from '@angular/platform-browser';
1414
import {TestGestureConfig} from './test-gesture-config';
1515

@@ -317,7 +317,7 @@ describe('MdSlider', () => {
317317

318318
// The transition has to be removed in order to test the updated positions without setTimeout.
319319
@Component({
320-
directives: [[MdSlider]],
320+
directives: [MD_SLIDER_DIRECTIVES],
321321
template: `<md-slider></md-slider>`,
322322
styles: [`
323323
.md-slider-track-fill, .md-slider-thumb-position {
@@ -329,19 +329,19 @@ describe('MdSlider', () => {
329329
class StandardSlider { }
330330

331331
@Component({
332-
directives: [[MdSlider]],
332+
directives: [MD_SLIDER_DIRECTIVES],
333333
template: `<md-slider disabled></md-slider>`
334334
})
335335
class DisabledSlider { }
336336

337337
@Component({
338-
directives: [[MdSlider]],
338+
directives: [MD_SLIDER_DIRECTIVES],
339339
template: `<md-slider min="5" max="15"></md-slider>`
340340
})
341341
class SliderWithMinAndMax { }
342342

343343
@Component({
344-
directives: [[MdSlider]],
344+
directives: [MD_SLIDER_DIRECTIVES],
345345
template: `<md-slider value="26"></md-slider>`
346346
})
347347
class SliderWithValue { }

src/components/slider/slider.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ export class MdSlider implements AfterContentInit {
206206
export class SliderRenderer {
207207
private _sliderElement: HTMLElement;
208208

209-
constructor(private _elementRef: ElementRef) {
210-
this._sliderElement = this._elementRef.nativeElement;
209+
constructor(elementRef: ElementRef) {
210+
this._sliderElement = elementRef.nativeElement;
211211
}
212212

213213
/**
@@ -249,3 +249,5 @@ export class SliderRenderer {
249249
this._sliderElement.focus();
250250
}
251251
}
252+
253+
export const MD_SLIDER_DIRECTIVES = [MdSlider];

src/components/slider/test-gesture-config.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ export class TestGestureConfig extends MdGestureConfig {
1919
buildHammer(element: HTMLElement) {
2020
let mc = super.buildHammer(element);
2121

22-
if (!this.hammerInstances.get(element)) {
23-
this.hammerInstances.set(element, [mc]);
24-
} else {
22+
if (this.hammerInstances.get(element)) {
2523
this.hammerInstances.get(element).push(mc);
24+
} else {
25+
this.hammerInstances.set(element, [mc]);
2626
}
2727

2828
return mc;

src/demo-app/slider/slider-demo.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import {Component} from '@angular/core';
2-
import {MdSlider} from '@angular2-material/slider/slider';
2+
import {MD_SLIDER_DIRECTIVES} from '@angular2-material/slider/slider';
33

44
@Component({
55
moduleId: module.id,
66
selector: 'slider-demo',
77
templateUrl: 'slider-demo.html',
8-
directives: [MdSlider],
8+
directives: [MD_SLIDER_DIRECTIVES],
99
})
1010
export class SliderDemo { }

0 commit comments

Comments
 (0)