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

Upgrade: Migrate spacing scale #14905

Merged
merged 10 commits into from
Nov 7, 2024
Merged

Upgrade: Migrate spacing scale #14905

merged 10 commits into from
Nov 7, 2024

Conversation

philipp-spiess
Copy link
Member

This PR adds migrations for the recent changes to the --spacing scale done in #12263.

There are a few steps that we do to ensure we have the best upgrade experience:

  • If you are overwriting the spacing theme with custom values, we now check if the new values are multiplies of the default spacing scale. When they are, we can safely remove the overwrite.
  • If you are extending the spacing theme, we will unset the default --spacing scale and only use the values you provided.
  • Any theme() function calls are replaced with calc(var(--spacing) * multiplier) unless the values are extending the default scale.

One caveat here is for theme() key which can not be replaced with var() (e.g. in @media attribute positions). These will not be able to be replaced with calc() either so the following needs to stay unmigrated:

@media (max-width: theme(spacing.96)) {
  .foo {
    color: red;
  }
}

Test plan

We are mainly testing two scenarios: The JS config extends the spacing namespace and the JS config overwrites the spacing namespace. For both cases we have added an integration test each to ensure this works as expected. The test contains a mixture of keys (some of it matching the default multiples, some don't, some have different scales, and some use non-numeric identifiers). In addition to asserting on the created CSS @theme, we also ensure that theme() calls are properly replaced.

@philipp-spiess philipp-spiess requested a review from a team as a code owner November 7, 2024 14:36
@adamwathan adamwathan force-pushed the feat/spacing-scale-codemods branch from 80bc46d to cb3f28c Compare November 7, 2024 19:01
CHANGELOG.md Outdated Show resolved Hide resolved
@adamwathan adamwathan merged commit 95c4877 into next Nov 7, 2024
1 check passed
@adamwathan adamwathan deleted the feat/spacing-scale-codemods branch November 7, 2024 19:25
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.

2 participants