Skip to content

Commit 2ada43c

Browse files
Updating the range pin to always be visible when enabled for the ionic theme
1 parent 5300f3b commit 2ada43c

File tree

2 files changed

+11
-21
lines changed

2 files changed

+11
-21
lines changed

core/src/components/range/range.ionic.scss

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -108,19 +108,18 @@
108108
}
109109

110110
.range-pin {
111-
@include transform(translate3d(0, 100%, 0), scale(0.01));
112-
@include padding($ion-space-200, $ion-space-200, $ion-space-200, $ion-space-200);
111+
@include padding($ion-space-300, $ion-space-300, $ion-space-300, $ion-space-300);
113112

114113
min-width: 28px;
115114

116-
transition: transform 120ms ease;
117-
118115
background: transparent;
119116
color: $text-color;
120117

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

123120
text-align: center;
121+
122+
transform: translate3d(0, calc(-100% + 11px), 0) scale(1);
124123
}
125124

126125
.range-knob {
@@ -129,20 +128,6 @@
129128
border-color: #{ion-color(primary, base)};
130129
}
131130

132-
/**
133-
* The -100% ensures the pin sits on top
134-
* of the range-knob-handle container.
135-
* We apply 11px so that the pin
136-
* text is closer to the knob inside of the container.
137-
* We also apply the 11px here instead of using "top"
138-
* otherwise the pin text will translate below the knob
139-
* when the text is scaled.
140-
*/
141-
.range-knob-pressed .range-pin,
142-
.range-knob-handle.ion-focused .range-pin {
143-
transform: translate3d(0, calc(-100% + 11px), 0) scale(1);
144-
}
145-
146131
// Ionic Range: Disabled (based on iOS Range)
147132
// --------------------------------------------------
148133
// When the range is disabled, the entire range,

core/src/components/range/range.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { isRTL } from '@utils/rtl';
88
import { createColorClasses, hostContext } from '@utils/theme';
99

1010
import { getIonTheme } from '../../global/ionic-global';
11-
import type { Color, Gesture, GestureDetail } from '../../interface';
11+
import type {Color, Gesture, GestureDetail, Theme} from '../../interface';
1212
import { roundToMaxDecimalPlaces } from '../../utils/floating-point';
1313

1414
import type {
@@ -637,6 +637,8 @@ export class Range implements ComponentInterface {
637637
inheritedAttributes,
638638
} = this;
639639

640+
const theme = getIonTheme(this);
641+
640642
let barStart = `${ratioLower * 100}%`;
641643
let barEnd = `${100 - ratioUpper * 100}%`;
642644

@@ -778,6 +780,7 @@ export class Range implements ComponentInterface {
778780
min,
779781
max,
780782
inheritedAttributes,
783+
theme,
781784
})}
782785

783786
{this.dualKnobs &&
@@ -793,6 +796,7 @@ export class Range implements ComponentInterface {
793796
min,
794797
max,
795798
inheritedAttributes,
799+
theme,
796800
})}
797801
</div>
798802
);
@@ -873,11 +877,12 @@ interface RangeKnob {
873877
pinFormatter: PinFormatter;
874878
inheritedAttributes: Attributes;
875879
handleKeyboard: (name: KnobName, isIncrease: boolean) => void;
880+
theme: Theme;
876881
}
877882

878883
const renderKnob = (
879884
rtl: boolean,
880-
{ knob, value, ratio, min, max, disabled, pressed, pin, handleKeyboard, pinFormatter, inheritedAttributes }: RangeKnob
885+
{ knob, value, ratio, min, max, disabled, pressed, pin, handleKeyboard, pinFormatter, inheritedAttributes, theme }: RangeKnob
881886
) => {
882887
const start = rtl ? 'right' : 'left';
883888

@@ -928,7 +933,7 @@ const renderKnob = (
928933
>
929934
{pin && (
930935
<div class="range-pin" role="presentation" part="pin">
931-
{pinFormatter(value)}
936+
{pinFormatter(value) + (theme === 'ionic' ? '%' : '')}
932937
</div>
933938
)}
934939
<div class="range-knob" role="presentation" part="knob" />

0 commit comments

Comments
 (0)