Commit graph

4646 commits

Author SHA1 Message Date
Jordan Pittman
880ceb49c9 WIP 2022-05-18 12:05:26 -04:00
Jordan Pittman
b756b00ba1 Fix build 2022-05-18 11:40:02 -04:00
Jordan Pittman
f54152b19e Fix CS 2022-05-18 11:35:53 -04:00
Jordan Pittman
52828f0100 Push candidate object into finalizeSelector 2022-05-18 10:45:01 -04:00
Jordan Pittman
b811c698fe Fix rebase problem 2022-05-18 10:13:51 -04:00
Jordan Pittman
16349e74c4 WIP 2022-05-18 10:12:15 -04:00
Jordan Pittman
cd24c5904b WIP 2022-05-18 10:12:15 -04:00
Jordan Pittman
985e35722b WIP 2022-05-18 10:12:15 -04:00
Jordan Pittman
5bcd9d2f69 WIP 2022-05-18 10:12:15 -04:00
Jordan Pittman
3cb47aaab6 Add test 2022-05-18 10:12:15 -04:00
Jordan Pittman
92000a5820 Stop double-parsing variants 2022-05-18 10:12:15 -04:00
Jordan Pittman
c8be920468 Use candidate object in applyImportant 2022-05-18 10:12:15 -04:00
Jordan Pittman
3192f2a007 Use object in recordCandidates 2022-05-18 10:12:15 -04:00
Jordan Pittman
90209cfda8 Use candidate object in extractArbitraryProperty
By this point arbitrary properties have been validated to be parsable. They aren’t valid candidates if they can’t be parsed (because they won’t produce valid CSS). This means all the checks in here can go away because the candidate parsing has handled it already.
2022-05-18 10:12:15 -04:00
Jordan Pittman
f66873f35e Use parsed object in resolveMatchedPlugins 2022-05-18 10:12:14 -04:00
Jordan Pittman
5fe5a65029 Use new candidate parsing in resolveMatches 2022-05-18 10:12:14 -04:00
Jordan Pittman
0f98fec7f0 Add new candidate object 2022-05-18 10:12:14 -04:00
Jordan Pittman
39c7a93f22 De-nest applyVariant 2022-05-18 10:09:59 -04:00
Jordan Pittman
3ac72b7e7d Move CSS validation helpers to separate file
wip
2022-05-18 10:09:58 -04:00
Robin Malfait
fc25299aa6
Add matchVariant API (#8310)
* update regex extractor

* implement `matchVariant` API

* add `matchVariant` test

* add `values` option to the `matchVariant` API

* move `matchVariant` tests to own file

* update changelog
2022-05-17 18:08:42 +02:00
Jordan Pittman
6c63f67d20
Create tailwind.config.cjs file in ESM package when running init (#8363)
* refactor

* Adds support for tailwind.config.cjs files to CLI

* Update changelog

Co-authored-by: Nate Moore <nate@natemoo.re>
2022-05-16 10:53:03 -04:00
Jordan Pittman
0313f02e2c
Move some config error checking out of resolveConfig (#8362) 2022-05-16 10:10:40 -04:00
depfu[bot]
638c8f43ea Update @swc/jest to version 0.2.21 2022-05-15 05:12:55 +00:00
Adam Wathan
177a00b156 Update changelog 2022-05-14 14:06:24 -04:00
Adam Wathan
7fa2a200b2
Reject invalid custom and arbitrary variants (#8345)
* WIP

Still need to write error message

* Update error message

first pass at something better

* Detect invalid variant formats returned by functions

* Add proper error message

Co-authored-by: Jordan Pittman <jordan@cryptica.me>
2022-05-14 13:58:02 -04:00
depfu[bot]
e41bf3d2a7 Update eslint to version 8.15.0 2022-05-13 21:44:02 +00:00
depfu[bot]
96a83534b0 Update esbuild to version 0.14.38 2022-05-10 14:27:59 +00:00
Jordan Pittman
b49dc7cafa
Move important selector to the front when @apply-ing selector-modifying variants in custom utilities (#8313)
* Fix generated utilities using `@apply` with important selectors

* Update changelog
2022-05-09 14:20:36 -04:00
Robin Malfait
be51739337
Arbitrary variants (#8299)
* register arbitrary variants

With the new `addVariant` API, we have a beautiful way of creating new
variants.

You can use it as:
```js
addVariant('children', '& > *')
```

Now you can use the `children:` variant. The API uses a `&` as a
reference for the candidate, which means that:
```html
children:pl-4
```

Will result in:
```css
.children\:pl-4 > * { .. }
```

Notice that the `&` was replaced by `.children\:pl-4`.

We can leverage this API to implement arbitrary variants, this means
that you can write those `&>*` (Notice that we don't have spaces) inside
a variant directly. An example of this can be:
```html
<ul class="[&>*]:underline">
  <li>A</li>
  <li>B</li>
  <li>C</li>
</ul>
```
Which generates the following css:
```css
.\[\&\>\*\]\:underline > * {
  text-decoration-line: underline;
}
```

Now all the children of the `ul` will have an `underline`. The selector
itself is a bit crazy since it contains the candidate which is the
selector itself, it is just escaped.

* add tests for arbitrary variants

This still requires some work to the `defaultExtractor` to make sure it
all works with existing code.

* update changelog

* Fix candidate detection for arbitrary variants

* Refactor

* Add support for at rules

* Add test for attribute selectors

* Fix test

* Add attribute selector support

* Split top-level comma parsing into a generalized splitting routine

We can now split on any character at the top level with any nesting. We don’t balance brackets directly here but this is probably “enough”

* Split variants by separator at the top-level only

This means that the separator has to be ouside of balanced brackets

* Fix extraction when using custom variant separators

* Support custom separators when top-level splitting variants

* Add a second multi-character separator test

* Split tests for at-rule and at-rule with selector changes

* Add nested at-rule tests

* Fix space-less at-rule parsing in addVariant

* Add test for using with `@apply`

Co-authored-by: Jordan Pittman <jordan@cryptica.me>
Co-authored-by: Adam Wathan <adam.wathan@gmail.com>
2022-05-08 12:24:59 -04:00
Adam Wathan
cea3ccf14d Update changelog 2022-05-07 16:05:34 -04:00
James Ross
f0026a45ba
feat: add plus-lighter support for mix-blend-mode (#8288) 2022-05-07 16:04:53 -04:00
Jordan Pittman
67d2286838
Try using local postcss installation first in the CLI (#8270)
* Load local PostCSS package if available

* Update changelog
2022-05-05 10:43:09 -04:00
Jordan Pittman
d676086a75
Rewrite default class extractor (#8204)
* Rewrite default extractor

* Eliminate lookbehind assertions in expand apply at rules

* Update changelog
2022-05-04 16:08:25 -04:00
Adam Wathan
bb0ab6744b
Update CHANGELOG.md 2022-05-04 13:02:02 -04:00
Nestor Vera
220e3501af
Add missing .grid-flow-dense utility (#8193) 2022-05-04 13:01:26 -04:00
depfu[bot]
94c05d50f2
Update jest-diff to version 28.0.2 (#8257)
Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com>
2022-05-04 13:00:48 -04:00
depfu[bot]
1c2789dd1e
Update jest to version 28.0.3 (#8266)
Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com>
2022-05-04 11:11:41 +02:00
Jordan Pittman
1402be2dd0
Handle utilities with multiple and/or grouped selectors better (#8262)
* Add failing test cases

* Flatten finalizeSelector code

* Use AST operations to format selector classes

With this change we only parse the selector once and operate on the AST until we need to turn it back into a selector. In addition this lets us solve an issue where .replace(…) did the wrong thing because it doesn’t understand that .base and .base-foo are two different classes

* Remove extraneous, non-matching selectors from utilities

* Update changelog
2022-05-03 13:10:27 -04:00
Jordan Pittman
7c337f24fc
Only check selectors containing apply candidates for circular dependencies (#8222)
* Only check selectors containing base apply candidates for circular dependencies

When given a two rule like `html.dark .a, .b { … }` and `html.dark .c { @apply b }` we would see `.dark` in both the base rule and the rule being applied and consider it a circular dependency. However, the selectors `html.dark .a` and `.b` are considered on their own and is therefore do not introduce a circular dependency.

This better matches the user’s mental model that the selectors are just two definitions sharing the same properties.

* Update changelog
2022-05-02 11:11:21 -04:00
Jordan Pittman
3989f77dd3 Update PostCSS version 2022-05-02 10:32:00 -04:00
Stefan Rumzucker
c3381d90a5
Remove default [hidden] style in preflight (#8248)
* Remove default `[hidden]` style in preflight

* Update snapshots

* Update changelog

Co-authored-by: Jordan Pittman <jordan@cryptica.me>
2022-05-02 10:30:06 -04:00
depfu[bot]
85b8e449e9 Update autoprefixer to version 10.4.5 2022-04-30 21:58:22 +00:00
Jordan Pittman
122fb89e6c
Support postcss config options in config file in the CLI (#8226)
* Support config options from postcss CLI

* Update changelog
2022-04-28 15:14:36 -04:00
Brad Cornes
922191450b Update changelog 2022-04-28 11:20:13 +01:00
Brad Cornes
cc696338b1
Improve type detection for arbitrary color values (#8201) 2022-04-28 11:18:51 +01:00
Jordan Pittman
89bf2ed46d
Fix intellisense for plugins with multiple @apply rules (#8213)
* Fix intellisense for plugins with multiple `@apply` rules

Intellisense uses `expandApplyAtRules` directly and doesn’t partition them. When a plugin registers components using something like `”@apply flex”: {}` more than once in the same component intellisense will break. This isn’t a problem for Tailwind CSS proper because we do rule partitioning. Given that Intellisense is using it directly though we shouldn’t outright break in the face of this situation even if the result isn’t 100% accurate (the source maps won’t be correct in this case).

* Update changelog

Co-authored-by: psucoder <hungle.info@gmail.com>
2022-04-27 12:09:20 -04:00
depfu[bot]
38535511dd Update prettier to version 2.6.2 2022-04-27 13:45:52 +00:00
depfu[bot]
2bf5a5ffb8 Update prettier-plugin-tailwindcss to version 0.1.10 2022-04-26 19:43:16 +00:00
Jordan Pittman
e010788574 Simplify apply handling
Pulling from perParentApplies here is unncessary as it’s never going to get any value
2022-04-26 14:27:28 -04:00
Gerard Nesta
1cc1ace142
Fixed date (#8152)
3.0.24 was released on april, not may
2022-04-19 07:46:48 -04:00