Skip to content

Commit cf35445

Browse files
committed
fix(range): add and document custom properties
references #14850 references #14808
1 parent f00db59 commit cf35445

File tree

6 files changed

+64
-11
lines changed

6 files changed

+64
-11
lines changed

core/src/components/range/range.ios.scss

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,16 @@
1111
--knob-size: 28px;
1212
--bar-height: #{$range-ios-bar-height};
1313
--bar-background: #{$range-ios-bar-background-color};
14+
--bar-background-active: #{ion-color(primary, base)};
1415
--height: #{$range-ios-slider-height};
1516

1617
@include padding($range-ios-padding-vertical, $range-ios-padding-horizontal);
1718
}
1819

20+
:host(.ion-color) .range-bar-active,
21+
:host(.ion-color) .range-tick-active {
22+
background: current-color(base);
23+
}
1924

2025
:host(.range-has-pin) {
2126
@include padding($range-ios-padding-vertical + $range-ios-pin-font-size, null, null, null);
@@ -26,7 +31,7 @@
2631

2732
width: auto;
2833

29-
background: $range-ios-bar-active-background-color;
34+
background: var(--bar-background-active);
3035
}
3136

3237
.range-tick {
@@ -44,7 +49,7 @@
4449
}
4550

4651
.range-tick-active {
47-
background: $range-ios-tick-active-background-color;
52+
background: var(--bar-background-active);
4853
}
4954

5055
.range-pin {

core/src/components/range/range.md.scss

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,29 @@
66

77
:host {
88
--knob-border-radius: 50%;
9-
--knob-background: #{$range-md-knob-background-color};
9+
--knob-background: var(--bar-background-active);
1010
--knob-box-shadow: none;
1111
--knob-size: 18px;
1212
--bar-height: #{$range-md-bar-height};
1313
--bar-background: #{$range-md-bar-background-color};
14+
--bar-background-active: #{ion-color(primary, base)};
1415
--height: #{$range-md-slider-height};
16+
--pin-background: #{ion-color(primary, base)};
17+
--pin-color: #{ion-color(primary, contrast)};
1518

1619
@include padding($range-md-padding-vertical, $range-md-padding-horizontal);
1720

1821
font-size: $range-md-pin-font-size;
1922
}
2023

24+
:host(.ion-color) .range-bar-active,
25+
:host(.ion-color) .range-knob,
26+
:host(.ion-color) .range-pin,
27+
:host(.ion-color) .range-pin::before {
28+
background: current-color(base);
29+
color: current-color(contrast);
30+
}
31+
2132
// TODO: REVIEW
2233
// .range-md [slot="range-start"] {
2334
// @include margin(0, 12px, 0, 0);
@@ -36,7 +47,7 @@
3647

3748
width: auto;
3849

39-
background: $range-md-bar-active-background-color;
50+
background: var(--bar-background-active);
4051
}
4152

4253
.range-knob {
@@ -78,10 +89,13 @@
7889
position: relative;
7990
top: -20px;
8091

92+
background: var(--pin-background);
93+
color: var(--pin-color);
94+
8195
min-width: 28px;
8296
height: 28px;
8397

84-
transition: transform 120ms ease, background-color 120ms ease;
98+
transition: transform 120ms ease, background 120ms ease;
8599

86100
text-align: center;
87101

@@ -97,9 +111,9 @@
97111

98112
transform: rotate(-45deg);
99113

100-
transition: background-color 120ms ease;
114+
transition: background 120ms ease;
101115

102-
background: $range-md-pin-background-color;
116+
background: var(--pin-background);
103117

104118
content: "";
105119
z-index: -1;

core/src/components/range/range.scss

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,17 @@
44
// --------------------------------------------------
55

66
:host {
7+
/**
8+
* @prop --bar-background: Background of the range bar
9+
* @prop --bar-background-active: Background of the active range bar
10+
* @prop --bar-height: Height of the range bar
11+
* @prop --height: Height of the range
12+
* @prop --knob-background: Background of the range knob
13+
* @prop --knob-border-radius: Border radius of the range knob
14+
* @prop --knob-box-shadow: Box shadow of the range knob
15+
* @prop --knob-size: Size of the range knob
16+
*/
717
--knob-handle-size: calc(var(--knob-size) * 2);
8-
--ion-color-base: #{ion-color(primary, base)};
9-
--ion-color-contrast: #{ion-color(primary, contrast)};
1018

1119
display: flex;
1220
position: relative;

core/src/components/range/readme.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,20 @@ left or right of the range.
4343
| `ionStyle` | Emitted when the styles change. |
4444

4545

46+
## CSS Custom Properties
47+
48+
| Name | Description |
49+
| ------------------------- | ---------------------------------- |
50+
| `--bar-background` | Background of the range bar |
51+
| `--bar-background-active` | Background of the active range bar |
52+
| `--bar-height` | Height of the range bar |
53+
| `--height` | Height of the range |
54+
| `--knob-background` | Background of the range knob |
55+
| `--knob-border-radius` | Border radius of the range knob |
56+
| `--knob-box-shadow` | Box shadow of the range knob |
57+
| `--knob-size` | Size of the range knob |
58+
59+
4660
----------------------------------------------
4761

4862
*Built with [StencilJS](https://stenciljs.com/)*

core/src/components/range/test/basic/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,10 @@
8585
<ion-range pin="true"></ion-range>
8686
</ion-item>
8787
<ion-item>
88-
<ion-range min="-200" max="200" steps="10" snaps="true" pin="true"></ion-range>
88+
<ion-range min="-200" max="200" step="10" snaps="true" pin="true"></ion-range>
8989
</ion-item>
9090
<ion-item>
91-
<ion-range min="1000" max="2000" steps="100" snaps="true" id="range"></ion-range>
91+
<ion-range min="1000" max="2000" step="100" snaps="true" id="range"></ion-range>
9292
</ion-item>
9393
<ion-item>
9494
<ion-range dual-knobs="true" id="multiKnob"></ion-range>

core/src/components/range/test/standalone/index.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,17 @@
2121
<ion-icon size="small" name="ios-thermometer-outline" slot="start"></ion-icon>
2222
<ion-icon name="ios-thermometer" slot="end"></ion-icon>
2323
</ion-range>
24+
<ion-range value="50" pin class="custom"></ion-range>
25+
26+
<style>
27+
.custom {
28+
--knob-background: purple;
29+
--bar-background: papayawhip;
30+
--bar-background-active: hotpink;
31+
--bar-height: 3px;
32+
--pin-background: pink;
33+
--pin-color: purple;
34+
}
35+
</style>
2436
</body>
2537
</html>

0 commit comments

Comments
 (0)