Skip to content

Commit

Permalink
fix(range): add and document custom properties
Browse files Browse the repository at this point in the history
references #14850
references #14808
  • Loading branch information
camwiegert committed Aug 30, 2018
1 parent f00db59 commit cf35445
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 11 deletions.
9 changes: 7 additions & 2 deletions core/src/components/range/range.ios.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,16 @@
--knob-size: 28px;
--bar-height: #{$range-ios-bar-height};
--bar-background: #{$range-ios-bar-background-color};
--bar-background-active: #{ion-color(primary, base)};
--height: #{$range-ios-slider-height};

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

:host(.ion-color) .range-bar-active,
:host(.ion-color) .range-tick-active {
background: current-color(base);
}

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

width: auto;

background: $range-ios-bar-active-background-color;
background: var(--bar-background-active);
}

.range-tick {
Expand All @@ -44,7 +49,7 @@
}

.range-tick-active {
background: $range-ios-tick-active-background-color;
background: var(--bar-background-active);
}

.range-pin {
Expand Down
24 changes: 19 additions & 5 deletions core/src/components/range/range.md.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,29 @@

:host {
--knob-border-radius: 50%;
--knob-background: #{$range-md-knob-background-color};
--knob-background: var(--bar-background-active);
--knob-box-shadow: none;
--knob-size: 18px;
--bar-height: #{$range-md-bar-height};
--bar-background: #{$range-md-bar-background-color};
--bar-background-active: #{ion-color(primary, base)};
--height: #{$range-md-slider-height};
--pin-background: #{ion-color(primary, base)};
--pin-color: #{ion-color(primary, contrast)};

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

font-size: $range-md-pin-font-size;
}

:host(.ion-color) .range-bar-active,
:host(.ion-color) .range-knob,
:host(.ion-color) .range-pin,
:host(.ion-color) .range-pin::before {
background: current-color(base);
color: current-color(contrast);
}

// TODO: REVIEW
// .range-md [slot="range-start"] {
// @include margin(0, 12px, 0, 0);
Expand All @@ -36,7 +47,7 @@

width: auto;

background: $range-md-bar-active-background-color;
background: var(--bar-background-active);
}

.range-knob {
Expand Down Expand Up @@ -78,10 +89,13 @@
position: relative;
top: -20px;

background: var(--pin-background);
color: var(--pin-color);

min-width: 28px;
height: 28px;

transition: transform 120ms ease, background-color 120ms ease;
transition: transform 120ms ease, background 120ms ease;

text-align: center;

Expand All @@ -97,9 +111,9 @@

transform: rotate(-45deg);

transition: background-color 120ms ease;
transition: background 120ms ease;

background: $range-md-pin-background-color;
background: var(--pin-background);

content: "";
z-index: -1;
Expand Down
12 changes: 10 additions & 2 deletions core/src/components/range/range.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,17 @@
// --------------------------------------------------

:host {
/**
* @prop --bar-background: Background of the range bar
* @prop --bar-background-active: Background of the active range bar
* @prop --bar-height: Height of the range bar
* @prop --height: Height of the range
* @prop --knob-background: Background of the range knob
* @prop --knob-border-radius: Border radius of the range knob
* @prop --knob-box-shadow: Box shadow of the range knob
* @prop --knob-size: Size of the range knob
*/
--knob-handle-size: calc(var(--knob-size) * 2);
--ion-color-base: #{ion-color(primary, base)};
--ion-color-contrast: #{ion-color(primary, contrast)};

display: flex;
position: relative;
Expand Down
14 changes: 14 additions & 0 deletions core/src/components/range/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,20 @@ left or right of the range.
| `ionStyle` | Emitted when the styles change. |


## CSS Custom Properties

| Name | Description |
| ------------------------- | ---------------------------------- |
| `--bar-background` | Background of the range bar |
| `--bar-background-active` | Background of the active range bar |
| `--bar-height` | Height of the range bar |
| `--height` | Height of the range |
| `--knob-background` | Background of the range knob |
| `--knob-border-radius` | Border radius of the range knob |
| `--knob-box-shadow` | Box shadow of the range knob |
| `--knob-size` | Size of the range knob |


----------------------------------------------

*Built with [StencilJS](https://stenciljs.com/)*
4 changes: 2 additions & 2 deletions core/src/components/range/test/basic/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@
<ion-range pin="true"></ion-range>
</ion-item>
<ion-item>
<ion-range min="-200" max="200" steps="10" snaps="true" pin="true"></ion-range>
<ion-range min="-200" max="200" step="10" snaps="true" pin="true"></ion-range>
</ion-item>
<ion-item>
<ion-range min="1000" max="2000" steps="100" snaps="true" id="range"></ion-range>
<ion-range min="1000" max="2000" step="100" snaps="true" id="range"></ion-range>
</ion-item>
<ion-item>
<ion-range dual-knobs="true" id="multiKnob"></ion-range>
Expand Down
12 changes: 12 additions & 0 deletions core/src/components/range/test/standalone/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,17 @@
<ion-icon size="small" name="ios-thermometer-outline" slot="start"></ion-icon>
<ion-icon name="ios-thermometer" slot="end"></ion-icon>
</ion-range>
<ion-range value="50" pin class="custom"></ion-range>

<style>
.custom {
--knob-background: purple;
--bar-background: papayawhip;
--bar-background-active: hotpink;
--bar-height: 3px;
--pin-background: pink;
--pin-color: purple;
}
</style>
</body>
</html>

0 comments on commit cf35445

Please sign in to comment.