94 Commits

Author SHA1 Message Date
Robin Malfait
2fedbe0194
Bump dependencies (#13741)
* bump dependencies

* update tests to reflect Lightning CSS change
2024-05-25 14:43:59 +02:00
Robin Malfait
0e92310caf
Bump dependencies (#13738)
* run `pnpm update --recursive`

* update tests to reflect lightningcss bump

It looks like it's mainly (re-)ordering properties. Not 100% sure why
though.
2024-05-24 15:07:44 +02:00
Wes Bos
3116d656f1
Add ESM build of the @tailwindcss/postcss package (#13693)
* 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>
2024-05-23 01:01:56 +02:00
Robin Malfait
5e737d8587
4.0.0-alpha.15 (#13658) 2024-05-08 19:26:59 +02:00
Jordan Pittman
aceec2ea39
Add fallbacks for @property rules for Firefox (#13655)
* Add `@property` fallbacks for Firefox

* Update tests

* Update changelog
2024-05-08 12:39:10 -04:00
Robin Malfait
3a5934006a
Revert "Remove automatic var(…) injection (#13537)"
This reverts commit cd4711cc21b8790d52ff62ffa8bfc03d4e031fdb.
2024-05-08 17:56:09 +02:00
Robin Malfait
cb17447ff1
Ensure strings are consumed as-is when using internal segment() (#13608)
* 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
2024-04-30 12:22:11 -04:00
Adam Wathan
719c0d4883 Improve comment 2024-04-27 12:32:59 -04:00
Brandon McConnell
1bdc906976
Allow hyphen character in regex pattern to use support queries as is (#13596)
* 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>
2024-04-27 12:28:59 -04:00
Robin Malfait
cd4711cc21
Remove automatic var(…) injection (#13537)
* 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
2024-04-19 00:40:52 +02:00
Robin Malfait
b83576ee6d
colocate css-parser benchmark file in src folder (#13543) 2024-04-18 16:12:54 +02:00
Robin Malfait
cc8c069f72
Further improve natural sorting of classes (#13532)
* 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>
2024-04-16 18:12:42 +02:00
Robin Malfait
cd0c308afe
Improve sorting candidates containing numbers (#13507)
* 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>
2024-04-15 17:56:30 +02:00
Justin Wong
b07cc4d3bd
Fix contain-* utilities (#13521)
* Fix contain-* utilities

Fixes #13520.

* Update changelog

* Update CHANGELOG.md

---------

Co-authored-by: Adam Wathan <adam.wathan@gmail.com>
2024-04-13 05:56:15 -04:00
Adam Wathan
0060508c6e
Declare character code constants per file (#13500)
Co-authored-by: Adam Wathan <4323180+adamwathan@users.noreply.github.com>
2024-04-11 12:44:44 +02:00
Robin Malfait
6da3f4a37f
Colocate charcode tokens (#13497)
* 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
2024-04-11 00:29:55 +02:00
Robin Malfait
45dd25ec38
fix typo "envionment" -> "environment" (#13496) 2024-04-10 18:17:11 -04:00
Maxwell Barvian
7347cddb9a
[v4] Switch default breakpoints to rem (#13469)
* Switch breakpoints to rem #8378

* Fix broken test

* Update snapshots

---------

Co-authored-by: Adam Wathan <4323180+adamwathan@users.noreply.github.com>
2024-04-09 21:04:58 -04:00
Robin Malfait
ce0a7347da
4.0.0-alpha.14 (#13487) 2024-04-09 20:55:54 +02:00
Vinicius Lourenço
3c7073f397
Perf: Use charCodeAt instead of string comparison (#13393)
* Use charCodeAt instead of string comparison

* Rename some things

* Fix lint issues

---------

Co-authored-by: Adam Wathan <4323180+adamwathan@users.noreply.github.com>
2024-04-09 13:25:56 -04:00
Adam Wathan
818692fe17
Don't accommodate hidden elements in space/divide (#13459)
* Don't accommodate hidden elements in space/divide

* Update tests

* Update changelog

---------

Co-authored-by: Adam Wathan <4323180+adamwathan@users.noreply.github.com>
2024-04-09 12:59:08 -04:00
Robin Malfait
d1eedb2324
Invert variant order application (#13478)
* 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>
2024-04-09 11:37:56 -04:00
Robin Malfait
4a25bc1fd5
Ensure deterministic SSR builds in @tailwindcss/vite (#13457)
* 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>
2024-04-08 18:10:08 -04:00
Adam Wathan
2719903e56 Update versions for alpha.13 2024-04-04 18:03:36 -04:00
Adam Wathan
cc6094e84f
Don't read variables for shadow sizes (#13449)
* 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>
2024-04-04 18:01:37 -04:00
Robin Malfait
34fea0e3d3
4.0.0-alpha.12 (#13448) 2024-04-04 17:43:02 +02:00
ottomated
5db92a4ceb
Speed up segmentation (#13415)
* Speed up segmentation

* Add segment benchmark

* Add and move comments

* Update

* Tweak comments

* Tweak variable name

* Tweak

---------

Co-authored-by: Jordan Pittman <jordan@cryptica.me>
2024-04-02 16:43:37 -04:00
Aaron Adams
be94e21136
Correct repository fields in package.json files (#13416) 2024-03-31 15:20:53 -04:00
Adam Wathan
4aefd26f44
Don't reset ::first-letter in Preflight (#13408)
* Don't reset ::first-letter in Preflight

* Update changelog

---------

Co-authored-by: Adam Wathan <4323180+adamwathan@users.noreply.github.com>
2024-03-30 08:06:53 -04:00
Jordan Pittman
a79fa45bf2
Make isColor faster (#13404)
When the arrays of colors were split, both smaller, and had different values to lookup an `includes` check was faster. Since they’ve been merged a Set is now beneficial.
2024-03-29 09:15:09 -04:00
Jordan Pittman
500372e728
Enable Vite's waitForRequestsIdle() for client requests only (#13394)
* Enable `waitForRequestsIdle` but only when not doing SSR

* Cleanup comment

* Update changelog
2024-03-28 22:57:16 -04:00
Jordan Pittman
855cd94ff0
Prepare next release: 4.0.0-alpha.11 (#13382)
* bump versions to `4.0.0-alpha.11`

* Update changelog

* Update changelog

* Update changelog

* Update changelog
2024-03-27 13:32:10 -04:00
Kris Braun
89eb1ba060
Fix Vite serve issues (#13380)
* Temporarily disable waitForRequestIdle

* Only apply vite:css-post in build mode
2024-03-27 12:31:54 -04:00
Robin Malfait
c815221249
Ensure build command is executed when using --output instead of -o (#13369) 2024-03-27 16:10:55 +01:00
Robin Malfait
99c4afd9cd
update comments to better describe what's going on (#13348) 2024-03-25 15:49:14 -04:00
Jordan Pittman
fee039d82f
Inherit letter spacing in form controls (#13328)
* Inherit letter spacing in form controls

* Update changelog

* Update snapshots
2024-03-22 16:01:39 -04:00
Adam Wathan
59038c5734
Include :popover-open in open variant (#13331)
* Include :popover-open in open variant

Co-Authored-By: Luke Warlow <lwarlow@igalia.com>

* Update changelog

* Remove accidental package.json change

* Revert playground changes

---------

Co-authored-by: Adam Wathan <4323180+adamwathan@users.noreply.github.com>
Co-authored-by: Luke Warlow <lwarlow@igalia.com>
2024-03-22 16:00:07 -04:00
Adam Wathan
de79455b0e
Add variant for @starting-style (#13329)
* Add variant for @starting-style

Co-Authored-By: Han Yeong-woo <han@yeongwoo.dev>

* Update changelog

---------

Co-authored-by: Adam Wathan <4323180+adamwathan@users.noreply.github.com>
Co-authored-by: Han Yeong-woo <han@yeongwoo.dev>
2024-03-22 15:38:06 -04:00
Kris Braun
3249777383
Process Tailwind output with Vite CSS plugins (#13218)
Transform Tailwind-generated CSS with Vite CSS plugins. vite:css does useful things like transforming url() paths and inlining images. vite:css-post generates bundle hashes. Before this change, the CSS bundle hash wasn't changing when the generated CSS changed.

Also adds Vite 5.2 peerDependancy.

---------

Co-authored-by: Jordan Pittman <jordan@cryptica.me>
2024-03-22 14:57:44 -04:00
Robin Malfait
fcdb3279ea
Fix incorrect syntax for translate-z's @property definition (#13327)
* fix incorrect syntax for `translate-z`

This used to be `<length-percentage>`, but we dropped percentage support
because it's not valid in #13321 and I forgot about this one.

* update changelog
2024-03-22 19:49:46 +01:00
Adam Wathan
0f69d4fe6e
[v4] Make 3D rotations composable (#13319)
* Reorganize to co-locate rotate/skew/transform

* Make 3D rotations composable

* Uppercase axis in rotate functions

* Update changelog

---------

Co-authored-by: Adam Wathan <4323180+adamwathan@users.noreply.github.com>
2024-03-22 13:31:57 -04:00
Robin Malfait
86dd6976f0
Remove percentage values for translate-z utilities (#13321)
* handle `translate-z` separately

* do not support fractions for `translate-z`

* update changelog
2024-03-22 17:19:18 +01:00
Robin Malfait
8840019efa
Prepare next release: 4.0.0-alpha.10 (#13281)
* bump versions to `4.0.0-alpha.10`

* update changelog

* Update changelog

---------

Co-authored-by: Adam Wathan <4323180+adamwathan@users.noreply.github.com>
2024-03-21 13:32:03 -04:00
Adam Wathan
b5df5e9202
Use variables with fallbacks for utility classes (#13177)
* Use variables with fallbacks for utility classes

* Update playwright test

* rename `resolveBare` to `resolveValue`

* make private methods really private

---------

Co-authored-by: Adam Wathan <4323180+adamwathan@users.noreply.github.com>
Co-authored-by: Robin Malfait <malfait.robin@gmail.com>
2024-03-21 18:25:43 +01:00
Robin Malfait
a3cedf253a
Improve transform, transform-cpu and transform-gpu utilities (#13290)
* fix `transform-gpu` translate syntax

* move `skewX` and `skewY` functions into the variable

* use `transform-[…]` with arbitrary values as-is

This will not have any fallbacks to the `skewX` or `skewY` functions.
The arbitrary values will be the only value that's used.

* use `--tw-skew-{x,y}` variables in `transform-cpu` and `transform-gpu`

* update tests

* drop `skewX` and `skewY` functions because they are embedded in the `--tw-skew-x` and `--tw-skew-y` CSS variables

* drop `transform-cpu` and `transform-gpu`

* add `translate-none`, `transform-none`, `rotate-none` and `scale-none`

* ensure `transform` creates a stacking context

* use `<transform-function>` instead of `<angle>`

* re-add `transform-gpu`

* drop the `,`, because `--tw-skew-x` and `--tw-skew-y` will always be defined by the `@property`

* `translate(0)` is not necessary because `--tw-skew-{x,y}` will always be defined

* add skew variables to `transform-gpu`

Otherwise skew's will be gone

* re-add `transform-cpu`
2024-03-21 17:51:15 +01:00
Robin Malfait
6a6186c24a
Remove bare value support for translate utilities (#13289)
* make `themeKeys` optional and default to `[]`

* remove `themeKeys` that already map 1:1 to a number or percentage

These can be handled by bare values without issues.

* remove fallback theme key lookup

- In case of `columns`, bare values can be used for the amount of columns
- In case of `divide-width`, we can always look at `--border-width`

* drop theme keys from suggestions

* drop bare value support for `translate-{axis}`

* add todo

* Revert "remove `themeKeys` that already map 1:1 to a number or percentage"

This reverts commit ef3b47aaee6af563d900b6fa3be283d860ac738e.

* Revert "remove fallback theme key lookup"

This reverts commit 0a5fc2dd394ba9375313720c1d8190f64f246486.

* Revert "drop theme keys from suggestions"

This reverts commit 7179a19517367431516d6f1f74ba3b7cc2271fc1.

* Revert "add todo"

This reverts commit 7340cdfcf87a22482e0c2c3af2b17b832e90cbab.
2024-03-21 17:40:19 +01:00
Kris Braun
85c3b2b6a2
Use Vite waitForRequestsIdle (#13291) 2024-03-20 16:40:50 -04:00
Adam Wathan
89a0b86e73
Remove bare value handling for perspective utilities (#13288)
* Remove bare value handling for perspective utilities

* move `perspective-123` example

This is now moved to the spot where we ensure that nothing is generated
at all. This prevents us from accidentally updating a snapshot and
missing a potential bug.

* update changelog

---------

Co-authored-by: Adam Wathan <4323180+adamwathan@users.noreply.github.com>
Co-authored-by: Robin Malfait <malfait.robin@gmail.com>
2024-03-20 15:25:24 +01:00
Kris Braun
dadb096da2
3D transform utilities (#13248)
* 3D rotation utilities

* Validate rotate values

* Replace forEach with for loop

* transform-style, transform-box, and backface-visibility utilities

* Tests for transform utilities

* 'perspective' utility

* Fix tests

* Remove unnecessary suggestion; move function comments

* scale-z

* Fix Intellisense test

* perspective-origin

* scale-3d

* Only include the z component of scale if it's defined

We want to avoid triggerring unnecessary 3D transformations.

* Comment the reason for setting --tw-rotate

* Test full bare rotate

* Fix merge

* Comment on rotate arbitrary value

* perspective bare values

Support `perspective-123` (but not `perspective-potato`)

* scale-3d as a static modifier to scale

Instead of scale-3d taking a separate scale, it modifies scale to apply in three dimensions.

* Test that scale-x overrides scale

* scale arbitrary values

Support arbitrary value for scale (e.g. `scale-[1_2_3.5]`).

* Specify rotation axis using a modifier

Support single rotation angles in line with the [CSS `rotate` property](https://developer.mozilla.org/en-US/docs/Web/CSS/rotate). Using modifiers (e.g. `rotate-45/x`) makes it clearer that the axis of rotation is modified. Thanks @adamwathan for this suggestion.

Composing angles is only supported in CSS via a pipeline of `transform` functions. I'll add arbitrary value support to `transform` next as an escape hatch for those cases that need more complex transformations.

* Use property defaults for scale-3d

* `transform` arbitrary values

Support arbitrary values for `transform`. The `skew-x` and `skew-y` transforms are applied before any arbitrary transformations.

* Add translate-z and translate-3d

Both work the same way as scale-z and scale-3d.

* Add translate-[xyz]-px

* Comment on how skewX and skewY are applied

* Remove unnecessary suggest

* Simplify translate

* Fix up comment on rotate syntax

* Back to rotate-x and rotate-y rather than rotate modifiers

* 3D transform test fixes
2024-03-19 17:52:32 +01:00
Robin Malfait
d2be632635
Skip newlines when parsing selectors (#13280)
* replace "\n" with " " when parsing CSS

* add test to ensure important whitespace is preserved
2024-03-19 16:23:14 +01:00