Skip to content

Commit 66770b0

Browse files
authored
Merge pull request #8620 from IgniteUI/SIvanova/slider-track-steps
chore(slider): improve slider track steps styling
2 parents 8274d4d + f9d679e commit 66770b0

File tree

3 files changed

+23
-12
lines changed

3 files changed

+23
-12
lines changed

projects/igniteui-angular/src/lib/core/styles/components/slider/_slider-theme.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
/// @param {Map} $schema [$light-schema] - The schema used as basis for styling the component.
1010
///
1111
/// @param {Color} $track-color [null] - The color of the track.
12+
/// @param {Color} $track-step-color [null] - The color of the track steps.
1213
/// @param {Color} $thumb-color [null] - The color of the thumb.
1314
/// @param {Color} $label-background-color [null] - The background color of the bubble label.
1415
/// @param {Color} $label-text-color [null] - The text color of the bubble label.
@@ -37,6 +38,7 @@
3738
$schema: $light-schema,
3839
3940
$track-color: null,
41+
$track-step-color: null,
4042
$thumb-color: null,
4143
4244
$label-background-color: null,
@@ -74,6 +76,7 @@
7476
name: $name,
7577
palette: $palette,
7678
track-color: $track-color,
79+
track-step-color: $track-step-color,
7780
track-hover-color: $track-hover-color,
7881
thumb-color: $thumb-color,
7982
thumb-hover-color: $thumb-hover-color,
@@ -320,6 +323,7 @@
320323
width: 100%;
321324
height: rem($slider-track-height);
322325
background-size: 100% em($slider-track-height);
326+
background-color: --var($theme, 'track-step-color');
323327
opacity: .85;
324328
transition: opacity .2s $ease-out-quad;
325329
z-index: 1;

projects/igniteui-angular/src/lib/core/styles/themes/schemas/light/_slider.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
/// Generates a light slider schema.
99
/// @type {Map}
1010
/// @property {Map} track-color [igx-color: ('secondary', 500)] - The color of the track.
11+
/// @property {Map} track-step-color [igx-color: 'surface'] - The color of the track steps.
1112
/// @property {Map} track-hover-color [igx-color: ('secondary', 500)] - The color of the track on hover.
1213
/// @property {Map} thumb-color [igx-color: ('secondary', 500)] - The color of the thumb.
1314
/// @property {Map} thumb-border-color [igx-color: ('secondary', 500)] - The thumb border color.
@@ -47,6 +48,10 @@ $_light-slider: (
4748
igx-color: ('secondary', 500)
4849
),
4950

51+
track-step-color: (
52+
igx-color: 'surface'
53+
),
54+
5055
thumb-color: (
5156
igx-color: ('secondary', 500)
5257
),

projects/igniteui-angular/src/lib/slider/slider.component.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ import { EditorProvider } from '../core/edit-provider';
1919
import { IgxSliderThumbComponent } from './thumb/thumb-slider.component';
2020
import { Subject, merge, Observable, timer, pipe } from 'rxjs';
2121
import { takeUntil, throttleTime } from 'rxjs/operators';
22-
import { SliderHandle,
22+
import {
23+
SliderHandle,
2324
IgxThumbFromTemplateDirective,
2425
IgxThumbToTemplateDirective,
2526
IRangeSliderValue,
@@ -32,7 +33,7 @@ import { SliderHandle,
3233
import { IgxThumbLabelComponent } from './label/thumb-label.component';
3334
import { IgxTicksComponent } from './ticks/ticks.component';
3435
import { IgxTickLabelsPipe } from './ticks/tick.pipe';
35-
import { resizeObservable } from '../core/utils';
36+
import { isIE, resizeObservable } from '../core/utils';
3637
import { IgxDirectionality } from '../services/direction/directionality';
3738

3839
const noop = () => {
@@ -90,7 +91,7 @@ export class IgxSliderComponent implements
9091
private _primaryTicks = 0;
9192
private _secondaryTicks = 0;
9293

93-
private _labels = new Array<number|string|boolean|null|undefined>();
94+
private _labels = new Array<number | string | boolean | null | undefined>();
9495
private _type = IgxSliderType.SLIDER;
9596

9697
private _destroyer$ = new Subject<boolean>();
@@ -291,7 +292,7 @@ export class IgxSliderComponent implements
291292
return this._labels;
292293
}
293294

294-
public set labels(labels: Array<number|string|boolean|null|undefined>) {
295+
public set labels(labels: Array<number | string | boolean | null | undefined>) {
295296
this._labels = labels;
296297

297298
this._pMax = this.valueToFraction(this.upperBound, 0, 1);
@@ -681,7 +682,7 @@ export class IgxSliderComponent implements
681682
* ```
682683
*/
683684
public set secondaryTicks(val: number) {
684-
if (val < 1 ) {
685+
if (val < 1) {
685686
return;
686687
}
687688

@@ -977,7 +978,7 @@ export class IgxSliderComponent implements
977978
*/
978979
public ngOnChanges(changes) {
979980
if (changes.minValue && changes.maxValue &&
980-
changes.minValue.currentValue < changes.maxValue.currentValue) {
981+
changes.minValue.currentValue < changes.maxValue.currentValue) {
981982
this._maxValue = changes.maxValue.currentValue;
982983
this._minValue = changes.minValue.currentValue;
983984
}
@@ -1026,7 +1027,7 @@ export class IgxSliderComponent implements
10261027
this._ngZone.runOutsideAngular(() => {
10271028
resizeObservable(this._el.nativeElement).pipe(
10281029
throttleTime(40),
1029-
takeUntil(this._destroyer$)).subscribe(() => this._ngZone.run( () => {
1030+
takeUntil(this._destroyer$)).subscribe(() => this._ngZone.run(() => {
10301031
this.stepDistance = this.calculateStepDistance();
10311032
}));
10321033
});
@@ -1069,7 +1070,7 @@ export class IgxSliderComponent implements
10691070
}
10701071

10711072
/** @hidden */
1072-
public getEditElement() {
1073+
public getEditElement() {
10731074
return this.isRange ? this.thumbFrom.nativeElement : this.thumbTo.nativeElement;
10741075
}
10751076

@@ -1249,7 +1250,7 @@ export class IgxSliderComponent implements
12491250

12501251
if (fromOffset === toOffset && toOffset < xPointer) {
12511252
this.thumbTo.nativeElement.focus();
1252-
} else if (fromOffset === toOffset && toOffset > xPointer ) {
1253+
} else if (fromOffset === toOffset && toOffset > xPointer) {
12531254
this.thumbFrom.nativeElement.focus();
12541255
} else if (match === fromOffset) {
12551256
this.thumbFrom.nativeElement.focus();
@@ -1271,7 +1272,8 @@ export class IgxSliderComponent implements
12711272
: null;
12721273
}
12731274

1274-
const renderCallbackExecution = !this.continuous ? this.generateTickMarks('white', interval) : null;
1275+
const renderCallbackExecution = !this.continuous ? this.generateTickMarks(
1276+
isIE() ? 'white' : 'var(--igx-slider-track-step-color, white)', interval) : null;
12751277
this.renderer.setStyle(this.ticks.nativeElement, 'background', renderCallbackExecution);
12761278
}
12771279

@@ -1350,7 +1352,7 @@ export class IgxSliderComponent implements
13501352
*/
13511353
private normalizeByStep(value: IRangeSliderValue | number) {
13521354
if (this.isRange) {
1353-
this.value = {
1355+
this.value = {
13541356
lower: (value as IRangeSliderValue).lower - ((value as IRangeSliderValue).lower % this.step),
13551357
upper: (value as IRangeSliderValue).upper - ((value as IRangeSliderValue).upper % this.step)
13561358
};
@@ -1430,7 +1432,7 @@ export class IgxSliderComponent implements
14301432
value = this.validateInitialValue(value as IRangeSliderValue);
14311433
this.upperValue = (value as IRangeSliderValue).upper;
14321434
this.lowerValue = (value as IRangeSliderValue).lower;
1433-
res = {lower: this.lowerValue, upper: this.upperValue};
1435+
res = { lower: this.lowerValue, upper: this.upperValue };
14341436
}
14351437

14361438
if (triggerChange) {

0 commit comments

Comments
 (0)