Skip to content

Conversation

ktabors
Copy link
Member

@ktabors ktabors commented Dec 15, 2020

Fixes a few issues in #1203

Moves the label value to the edge when on top and align start when a side label.
Default width is 192px.
Changed the width on the width and label overflow stories.

✅ Pull Request Checklist:

  • Included link to corresponding React Spectrum GitHub Issue.
  • Added/updated unit tests and storybook for this change (for new code or code which already has tests).
  • Filled out test instructions.
  • Updated documentation (if it already exists for this component).
  • Looked at the Accessibility Practices for this feature - Aria Practices

📝 Test Instructions:

Test all the slider stories, specifically the value stories, the the label side, the label overflow, and the custom width stories.

🧢 Your Project:

RSP

@ktabors ktabors changed the title #1203 slider improving label positioning and width to 192px #1203 slider improving label positioning and width Dec 15, 2020

min-block-size: var(--spectrum-slider-height);
min-inline-size: var(--spectrum-slider-min-width);
min-inline-size: var(--spectrum-global-dimension-size-2400);
Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Perhaps a variable in the :root of this file would suffice for now? Something like --spectrum-slider-min-height: var(--spectrum-global-dimension-size-2400);

Copy link
Member

@LFDanLu LFDanLu Dec 15, 2020

Choose a reason for hiding this comment

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

Ah never mind, my mistake. Just realized that --spectrum-slider-min-width is already a thing. Yeah I think opening a PR makes sense

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Is it supposed to change the min width or just the default width?

Copy link
Member Author

Choose a reason for hiding this comment

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

min width is default width, right?

@adobe-bot
Copy link

Build successful! 🎉

Copy link
Member

@LFDanLu LFDanLu left a comment

Choose a reason for hiding this comment

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

Is the default slider width of 192px supposed to be applied to outer slider div (aka spectrum-Slider) or the slider control (aka spectrum-Slider-controls)? Been trying to figure out which makes sense but the XD file and spectrum-css docs don't show anything being 192px by default

The answer to the above will affect things like the inline-size calculation the slider-control does and stuff

@ktabors
Copy link
Member Author

ktabors commented Dec 16, 2020

Discussed where the default width should be set and it should be on the track. This is how other labeled form components like TextField are done, with it on the input and not the container wrapping the label and the input. The custom width should go on the container.

font-feature-settings: "tnum";
text-align: end;

&:only-child {
Copy link
Member

Choose a reason for hiding this comment

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

What's the :only-child for?

Copy link
Member Author

Choose a reason for hiding this comment

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

When it is a side label, the value and label are in separate label containers... the way I added the start align to the value when side label is that value is the only child of a label container.

Copy link
Member

Choose a reason for hiding this comment

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

Oh I assumed there was a class for the side label state but I guess not... 😞

Maybe just add a comment to explain what you just said then.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe we should use the spectrum-Slider--positionSide class now?

let upperTrack = (
<div
className={classNames(styles, 'spectrum-Slider-track')}
style={{[cssDirection]: `${state.getThumbPercent(1) * 100}%`, width: `${(1 - state.getThumbPercent(1)) * 100}%`}} />
Copy link
Member

Choose a reason for hiding this comment

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

What was this change for?

Copy link
Member

Choose a reason for hiding this comment

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

Ah this one I can answer: @ktabors had noticed the following issue with range sliders where the right most track line spills into the right thumb:
image
Looking at https://opensource.adobe.com/spectrum-css/slider.html#range, the right most track line only has width applied to it, the left/right inline style here was extraneous

@adobe-bot
Copy link

Build successful! 🎉

@adobe-bot
Copy link

Build successful! 🎉

@adobe-bot
Copy link

Build successful! 🎉


/* These calculations prevent the track from spilling outside of the control */
inline-size: calc(100% - calc(var(--spectrum-slider-controls-margin) * 2));
inline-size: calc(100% - calc(var(--spectrum-slider-controls-margin)));
Copy link
Member

@LFDanLu LFDanLu Dec 17, 2020

Choose a reason for hiding this comment

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

Since the default width is being specified on the wrapping div now, I think you can revert this change here and remove the margin-inline-end that you added below

Copy link
Member Author

Choose a reason for hiding this comment

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

danni/devon removed it

@adobe-bot
Copy link

Build successful! 🎉

@adobe-bot
Copy link

Build successful! 🎉

touch-action: none;

width: var(--spectrum-global-dimension-size-2400);
min-inline-size: var(--spectrum-slider-min-width);
Copy link
Member Author

Choose a reason for hiding this comment

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

I thought textfield had the min width on the input parent not the field and input parent parent.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah honestly I don't know which is right. I am going to bring it up with Spectrum because I don't think I was specific enough when I asked them originally.

@adobe-bot
Copy link

Build successful! 🎉

This should work now.

Co-authored-by: Devon Govett <devongovett@gmail.com>
@adobe-bot
Copy link

Build successful! 🎉

@devongovett devongovett merged commit 0fe5ec6 into main Dec 17, 2020
@devongovett devongovett deleted the slider_label branch December 17, 2020 17:58
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.

5 participants