-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
[Components]: Add SegmentedControl #31937
Conversation
40b7691
to
51dd550
Compare
f4576d7
to
fd21789
Compare
Size Change: +3.48 kB (0%) Total Size: 1.07 MB
ℹ️ View Unchanged
|
I pushed a few tweaks, now it looks like this: We're getting closer here. One next step is fixing the focus style, which is supposed to be 1.5px admin-theme-color-blue. The CSS suggests this is accomplished by a border color and a .5px shadow: But as you can see, the rule points to an object instead of a color. Here's the bit: That "admin" color is defined here: We need to revisit those admin color scheme treatments by the way, and ideally remove the fallback now that we don't have to support IE11. The colors are also wrong, where "medium blue" is not equivalent to the dark blue. @ntsekouras do you know why that bit isn't working as it should? |
I guess it's okay to change to have the proper value like Also I think it's okay to change to the proper color values in the --cc @sarayourfriend |
Note to self: if we remove the dark background color on the active button and rely on the backdrop, the horizontal sliding animation will be more visible. |
Fixed sliding: We'll still need to remove the !important for the active control. Without it, it's essentially minimal specificity competing against minimal specificity: In vanilla CSS I'd have done this:
What's the CSS-in-JS equivalent? |
I refactored not to use While this works, the approach I took was to use |
packages/components/src/segmented-control/segmented-control-button.tsx
Outdated
Show resolved
Hide resolved
That's the exact right way to solve this problem, using the |
b730335
to
d08bcbb
Compare
packages/components/src/segmented-control/segmented-control-button.tsx
Outdated
Show resolved
Hide resolved
packages/components/src/segmented-control/segmented-control-option.tsx
Outdated
Show resolved
Hide resolved
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 so cool! Thanks so much @ntsekouras!
I'd like to discuss more the naming convention (SegmentedControl.Option
vs. SegmentedControlOption
), especially in the light of #33391. It doesn't look like we have many modules using this dot notation if any. So we would need to change more things if we want to adopt this convention. For now, I would stick with SegmentedControlOption
.
My biggest concern on this Module.Child
convention is that we can't leverage tree shaking. When Module
is imported, all the Child
components will be imported as well. For example, even if we just use Toolbar
and Toolbar.Button
, the other components of the family like Toolbar.DropdownMenu
, Toolbar.Group
etc. would also add to the bundle even though they're not being used.
packages/components/src/segmented-control/segmented-control-option.tsx
Outdated
Show resolved
Hide resolved
packages/components/src/segmented-control/segmented-control-option.tsx
Outdated
Show resolved
Hide resolved
packages/components/src/segmented-control/segmented-control-option.tsx
Outdated
Show resolved
Hide resolved
I believe it's okay to land now as it's not been used somewhere yet. @jasmussen can take a look at it really soon, when he is back from his vacations. |
Thank you all for the help, reviews and guidance! 🙇 |
Oof this looks really bad. We should definitely address this. I'll add it to the list. |
Thanks for landing this! |
Congrats on landing this!
I'll take a look at this one as soon as I can! |
Description
Adds a new
SegmentedControl
component.Testing Instructions
I have added a temp commit which renders this control in
PostFeaturedImage
.Screen.Recording.2021-07-07.at.7.19.32.PM.mov