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

Slider update #4614

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open

Slider update #4614

wants to merge 14 commits into from

Conversation

tayyabataimur
Copy link
Contributor

@tayyabataimur tayyabataimur commented Jan 23, 2025

Slider and RangeSlider components.

Copy link

changeset-bot bot commented Jan 23, 2025

⚠️ No Changeset found

Latest commit: 5694d03

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

vercel bot commented Jan 23, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
saltdesignsystem ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 20, 2025 5:17pm

@tayyabataimur tayyabataimur force-pushed the slider-update branch 2 times, most recently from 1eee83a to a2508f9 Compare January 23, 2025 11:57
@tayyabataimur tayyabataimur added the chromatic Run chromatic on the current PR. Will be removed by the CI once submitted. label Jan 23, 2025
@github-actions github-actions bot removed the chromatic Run chromatic on the current PR. Will be removed by the CI once submitted. label Jan 23, 2025
@tayyabataimur tayyabataimur added the chromatic Run chromatic on the current PR. Will be removed by the CI once submitted. label Jan 24, 2025
@tayyabataimur tayyabataimur added chromatic Run chromatic on the current PR. Will be removed by the CI once submitted. and removed chromatic Run chromatic on the current PR. Will be removed by the CI once submitted. labels Jan 24, 2025
@github-actions github-actions bot removed the chromatic Run chromatic on the current PR. Will be removed by the CI once submitted. label Jan 24, 2025
@joshwooding joshwooding self-requested a review January 24, 2025 11:31
@tayyabataimur tayyabataimur added the chromatic Run chromatic on the current PR. Will be removed by the CI once submitted. label Jan 28, 2025
@github-actions github-actions bot removed the chromatic Run chromatic on the current PR. Will be removed by the CI once submitted. label Jan 28, 2025
const changeSpy = cy.stub().as("changeSpy");
cy.mount(<Slider style={{ width: "400px" }} onChange={changeSpy} />);
cy.get(".saltSliderTrack").trigger("pointerdown", {
cy.get(".saltSliderTrack-rail").trigger("pointerdown", {
button: 0,
clientX: 50,
clientY: 50,
});
cy.get("@changeSpy").should("have.callCount", 1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should test the correct values are returned when we test callbacks

<SliderThumb
aria-describedby={formFieldDescribedBy}
aria-label={ariaLabel}
aria-labelledby={formFieldLabelledBy}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aria-labelledby and aria-describedby being passed in as props should also be handled (and tested)

aria-labelledby={formFieldLabelledBy}
aria-valuemax={max}
aria-valuemin={min}
aria-valuetext={ariaValueText}
Copy link
Contributor

@joshwooding joshwooding Feb 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we be providing guidance on how to use this, or is this just to cover all bases? @jake-costa

@@ -1,2 +1,3 @@
export * from "./Slider";
export * from "./types";
export * from "./RangeSlider";
export * from "./internal/useSliderThumb";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be careful that this isn't exposing this from the package unnecessarily, import {} from "@salt-ds/core"

transform: translateX(-50%);
cursor: pointer;
outline: none;
top: -5px;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this value correct? Or is there a token / calculation we can use

use visibility: hidden as we need the screen
reader to announce it */
.saltSliderThumb-accessibleText {
position: absolute;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should use the standard approach here? There should be an example elsewhere in the code

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Found useAriaAnnouncer() which I think would suit the purpose

transform: translate(-50%, -50%);
border: 1px solid var(--salt-accent-borderColor);
padding: var(--salt-spacing-50) var(--salt-spacing-100);
user-select: none;
Copy link
Contributor

@joshwooding joshwooding Feb 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should check this behaviour, although I assume this is included to prevent selecting text when dragging. When not dragging should selecting text work? @jake-costa @navkaur76

Edit: I just checked, currently dragging the tooltip changes the value so I assume this was intentional

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joshwooding Yep, this was intentional to prevent selecting the tooltip's text when dragging. Good question about being able to select the text when not dragging, keen to hear Jake and Nav's thoughts on this.


.saltSliderTrack-minLabel,
.saltSliderTrack-maxLabel {
user-select: none;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably just check if this is necessary everywhere

}

.saltSliderTrack-minLabel {
order: 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I always get a bit nervous when I see order being used, due to accessibility worried @jake-costa maybe something to have a quick look at

By default the minimum and maximum values are shown, and can be displayed either inline or below the track (using the `marks` prop to `"bottom"`).

Alternately, incremental marks can be shown along the track by setting the `marks` prop to `"all"`. The incremental marks will match the `step` prop value (i.e. for a `step` value of `5`, the marks will display as "0", "5", "10", "15", etc.) Note that when all marks are shown, they are always displayed below the track.
Selection of a single value from a horizontally oriented slider track. Values can be displayed either inline or below the track.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

values or labels?

By default the minimum and maximum values are shown, and can be displayed either inline or below the track (using the `marks` prop to `"bottom"`).

Alternately, incremental marks can be shown along the track by setting the `marks` prop to `"all"`. The incremental marks will match the `step` prop value (i.e. for a `step` value of `5`, the marks will display as "0", "5", "10", "15", etc.) Note that when all marks are shown, they are always displayed below the track.
Selection of a single value from a horizontally oriented slider track. Values can be displayed either inline or below the track.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can understand why but since we only support one orientation for now we don't need to add "horizontally oriented" everywhere


## With Markers

You can display markers under the values of your choice with custom labels.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wording confused me a bit, "markers" are the labels so we might need to clear up the wording a bit

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the way I think of this is, we always have min/max labels and if we want to add more labels, we pass them through markers or marks to add those labels at certain marks.

Copy link
Contributor

@joshwooding joshwooding left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good 🎉, left a few comments/thoughts. Not all of these need to be resolved before going to labs but it's better to raise them now.

@jake-costa
Copy link
Contributor

@tayyabataimur FYI for examples with a visible label should referenced by aria-labelledby on the slider element.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants