Skip to content

Commit 5eb4e10

Browse files
authored
fix(slider): style ticks according to the fill placement (#9196)
**Related Issue:** #1631 ## Summary This fixes an issue where ticks outside of the active fill were highlighted. **Note**: this depends on #9195
1 parent 9e5a713 commit 5eb4e10

File tree

2 files changed

+23
-3
lines changed

2 files changed

+23
-3
lines changed

packages/calcite-components/src/components/slider/slider.stories.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,15 +452,27 @@ export const fillPlacements = (): string => html`
452452
<calcite-slider min="0" max="100" value="50" fill-placement="start"></calcite-slider>
453453
<calcite-slider min="0" max="100" value="100" fill-placement="start"></calcite-slider>
454454
<br />
455+
<calcite-slider ticks="10" handle-ticks min="0" max="100" value="0" fill-placement="start"></calcite-slider>
456+
<calcite-slider ticks="10" handle-ticks min="0" max="100" value="50" fill-placement="start"></calcite-slider>
457+
<calcite-slider ticks="10" handle-ticks min="0" max="100" value="100" fill-placement="start"></calcite-slider>
458+
<br />
455459
<label>none</label>
456460
<calcite-slider min="0" max="100" value="0" fill-placement="none"></calcite-slider>
457461
<calcite-slider min="0" max="100" value="50" fill-placement="none"></calcite-slider>
458462
<calcite-slider min="0" max="100" value="100" fill-placement="none"></calcite-slider>
459463
<br />
464+
<calcite-slider ticks="10" handle-ticks min="0" max="100" value="0" fill-placement="none"></calcite-slider>
465+
<calcite-slider ticks="10" handle-ticks min="0" max="100" value="50" fill-placement="none"></calcite-slider>
466+
<calcite-slider ticks="10" handle-ticks min="0" max="100" value="100" fill-placement="none"></calcite-slider>
467+
<br />
460468
<label>end</label>
461469
<calcite-slider min="0" max="100" value="0" fill-placement="end"></calcite-slider>
462470
<calcite-slider min="0" max="100" value="50" fill-placement="end"></calcite-slider>
463471
<calcite-slider min="0" max="100" value="100" fill-placement="end"></calcite-slider>
472+
<br />
473+
<calcite-slider ticks="10" handle-ticks min="0" max="100" value="0" fill-placement="end"></calcite-slider>
474+
<calcite-slider ticks="10" handle-ticks min="0" max="100" value="50" fill-placement="end"></calcite-slider>
475+
<calcite-slider ticks="10" handle-ticks min="0" max="100" value="100" fill-placement="end"></calcite-slider>
464476
`;
465477

466478
export const customLabelsAndTicks = (): string => html`

packages/calcite-components/src/components/slider/slider.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -339,9 +339,17 @@ export class Slider
339339
<div class={CSS.ticks}>
340340
{this.tickValues.map((tick) => {
341341
const tickOffset = `${this.getUnitInterval(tick) * 100}%`;
342-
let activeTicks = tick >= min && tick <= value;
343-
if (useMinValue) {
344-
activeTicks = tick >= this.minValue && tick <= this.maxValue;
342+
343+
let activeTicks: boolean = false;
344+
345+
if (fillPlacement === "start" || fillPlacement === "end") {
346+
if (useMinValue) {
347+
activeTicks = tick >= this.minValue && tick <= this.maxValue;
348+
} else {
349+
const rangeStart = fillPlacement === "start" ? min : value;
350+
const rangeEnd = fillPlacement === "start" ? value : this.max;
351+
activeTicks = tick >= rangeStart && tick <= rangeEnd;
352+
}
345353
}
346354

347355
return (

0 commit comments

Comments
 (0)