Skip to content
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

refactor: Migrate to MUI System styled #48

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

jonkafton
Copy link
Contributor

@jonkafton jonkafton commented Feb 3, 2025

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:

  • Media query breakpoints specified in variants are not being applied.
  • Small layout shifts on Button variants.
  • Explicit any in Button.tsx (need to type create styled callback for reuse).

@jonkafton jonkafton marked this pull request as draft February 3, 2025 20:55
@jonkafton jonkafton changed the title Migrate to MUI System styled refactor: Migrate to MUI System styled Feb 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant