chore: Add new style-value-parser package #743
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Background
We're currently using
postcss-value-parser
for a few purposes but it is quite rudimentary.lightningcss
was considered but its API only parses entire CSS files and not individual values. It would also be a very heavy tool for what we need as it's an entire CSS post-processor. It would also allow all valid CSS and it would be more difficult to manually add our own constraints to it.New CSS Value Parser
This PR introduces a new parser which have been tailored for StyleX:
box-shadow
..toString()
methods will output normalised strings for various valuescm
andinch
topx
.How it will be used
This parser will be used to :
@media
queries in order to add additional guarantees for them.How complete is it?
There should already be parser for every CSS type.
There are a few style property specific parsers that composing together the "type" parsers. These are there as examples to get us started. These need to be updated to allow CSS variables being used in various positions.
There are many unit tests, but test coverage could be improved. Specially for the
toString
methods.