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

Wrap tokens for CSS output containing math expressions in calc() #1055

Open
jorenbroekema opened this issue Dec 4, 2023 · 0 comments
Open
Labels
4.0 Planned for v4 major version enhancement

Comments

@jorenbroekema
Copy link
Collaborator

jorenbroekema commented Dec 4, 2023

Feature Request

For the CSS property formatter or as a CSS-specific value transform (I prefer the latter, format should not be concerned much with token value changes).

:root {
  --my-math: 15px + 20px;
}

This is invalid CSS, but would be valid if wrapped inside CSS calc() statement. This can be done for any expression using * / + - characters.
Important to note is that whatever we do to regex match such tokens is that there must be spaces around the + and - math operators, see https://developer.mozilla.org/en-US/docs/Web/CSS/calc#notes

Output will then be:

:root {
  --my-math: calc(15px + 20px);
}

Should probably also support CSS custom props:

:root {
  --my-length: 15px;
  --my-math: calc(var(--my-length) + 20px);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
4.0 Planned for v4 major version enhancement
Projects
None yet
Development

No branches or pull requests

1 participant