Skip to content

Conversation

@RobinMalfait
Copy link
Member

This PR is a follow up from #14664 migrates all the theme(…) calls in your CSS to var(…) if we can.

In at-rules, like @media we can't use var(…) so we have to use the modern version of theme(…).

In declarations, we can convert to var(…) unless there is a modifier used in the theme(…) function, then we can only convert to the new theme(…) syntax without dot notation.

Input:

@media theme(spacing.4) {
  .foo {
    background-color: theme(colors.red.900);
    color: theme(colors.red.900 / 75%); /* With spaces around the `/` */
    border-color: theme(colors.red.200/75%); /* Without spaces around the `/` */
  }
}

Output:

@media theme(--spacing-4) {
/*     ^^^^^^^^^^^^^^^^^^     Use `theme(…)` since `var(…)` is invalid in this position*/
  .foo {
    background-color: var(--color-red-900); /* Converted to var(…) */
    color: theme(--color-red-900 / 75%); /* Convert to modern theme(…) */
    border-color: theme(--color-red-200 / 75%); /* Convert to modern theme(…) — pretty printed*/
  }
}

Copy link
Member Author

RobinMalfait commented Oct 16, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @RobinMalfait and the rest of your teammates on Graphite Graphite

Copy link
Member

@philipp-spiess philipp-spiess left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM just a small nit on the pretty option

Copy link
Member Author

RobinMalfait commented Oct 17, 2024

Merge activity

  • Oct 17, 5:44 AM EDT: A user started a stack merge that includes this pull request via Graphite.
  • Oct 17, 5:45 AM EDT: Graphite rebased this pull request as part of a merge.
  • Oct 17, 5:50 AM EDT: A user merged this pull request with Graphite.

Base automatically changed from robin/10-17-make_themetovar_reusable to next October 17, 2024 09:44
Indicating that the `pretty` option is about pretty printing the new
value.
@RobinMalfait RobinMalfait force-pushed the robin/10-17-migrate_theme_to_var_in_css branch from 6cd7cb3 to b29a111 Compare October 17, 2024 09:44
@RobinMalfait RobinMalfait merged commit 4a4be27 into next Oct 17, 2024
2 checks passed
@RobinMalfait RobinMalfait deleted the robin/10-17-migrate_theme_to_var_in_css branch October 17, 2024 09:50
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.

3 participants