-
Notifications
You must be signed in to change notification settings - Fork 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
SegmentedControl: migrate CSS to webpack #35051
Conversation
Here is how your PR affects size of JS and CSS bundles shipped to the user's browser: Webpack Runtime (~8 bytes removed 📉 [gzipped])
Webpack runtime for loading modules. It is included in the HTML page as an inline script. Is downloaded and parsed every time the app is loaded. Legacy SCSS Stylesheet (~328 bytes removed 📉 [gzipped])
The monolithic CSS stylesheet that is downloaded on every app load. Sections (~272 bytes added 📈 [gzipped])
Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to. Async-loaded Components (~1798 bytes added 📈 [gzipped])
React components that are loaded lazily, when a certain part of UI is displayed for the first time. Legend What is parsed and gzip size?Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory. Generated by performance advisor bot at iscalypsofastyet.com. |
7d64a42
to
90d31c8
Compare
91888e5
to
1640639
Compare
1640639
to
ead1370
Compare
Removes code duplication and makes CSS modularization easier: styles for the control and the item are used at exactly one place.
Removes the `onSelect` prop (it's present only on the simplified variant) and adds the missing `primary` prop.
`SegmentedControl` and `SegmentedControl.Item` are always used together, so let's merge them into one module and make all imports one-liners. Improves the DX and makes CSS modularization easier.
4563110
to
c7eb716
Compare
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.
I tested various usages and they all seem to work fine! Code changes look good 👍
Just linking the discussion on the other PR as that relates to these changes as well: #35086 (comment) |
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.
Resolved conflicts with master, and e2e tests started failing. But they seem flacky and unrelated to this change.
Code looks good. I tested a few screens with this component and everything seems to work.
Thanks for the review @diegohaz! I usually prefer rebasing the branch rather than merging master into it. The commit history is then nicer and easier to work with. |
I'm not entirely sure what's going on but I see this on Jetpack plans grid (https://wordpress.com/plans + choose a Jetpack site): I see it only occasionally, like every 5th refresh. When it's broken, I see the CSS that I have in the screenshot. I suspect this PR changed this but I haven't tested yet to confirm. When it works, I see this instead: Note Occurs in all screen sizes both on Firefox and Chrome. |
Migrates
SegmentedControl
CSS to webpack and also improves the DX of the component:First, the
SimplifiedSegmentedControl
is re-implemented in terms ofSegmentedControl
andSegmentedControlItem
. No duplicate code (like the HTML markup).Second, make
SegmentedControlItem
a property of the parent component:SegmentedControl.Item
. They are always used together and the DX is better:Before:
After:
We need just one
import
statement.How to test:
Verify the various usages of the component. Used at a lot of places, but the refactoring is very straightforward and low-risk.