Skip to content

Conversation

thecrypticace
Copy link
Contributor

@thecrypticace thecrypticace commented Apr 22, 2025

This builds on top of #1316 to simplify and improve value parsing in the language service. It's fairly easy to trip up the regexes we use to match and replace things. This PR changes things around to use proper parsers that implement the same algorithms that CSS uses.

There's still a lot of work left to make use of these new parsers everywhere that is necessary.

Fixes #1210

@thecrypticace thecrypticace force-pushed the fix/better-calc-evaluation branch 2 times, most recently from 5c1a316 to cfa251d Compare April 23, 2025 15:02
Base automatically changed from fix/better-calc-evaluation to main April 23, 2025 15:12
wip

wip

wip

wip

wip

wip

wip

wip

wip
@thecrypticace thecrypticace force-pushed the feat/improve-value-parsing branch from 4877d8d to 87ef383 Compare September 25, 2025 01:29
@thecrypticace thecrypticace added this to the 0.16.0 milestone Sep 30, 2025
thecrypticace added a commit that referenced this pull request Oct 6, 2025
Fixes #1463

We'll have to bail in some cases that we didn't before to fix this. This
seems fine though. The core problem was that given this theme:
```css
@theme {
  --radius: calc(var(--radius));
}
```

We'd see this CSS:
```css
.rounded {
  border-radius: calc(var(--radius));
}
```

And we'd try to replace variables in `calc(var(--radius))`. This doesn't
_start_ with a var(…) so our recursion guards didn't catch this.

This entire system is a bit fragile and I'll be working to clean this up
along with how we handle pixel equivalents, light-dark replacements,
color-mix replacements, etc… in some future PRs (#1330 is one of those
but I want to reorganize + tweak some code first in an earlier PR which
will make that one "nicer")
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.

Color swatch not showing up for variables using theme
1 participant