Skip to content

Commit 9cd02f6

Browse files
authored
fix(uui-slider): Ensure track step dots are in center on track (#919)
* Ensure track step dots are in center on track * Calculate track height and hover style
1 parent 8454ae9 commit 9cd02f6

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

packages/uui-range-slider/lib/uui-range-slider.element.ts

+9-6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const Z_INDEX = {
1212
};
1313

1414
const THUMB_SIZE = 18;
15+
const TRACK_HEIGHT = 3;
1516
const TRACK_PADDING = 12;
1617
const STEP_MIN_WIDTH = 24;
1718

@@ -642,7 +643,7 @@ export class UUIRangeSliderElement extends UUIFormControlMixin(LitElement, '') {
642643

643644
return html`<div class="step-wrapper">
644645
<svg height="100%" width="100%">
645-
<rect x="9" y="9" height="3" rx="2" />
646+
<rect x="9" y="9" height="${TRACK_HEIGHT}" rx="2" />
646647
${this._renderStepCircles(stepPositions)}
647648
</svg>
648649
${this._renderStepValues(stepAmount)}
@@ -671,9 +672,9 @@ export class UUIRangeSliderElement extends UUIFormControlMixin(LitElement, '') {
671672
const colorEnd = this._highInputValue - this._min;
672673
673674
if (cx / trackValue >= colorStart && cx / trackValue <= colorEnd) {
674-
return svg`<circle class="track-step filled" cx="${cx}" cy="5" r="4.5" />`;
675+
return svg`<circle class="track-step filled" cx="${cx}" cy="${TRACK_HEIGHT * 2}" r="4.5" />`;
675676
} else {
676-
return svg`<circle class="track-step regular" cx="${cx}" cy="5" r="4.5" />`;
677+
return svg`<circle class="track-step regular" cx="${cx}" cy="${TRACK_HEIGHT * 2}" r="4.5" />`;
677678
}
678679
})}`;
679680
}
@@ -779,16 +780,18 @@ export class UUIRangeSliderElement extends UUIFormControlMixin(LitElement, '') {
779780
}
780781
781782
:host(:not([readonly])) #inner-color-thumb:hover .color {
782-
height: 5px;
783+
height: ${TRACK_HEIGHT * 2}px;
783784
background-color: var(--color-hover);
785+
transform: translateY(-${TRACK_HEIGHT / 2}px);
784786
}
785787
786788
.color {
787789
user-select: none;
788790
position: absolute;
789791
inset-inline: 0;
790-
height: 3px;
791-
transform: translateY(2px);
792+
height: ${TRACK_HEIGHT}px;
793+
top: 50%;
794+
transform: translateY(0);
792795
background-color: var(--color-interactive);
793796
transition: height 60ms;
794797
}

0 commit comments

Comments
 (0)