* Use `initial` for `@property` fallbacks instead of ` `
* Update changelog
---------
Co-authored-by: Adam Wathan <4323180+adamwathan@users.noreply.github.com>
* Support combining arbitrary shadows without a color with shadow color utilities
* Update changelog
---------
Co-authored-by: Adam Wathan <4323180+adamwathan@users.noreply.github.com>
* Use longform length + percentage syntax for properties
Using properties that declare the shorthand syntax `<length-percentage>` has a bug where two properties side-by-side e.g. `var(—foo)var(—bar)` invalidate the property value when it should not. Switching the `@property` definition to use the long form syntax `<length> | <percentage>` fixes this.
* Update changelog
* Update tests
* move `length` data type from `background-position` to `background-size`
This way it's backwards compatible with v3.
* sort data types
* update changelog
* make sure `length` is inferred later
Otherwise `bg-[120px]` would be inferred as `length` instead of
`position`.
In v3 this maps to `position` instead of `length`.
```css
.bg-\[120px\] {
background-position: 120px;
}
```
* add explicit test cases for `length` and `size` data types
* run `pnpm update --recursive`
* update tests to reflect lightningcss bump
It looks like it's mainly (re-)ordering properties. Not 100% sure why
though.
* Fixes exports when importing CJS form ESM file
* Build a real ESM version of the postcss plugin
---------
Co-authored-by: Jordan Pittman <jordan@cryptica.me>
* ensure we handle strings as-in
When encountering strings when using `segment` we didn't really treat
them as actual strings. This means that if you used any parens,
brackets, or curlies then we wanted them to be properly balanced.
This should not be the case, whenever we encounter a string, we want to
consume it as-is and don't want to worry about bracket balancing. We
will now consume it until the end of the string (and make sure that
escaped closing quotes are not seen as real closing quotes).
* update changelog
* drop unnecessary test
Already had this test
* ensure we utilities and variants defined
* add example test that parses with unbalanced brackets inside quotes
* improve changelog entry
* hoist comment
* Allow hyphen character in regex pattern to use support queries as is
* Update variants.test.ts
---------
Co-authored-by: Adam Wathan <adam.wathan@gmail.com>
* remove automatic `var(…)` injection
There are a few properties that use "dashed-ident" values, this means
that you can use `--my-thing` as-is without the `var(…)` around it.
This causes issues because we are now injecting a `var(…)` where it's not
needed.
One potential solution is to create a list of properties where dashed
idents can be used. However, they can _also_ use CSS custom properties
that point to another dashed ident.
A workaround that some people used is adding a `_` in front of the
variable: `mt-[_--my-thing]` this way we don't automatically inject the
`var(…)` around it. This is a workaround and gross.
While the idea of automatic var injection is neat, this causes more
trouble than it's worth. Adding `var(…)` explicitly is better.
A side effect of this is that we can simplify the `candidate` data
structure because we don't need to track `dashedIdent` separately
anymore.
* update tests by adding `var(…)` explicitly
* update changelog
* skip initial character we just saw
Thanks Richard for noticing!
Co-authored-by: Richard van Velzen <richard@frank.nl>
* prevent calling `charCodeAt()` if we already computed the value
* update changelog
---------
Co-authored-by: Richard van Velzen <richard@frank.nl>
* implement custom `compare` for sorting purposes
This `compare` function compares two strings. However, once a number is
reached the numbers are compared as actual numbers instead of the string
representation.
E.g.:
```
p-1
p-2
p-10
p-20
```
Will be sorted as expected in this order, instead of
```
p-1
p-10
p-2
p-20
```
---
This should also make suggestions in the vscode extension more logical.
* update tests to reflect order changes
* update changelog
* reset `i` correctly
This makes the code more correct _and_ improves performance because the
`Number(…)` will now always deal with numbers.
On the tailwindcss.com codebase, sorting now goes from `~3.29ms` to
`~3.10ms`
* drop unreachable code
In this branch, it's guaranteed that numbers are _different_ which means
that they are never going to be the same thus unreachable code.
When we compare two strings such as:
```
foo-123-bar
foo-123-baz
```
Then all characters until the last character is the same character in
both positions. This means that "numbers" that are the same in the same
position will be compared as strings instead of numbers. But that is
fine because they are the same anyway.
* add fallback in case numbers are the same but strings are not
This can happen if we are sorting `0123` and `123`. The `Number`
representation will be equal, but the string is not.
Will rarely or even never happen. But if it does, this makes it
deterministic.
* re-word comment
* add more test cases with numbers in different spots with various lengths
* Update CHANGELOG.md
* cleanup, simplify which variables we increment
This also gets rid of some explanation that can now be omitted entirely.
---------
Co-authored-by: Adam Wathan <adam.wathan@gmail.com>
* use shared tokens
* use token constants in candidate parser
* use token constants in `isColor` function
* add block now that `return null` goes to a new line
* Switch breakpoints to rem #8378
* Fix broken test
* Update snapshots
---------
Co-authored-by: Adam Wathan <4323180+adamwathan@users.noreply.github.com>
* Use charCodeAt instead of string comparison
* Rename some things
* Fix lint issues
---------
Co-authored-by: Adam Wathan <4323180+adamwathan@users.noreply.github.com>
* reverse order of variants
This way variants work similar to how you would write them in CSS
itself.
This also allows us to remove the special "fixup" code that fixes the
position of some variants because they have to be in a specific order
(the end). Since the order wasn't intuitive we had to solve this with a
fixup.
This commit should allow us to remove this entirely, because now it is intuitive.
* update tests to reflect variant order change
* Update changelog
---------
Co-authored-by: Adam Wathan <4323180+adamwathan@users.noreply.github.com>
* ensure we wait in the `build` step as well
It looks like when running `astro build` we only run this `build` step
and not the `dev` step where we already use the `waitForRequestsIdle`
code.
Adding this to the `build` part as well does generate the correct
result.
* update changelog
* fix typo
* add comment
* Don’t run transforms more than necessary
* Don’t remove modules from the graph during SSR
* Update changelog
* Add `preview` script
---------
Co-authored-by: Jordan Pittman <jordan@cryptica.me>
* Don't read variables for shadow sizes
* Add UI test
* Handle key suffix in get function instead of ThemeKey
* Remove duplicate theme keys
* Format test in a less insane way
* Revert playground changes
* Update changelog
---------
Co-authored-by: Adam Wathan <4323180+adamwathan@users.noreply.github.com>