refactor: Migrate to MUI System styled #48
Draft
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.
What are the relevant tickets?
Closes: https://github.com/mitodl/hq/issues/6636
Description (What does it do?)
Migrates component styles to use styled(), replacing @emotion/styled.
@emotion/styled
and@emotion/react
remain installed as they are peer dependencies of@mui/styled-engine
.This implements variants and is an incremental step towards PigmentCSS. From the linked issue: "We have a [MIT Learn] branch with an initial migration to PigmentCSS: mitodl/mit-learn@main...jk/6475-pigmentcss. An option was to migrate incrementally with Emotion and PigmentCSS running in parallel, however this produced build errors coming from Pigment's dependencies that have no stack trace to any of our code for debugging (WyW-in-JS in particular) and from within the obfuscated JS bundle, missing source mapping on the build output. These issues are resolvable, but will take time - the PigmentCSS documentation is very thin at the moment (we have Migrating to PigmentCSS and its repo README). Many of the repo issues remain open for a long time. There is evidence that the Material UI team is heavily invested in PigmentCSS, indeed it is planned to become the Material UI default styling engine in subsequent versions (currently Emotion). There is also a general trajectory towards styling engines that pre-compile JS to CSS at build time given their compatibility with React Server Components and subsequent performance benefit, however the PigmentCSS library is alpha at present and so presents a risk in adopting fully."
The wider goal is to migrate to zero-runtime CSS to avoid the performance hit on the main thread as declarations are produced during hydration.
The main increment on this branch is to apply variants, however MUI System
styled()
does not yet support Styling based on runtime values.How can this be tested?
Run
yarn start
to fire up Storybook. All story pages and component variants should match https://mitodl.github.io/smoot-design/Additional Context
Leaving in draft for the moment as there are issues to be resolved:
Small layout shifts on Button variants.