4622 Commits

Author SHA1 Message Date
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
depfu[bot]
3d20308a85 Update esbuild to version 0.14.36 2022-04-19 02:28:01 +00:00
depfu[bot]
c0a4980555 Update @swc/cli to version 0.1.57 2022-04-18 12:29:03 +00:00
depfu[bot]
aedfc6c7dd Update eslint to version 8.13.0 2022-04-15 21:45:01 +00:00
Jordan Pittman
67bf8167d1
Allow arbitrary values with commas in @apply (#8125)
* De-indent code

* Allow arbitrary values with commas in `@apply`

* Update changelog
2022-04-15 16:23:30 -04:00
Jordan Pittman
e5ed08b5cb
Handle duplicate atrules without children (#8122)
* Handle duplicate atrules without children

We assumed that all At Rule nodes had children. Including ones that do not and should not — for example `@import url(…);`. Since this is not the case we’ll skip adding children for nodes that don’t have any.

* Update changelog

Co-authored-by: Jordi Marimon Palarea <jordimarimon7@gmail.com>
2022-04-15 12:24:27 -04:00
Jordan Pittman
5c76de72ba
Require matching prefix when detecting negatives (#8121)
* Require matching prefix when detecting negatives

* Update changelog
2022-04-15 11:57:06 -04:00
Michaël Gallego
206f1d6df5
Make font weight inherit in preflight (#8078)
* Make font weight inherit

* Update snapshots

* Update changelog

Co-authored-by: Adam Wathan <adam.wathan@gmail.com>
2022-04-15 11:26:24 -04:00
Jordan Pittman
34c1e36c2a
Don’t split vars with numbers in them inside arbitrary values (#8091)
* Don’t mangle vars with numbers in them

* Update changelog
2022-04-13 09:31:10 -04:00
Jordan Pittman
1d4c5c78bd Update changelog 2022-04-12 14:29:17 -04:00
Jordan Pittman
7ed46b6f52 Re-enable new features
This reverts commits 1456ed9021b3455dbb4458c2fb7d8ab66dfb3fed, d0269c24b3c7ad4557b7e3f2779bd15c5ac501f7, and 57699a04036c542d82e7b7102d775d4d2379493d.
2022-04-12 14:13:04 -04:00
Jordan Pittman
23a6d3ff84 3.0.24 v3.0.24 2022-04-12 14:11:22 -04:00
Jordan Pittman
1456ed9021 Fix integration test 2022-04-12 14:06:50 -04:00
Jordan Pittman
d0269c24b3 Temp fix CS errors 2022-04-12 14:03:24 -04:00
Jordan Pittman
b89c3796db Update changelog 2022-04-12 14:00:22 -04:00
Jordan Pittman
57699a0403
Prep for patch release (#8098)
* Disable backdrop variant

* Disable enabled variant

* Disable border spacing utilities

* Disable text-start/end utilities

* Disable poll option in CLI

* Disable ring color default fn

* Disable dark mode class name customization

* Disable support for `Document` node types

* Disable rgb/hsl fns

* Update tests

* Temporarily disable type generation

* Update changelog
2022-04-12 13:58:57 -04:00
West
c1ed8dd59f
Redirect to the up-to-date plugin url (#8081) 2022-04-11 13:06:10 -04:00
depfu[bot]
f6eeed34a0 Update cssnano to version 5.1.7 2022-04-10 11:58:03 +00:00
depfu[bot]
50629f68ac Update postcss-selector-parser to version 6.0.10 2022-04-06 21:13:12 +00:00
depfu[bot]
5d49604606 Update postcss-load-config to version 3.1.4 2022-04-05 11:13:20 +00:00
Brad Cornes
6fc8d777da
Update screens types (#8042) 2022-04-05 11:46:50 +01:00
Brad Cornes
b9dec5feb7
Update theme.fontSize types (#8040) 2022-04-04 14:35:33 +01:00
Robin Malfait
2d3a748d1f
Ensure the percentage data type is validated correctly (#8015)
* ensure the `percentage` data type is validated correctly

When checking for our data types, we have to make sure that each part is
correct, this wasn't happening for the `percentage` data type, which
meant that `top_right_50%` was a valid percentage value because it ended
in `%` which is not correct.

Because of this, the generated code was non-existent because we got a
warning:

  The class `bg-[top_right_50%]` is ambiguous and matches multiple utilities.
     Use `bg-[length:top_right_50%]` for `background-size: top right 50%`
     Use `bg-[position:top_right_50%]` for `background-position: top right 50%`
   If this is content and not a class, replace it with `bg-&lsqb;top_right_50%&rsqb;` to silence this warning.

But this is not correct because this can never be a valid background
size due to the `top right` section.

This fixes it by validating each part individually, and now we get
generated css.

* update changelog
2022-04-01 12:37:22 +02:00
Robin Malfait
010f787f5f
Types: allow for arbitrary theme values (for 3rd party plugins) (#7926)
* allow for arbitrary configuration in the `theme` section

This is useful for third party plugins otherwise you will get an error.

* WIP: `theme()` utility function code completion

This will give you code completion in the `theme()` function. The reason
it is still a WIP is that this only works with the default config right
now and not 100% sure if it is possible to define generics in JSDoc.

The idea would be to:
- Provide types from the default config
- Provide types from the custom config (e.g.: 3rd party plugin)
- Override default config types with the overrides of the user's config

Right now this only provides types for the defaultConfig which might
result in dropping all of this in favor of a much simpler:

```ts
theme<D = any>(path: string, defaultValue: D) => D
```

But this sadly doesn't give you "nice" auto completion. However, the
default might be good enough if we don't error on for example
`theme('customPlugin')` which is currently not the case.

* update changelog

* undo all `theme` types, and type it as `theme(path: string): any`

Since currently we don't want to investigate time to make the code
completion *perfect* (because it might be even impossible to do it
properly due to resolving of overrides, extend and deeply nested presets)

For now we will provide a way simpler type, which is better than
incorrect types. So far we only had types for the default config theme
*only*.
2022-03-31 23:58:31 +02:00
depfu[bot]
8ba3d61a82 Update lilconfig to version 2.0.5 2022-03-30 23:43:26 +00:00