Skip to content

fix(slider): slider handle aligns with track when font size changes #5372

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

Merged
merged 18 commits into from
Feb 16, 2023
Merged
Show file tree
Hide file tree
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
32 changes: 16 additions & 16 deletions src/components/slider/slider.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
.scale--s {
--calcite-slider-handle-size: 10px;
--calcite-slider-handle-extension-height: 6.5px;
--calcite-slider-handle-size: theme("spacing[2.5]");
--calcite-slider-handle-extension-height: 0.4rem;
--calcite-slider-container-font-size: var(--calcite-font-size--3);
.handle__label,
.tick__label {
Expand All @@ -9,8 +9,8 @@
}

.scale--m {
--calcite-slider-handle-size: 14px;
--calcite-slider-handle-extension-height: 8px;
--calcite-slider-handle-size: theme("spacing[3.5]");
--calcite-slider-handle-extension-height: 0.5rem;
--calcite-slider-container-font-size: var(--calcite-font-size--2);
.handle__label,
.tick__label {
Expand All @@ -19,8 +19,8 @@
}

.scale--l {
--calcite-slider-handle-size: 16px;
--calcite-slider-handle-extension-height: 10.5px;
--calcite-slider-handle-size: 1rem;
--calcite-slider-handle-extension-height: 0.65rem;
--calcite-slider-container-font-size: var(--calcite-font-size--1);
.handle__label,
.tick__label {
Expand Down Expand Up @@ -58,17 +58,17 @@

.scale--s {
.thumb:not(.thumb--precise) {
--calcite-slider-thumb-y-offset: -6px;
--calcite-slider-thumb-y-offset: -0.375rem;
}
}
.scale--m {
.thumb:not(.thumb--precise) {
--calcite-slider-thumb-y-offset: -8px;
--calcite-slider-thumb-y-offset: -0.5rem;
}
}
.scale--l {
.thumb:not(.thumb--precise) {
--calcite-slider-thumb-y-offset: -9px;
--calcite-slider-thumb-y-offset: -0.55rem;
}
}

Expand Down Expand Up @@ -157,7 +157,7 @@
}

&.thumb--precise {
--calcite-slider-thumb-y-offset: -2px;
--calcite-slider-thumb-y-offset: -0.125rem;
}
}

Expand All @@ -168,17 +168,17 @@
&:host(:not([has-histogram])) {
.scale--s {
.thumb:not(.thumb--precise) {
--calcite-slider-thumb-y-offset: -23px;
--calcite-slider-thumb-y-offset: -1.4375rem;
}
}
.scale--m {
.thumb:not(.thumb--precise) {
--calcite-slider-thumb-y-offset: -30px;
--calcite-slider-thumb-y-offset: -1.875rem;
}
}
.scale--l {
.thumb:not(.thumb--precise) {
--calcite-slider-thumb-y-offset: -32px;
--calcite-slider-thumb-y-offset: -2rem;
}
}
}
Expand All @@ -199,13 +199,13 @@

:host([label-handles][precise]) {
&:host(:not([has-histogram])) .scale--s .thumb--value {
--calcite-slider-thumb-y-offset: -33px;
--calcite-slider-thumb-y-offset: -2.075rem;
}
&:host(:not([has-histogram])) .scale--m .thumb--value {
--calcite-slider-thumb-y-offset: -44px;
--calcite-slider-thumb-y-offset: -2.75rem;
}
&:host(:not([has-histogram])) .scale--l .thumb--value {
--calcite-slider-thumb-y-offset: -49px;
--calcite-slider-thumb-y-offset: -3.0625rem;
}
}

Expand Down
114 changes: 114 additions & 0 deletions src/components/slider/slider.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,3 +279,117 @@ export const wordBreakDoesNotAffectLabels_TestOnly = (): string =>
></calcite-slider>`;

export const WithLabelHandlesAndNoValue_TestOnly = (): string => html` <calcite-slider max="750"></calcite-slider> `;

export const WithLargeFontSize_TestOnly = (): string => html`<html lang="en">
<head>
<style>
html {
font-size: 24px;
}
calcite-label {
padding: 10px;
}
</style>
</head>
<body>
<div style="width: 400px; padding: 20px">
<calcite-label>
precise with label-handles
<calcite-slider scale="s" min="10" max="100" value="50" step="10" precise label-handles></calcite-slider
></calcite-label>
<calcite-label>
precise with label-handles mirrored
<calcite-slider
scale="s"
min="10"
max="100"
value="50"
step="10"
label-handles
precise
mirrored
></calcite-slider>
</calcite-label>
<calcite-label>
precise with label-handles & label-ticks
<calcite-slider
min="0"
max="100"
value="40"
step="10"
ticks="10"
scale="s"
label-handles
label-ticks
precise
></calcite-slider>
</calcite-label>
<calcite-label>
precise with label-handles & label-ticks mirrored
<calcite-slider
min="0"
max="100"
value="40"
step="10"
ticks="10"
scale="s"
label-handles
precise
mirrored
label-ticks
></calcite-slider>
</calcite-label>
<calcite-label>
range slider with label-handles & label-ticks
<calcite-slider
min="10"
max="100"
min-value="20"
max-value="90"
step="10"
min-label="Temperature range (lower)"
max-label="Temperature range (upper)"
scale="s"
label-handles
ticks="10"
label-ticks
></calcite-slider>
</calcite-label>
<calcite-label>
precise range slider with label-handles & label-ticks
<calcite-slider
min="10"
max="100"
min-value="20"
max-value="90"
step="10"
min-label="Temperature range (lower)"
max-label="Temperature range (upper)"
scale="s"
label-handles
ticks="10"
precise
label-ticks
></calcite-slider>
</calcite-label>
<calcite-label>
precise range slider with label-handles & label-ticks mirrored
<calcite-slider
min="10"
max="100"
min-value="20"
max-value="90"
step="10"
min-label="Temperature range (lower)"
max-label="Temperature range (upper)"
scale="s"
label-handles
ticks="10"
precise
label-ticks
mirrored
></calcite-slider>
</calcite-label>
</div>
</body>
</html>`;