-
Notifications
You must be signed in to change notification settings - Fork 129
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
Introduce StyleX for styling #411
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
vinceau
force-pushed
the
refactor/stylex
branch
from
January 22, 2024 21:47
bf3f401
to
1b7cb87
Compare
See [this issue](facebook/stylex#370) for more info.
NikhilNarayana
approved these changes
Jan 24, 2024
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.
seems like a solid improvement to me
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR introduces yet another styling option into our codebase lol. This time it's Facebook's StyleX.
Motivation
Currently we have a lot of different styling options in our codebase:
sx
And then even with Emotion, there are different ways to style components e.g.
or:
As a developer it's really not clear what we should be using when and where. I'd be nice if we could reduce this list down to just one consistent method we use to style components across the board.
What's wrong with Emotion?
Defining the Emotion styles as string literals, the entire CSS strings are included as is in the compiled JS blob. There are a few issues with this:
renderer.js
and means there's more overhead in running and applying the styles.What does StyleX offer over Emotion?
This is actually huge for performance because all the CSS is generated beforehand at build, so that at runtime it only needs to add/remove classnames. We should see a much better performing application if we switch to StyleX,
and even more if we eventually add lazy loading to our pages too(addressed in #412).Since it uses object notation (similar to the style props and Material's overrides), rather than strings for defining types, we're much less likely to introduce bugs.
Migration Plan
Ideally we start using StyleX on all new components and modifications to existing components. Over time we reduce dependence on Emotion and switch fully over to StyleX for all custom components and styling needs.
End goal: Unfortunately we cannot completely remove Emotion from our codebase since it is a dependency of Material UI. However we can at least stop using it explicitly except for MUI themes and overrides.