Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure track step dots are in center on track #919

Merged
merged 2 commits into from
Oct 14, 2024
Merged
Changes from all 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
15 changes: 9 additions & 6 deletions packages/uui-range-slider/lib/uui-range-slider.element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const Z_INDEX = {
};

const THUMB_SIZE = 18;
const TRACK_HEIGHT = 3;
const TRACK_PADDING = 12;
const STEP_MIN_WIDTH = 24;

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

return html`<div class="step-wrapper">
<svg height="100%" width="100%">
<rect x="9" y="9" height="3" rx="2" />
<rect x="9" y="9" height="${TRACK_HEIGHT}" rx="2" />
${this._renderStepCircles(stepPositions)}
</svg>
${this._renderStepValues(stepAmount)}
Expand Down Expand Up @@ -671,9 +672,9 @@ export class UUIRangeSliderElement extends UUIFormControlMixin(LitElement, '') {
const colorEnd = this._highInputValue - this._min;

if (cx / trackValue >= colorStart && cx / trackValue <= colorEnd) {
return svg`<circle class="track-step filled" cx="${cx}" cy="5" r="4.5" />`;
return svg`<circle class="track-step filled" cx="${cx}" cy="${TRACK_HEIGHT * 2}" r="4.5" />`;
} else {
return svg`<circle class="track-step regular" cx="${cx}" cy="5" r="4.5" />`;
return svg`<circle class="track-step regular" cx="${cx}" cy="${TRACK_HEIGHT * 2}" r="4.5" />`;
}
})}`;
}
Expand Down Expand Up @@ -779,16 +780,18 @@ export class UUIRangeSliderElement extends UUIFormControlMixin(LitElement, '') {
}

:host(:not([readonly])) #inner-color-thumb:hover .color {
height: 5px;
height: ${TRACK_HEIGHT * 2}px;
background-color: var(--color-hover);
transform: translateY(-${TRACK_HEIGHT / 2}px);
}

.color {
user-select: none;
position: absolute;
inset-inline: 0;
height: 3px;
transform: translateY(2px);
height: ${TRACK_HEIGHT}px;
top: 50%;
transform: translateY(0);
background-color: var(--color-interactive);
transition: height 60ms;
}
Expand Down
Loading