Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 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
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,14 @@
* @prop --pin-background: Background of the range pin (only available in MD mode)
* @prop --pin-color: Color of the range pin (only available in MD mode)
*/
--knob-handle-size: calc(var(--knob-size) * 2);

display: flex;
position: relative;

flex: 3;
align-items: center;

font-family: $font-family-base;

user-select: none;
z-index: $z-index-item-input;
}

:host(.range-disabled) {
Expand All @@ -40,10 +36,6 @@
flex: initial;
}

::slotted(ion-icon[slot]) {
font-size: 24px;
}

.range-slider {
position: relative;

Expand Down Expand Up @@ -214,8 +206,6 @@
* only the label would show and users
* would not be able to see the range.
*/
max-width: 200px;

text-overflow: ellipsis;

white-space: nowrap;
Expand Down Expand Up @@ -254,15 +244,6 @@
flex-direction: row;
}

:host(.range-label-placement-start) .label-text-wrapper {
/**
* The margin between the label and
* the range should be on the end
* when the label sits at the start.
*/
@include margin(0, $form-control-label-margin, 0, 0);
}

// Range Label Placement - End
// ----------------------------------------------------------------

Expand All @@ -274,27 +255,9 @@
flex-direction: row-reverse;
}

/**
* The margin between the label and
* the range should be on the start
* when the label sits at the end.
*/
:host(.range-label-placement-end) .label-text-wrapper {
@include margin(0, 0, 0, $form-control-label-margin);
}

// Range Label Placement - Fixed
// ----------------------------------------------------------------

:host(.range-label-placement-fixed) .label-text-wrapper {
/**
* The margin between the label and
* the range should be on the end
* when the label sits at the start.
*/
@include margin(0, $form-control-label-margin, 0, 0);
}

/**
* Label is on the left of the range in LTR and
* on the right in RTL. Label also has a fixed width.
Expand Down Expand Up @@ -323,24 +286,9 @@
@include transform-origin(start, top);
@include transform(scale(#{$form-control-label-stacked-scale}));

/**
* The margin between the label and
* the range should be on the bottom
* when the label sits on top.
*/
@include margin(null, 0, $form-control-label-margin, 0);

/**
* Label text should not extend
* beyond the bounds of the range.
*/
max-width: calc(100% / #{$form-control-label-stacked-scale});
}

:host(.in-item.range-label-placement-stacked) .label-text-wrapper {
@include margin($range-item-label-margin-top, null, $form-control-label-margin, null);
}

:host(.in-item.range-label-placement-stacked) .native-wrapper {
@include margin(null, null, $range-item-label-margin-bottom, null);
}
210 changes: 210 additions & 0 deletions core/src/components/range/range.ionic.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
@use "../../themes/ionic/ionic.globals.scss" as globals;
@import "./range.common";
@import "../../foundations/ionic.vars";

// Ionic Range
// --------------------------------------------------

:host {
--knob-border-radius: 50%;
--knob-background: #{$ion-primitives-base-white};
--knob-box-shadow: 0;
--knob-size: 22px;
--knob-handle-size: #{$ion-scale-1000};
--bar-height: #{$ion-scale-200};
--bar-background: #{$ion-primitives-neutral-100};
--bar-background-active: #{ion-color(primary, base)};
--bar-border-radius: #{$ion-border-radius-400};
--height: 42px;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should use scale-1000 to match the knob area and then we can adjust the pin in the other PR to reach the 68px total height

Suggested change
--height: 42px;
--height: #{globals.$ion-scale-1000};


@include globals.typography(globals.$ion-body-md-regular);

z-index: $ion-z-index-100;
}

:host(.range-item-start-adjustment) {
@include padding(null, null, null, $ion-space-600);
}

:host(.range-item-end-adjustment) {
@include padding(null, $ion-space-600, null, null);
}

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

::slotted(ion-icon[slot]) {
font-size: $ion-font-size-600;
}

::slotted([slot="start"]) {
@include margin(0, 16px, 0, 0);
}

::slotted([slot="end"]) {
@include margin(0, 0, 0, 16px);
}

::slotted([slot="label"]) {
max-width: $ion-scale-5000;
}

:host(.range-has-pin:not(.range-label-placement-stacked)) {
/**
* The pin should not overlap any elements that are
* above the range. By adding padding to the top of the
* range, it provides a buffer for the pin to move into
* when it is pressed.
*
* The padding is not included when the label is stacked
* because the pin is below the label.
* It still requires a buffer to prevent the pin from
* overlapping the range. The buffer is added to the
* bottom of the range label instead of the host.
*/
@include padding(calc($ion-space-200 + dynamic-font(12px)), null, null, null);
}

:host(.range-has-pin.range-label-placement-stacked) .label-text-wrapper {
/**
* The pin should not overlap the stacked label. By adding
* margin to the bottom of the label, it provides a buffer
* for the pin to move into when it is pressed.
*/
@include margin(null, null, calc($ion-space-200 + dynamic-font(12px)), null);
}

.range-bar-active {
bottom: 0;

width: auto;

background: var(--bar-background-active);

&.has-ticks {
@include border-radius(0);
@include margin(null, calc(-1 * $ion-scale-100 * 0.5), null, calc(-1 * $ion-scale-100 * 0.5));
}
}

.range-tick {
@include margin-horizontal(calc($ion-scale-100 * -0.5), null);
@include border-radius($ion-border-radius-0);

position: absolute;
top: calc((42px * 0.5) - ($ion-scale-300 * 0.5));

width: $ion-scale-100;
height: $ion-scale-300;

background: $ion-primitives-neutral-100;
pointer-events: none;
}

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

.range-pin {
@include transform(translate3d(0, 100%, 0), scale(0.01));
@include padding($ion-space-200, $ion-space-200, $ion-space-200, $ion-space-200);

min-width: 28px;

transition: transform 120ms ease;

background: transparent;
color: $text-color;

font-size: dynamic-font(12px);

text-align: center;
}

.range-knob {
border-width: $ion-border-size-025;
border-style: solid;
border-color: #{ion-color(primary, base)};
}

/**
* The -100% ensures the pin sits on top
* of the range-knob-handle container.
* We apply 11px so that the pin
* text is closer to the knob inside of the container.
* We also apply the 11px here instead of using "top"
* otherwise the pin text will translate below the knob
* when the text is scaled.
*/
.range-knob-pressed .range-pin,
.range-knob-handle.ion-focused .range-pin {
transform: translate3d(0, calc(-100% + 11px), 0) scale(1);
}

// Ionic Range: Disabled (based on iOS Range)
// --------------------------------------------------
// When the range is disabled, the entire range,
// range label, any slotted labels, and any slotted
// icons need to receive the same opacity.

:host(.range-disabled) {
opacity: 0.3;
}

// Range Label Placement - Start
// ----------------------------------------------------------------

:host(.range-label-placement-start) .label-text-wrapper {
/**
* The margin between the label and
* the range should be on the end
* when the label sits at the start.
*/
@include margin(0, $ion-space-400, 0, 0);
}

// Range Label Placement - End
// ----------------------------------------------------------------

:host(.range-label-placement-end) .label-text-wrapper {
/**
* The margin between the label and
* the range should be on the start
* when the label sits at the end.
*/
@include margin(0, 0, 0, $ion-space-400);
}

// Range Label Placement - Fixed
// ----------------------------------------------------------------

:host(.range-label-placement-fixed) .label-text-wrapper {
/**
* The margin between the label and
* the range should be on the end
* when the label sits at the start.
*/
@include margin(0, $ion-space-400, 0, 0);
}

// Range Label Placement - Stacked
// ----------------------------------------------------------------

:host(.range-label-placement-stacked) .label-text-wrapper {
/**
* The margin between the label and
* the range should be on the bottom
* when the label sits on top.
*/
@include margin(null, 0, $ion-space-400, 0);
}

:host(.in-item.range-label-placement-stacked) .label-text-wrapper {
@include margin($ion-space-250, null, $ion-space-400, null);
}

:host(.in-item.range-label-placement-stacked) .native-wrapper {
@include margin(null, null, $ion-space-0, null);
}
2 changes: 1 addition & 1 deletion core/src/components/range/range.ios.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import "./range";
@import "./range.native";
@import "./range.ios.vars";

// iOS Range
Expand Down
2 changes: 1 addition & 1 deletion core/src/components/range/range.md.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
@import "./range";
@import "./range.native";
@import "./range.md.vars";

// Material Design Range
Expand Down
Loading
Loading