-
Notifications
You must be signed in to change notification settings - Fork 894
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 improvements #211
Slider improvements #211
Conversation
This pull request is being automatically deployed with Vercel (learn more). 🔍 Inspect: https://vercel.com/modulz/interop-ui/oh1rix4uy/modulz-deploys.com [Deployment for 1b04b84 failed] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is much simpler to review now so, nice job! 👏
I have a few general comments below (as well as a handful smaller inline ones).
Where's the TS error? I don't seem to see it.
There's something that doesn't feel quite right for me with regards to arrow keys.
I'm not sure I'm right about it but it feels strange.
- horizontal orientation, left-right is good, but up-down seem inverted to me
- vertical orientation, up-down is good, left-right seems good but only because the range starts from the top, what if we want the range to start from the bottom? I feel like it should be possible, like an equalizer-type UI.
Note: I saw that you have a
startEdge
/endEdge
in context, I think it's mainly to execute horizontal vs. vertical, but I feel like a start edge could be useful in achieving what I've described above as well as dealing with arrows accordingly.
Generally, there are quite a few functions that take a few args, often most of them numbers, which I feel make them harder to track and prone to mistakes. I generally switch to an object of named params for these. Not sure what you think?
I completely get what you've tried to do with SliderHorizontal
and SliderVertical
to avoid the orientation ? … : …
in a bunch of places. I don't know if I prefer it though to be honest. This way gives me a big indirection from the top level. I feel like I'd rather have one component where I see everytime we switch from width
to height
, top
to left
, clientX
to clientY
, etc. Doesn't seem to be many of them. I usually prefer inlining like this. I say this knowing fully that you've probably considered it and tried it, but that's just my gut feeling when I see that it's mostly duplicated code.
Note: I think that perhaps this came from being too much when everything was in one place (including the abstractions now built into
SliderPart
). I suspect a good middle ground now would be to retain theSliderPart
abstraction, but close downSliderVertical
andSliderHorizontal
intoSlider
.
Ah yeah, I see that. Admittedly, I didn't have the up/down keys working in
Hmmm, this is an interesting one. That implies we should be able to start from the right too in horizontal mode. What are your thoughts on this one @colmtuite @chaance ? It seems fair to me, but just checking before I spend a bunch of time on it.
I agree, the fact that a lot of this stuff is even abstracted hurts my head. There was feedback to abstract these but I think we've gone a bit tooooo far. I'll move the ones that aren't being re-used back inline (where is makes sense) and try clean up some of the args for the others.
Yeah, I had a load of branching before and honestly, I wasn't keen at all. It wasn't easy to visualise exactly how things were going to be in a particular orientation because the orientation concerns were spread all over. With this, I can see exactly what each orientation is responsible for. However, I have changed things quite a bit since my initial branching madness SO... I'll create a separate temp branch where we can compare the two and see which we prefer. |
I actually think we want all directional keys working in either orientation. That's now native range inputs work (only horizontal mode for native, obviously).
|
RTL is important for internationalization, so I definitely think we should support it. I generally expect vertical sliders to start from the bottom, but that's a little less clear since we operate in a horizontal reading mode in english. I do think we need to support all cases since both vertical and RTL languages will need one or the other depending on its context. |
Yeah I think we need both, but I also think there's somehow a different expectation based on which side the range starts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some questions within. Still need to give it a test run locally but I'll submit another review shortly!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One very minor thing but GTG!
Thanks @chaance... I'll wait for @benoitgrelard to double check he's happy with the final result too and then merge next week 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes are looking good!
A few things noted inline, almost there!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 🎉 🚀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚢🚢🚢
It's probably easier to just review these files from scratch. Don't worry about reviewing stuff I haven't changed, I'm happy to rework it too if we think that's needed.
Note: There is a TS error to do with ourforwardRef
typing. I'm trying to removedefaultValue
from theReact.componentPropsWithRef<'span'>
type, but ourforwardRef
stuff adds it back in. This results in anever
type fordefaultValue
when using the array variationI tried to fix it before PRing but it opened a can of worms. I'm not sure if it's worth investing too much time here given the polymorphic work I've been doing separately but we do need to fix that before releasing it.