303 Commits

Author SHA1 Message Date
Jordan Pittman
deefbf5aaf
Handle theme keys with slashes when using theme() in CSS (#8831)
* Fix lookup of `theme(…)` paths with slashes in them

* Update changelog
2022-07-11 10:47:17 -04:00
Tmk
6729524185 Support font-weight in font-size utilities (#8763)
* Support font-weight in font-size utilities

* WIP update tests

* Update changelog

Co-authored-by: Jordan Pittman <jordan@cryptica.me>
2022-07-04 17:01:06 -04:00
Jordan Pittman
102977530e
Add support for alpha values in safelist (#8774)
Co-authored-by: Petr Novak <petr.nmn.novak@gmail.com>
2022-07-04 16:37:38 -04:00
Jordan Pittman
8494f7515d
Don’t prefix selectors in arbitrary variants (#8773)
* Don’t prefix selectors in arbitrary variants

* Update changelog
2022-07-04 14:52:24 -04:00
Jordan Pittman
5191ec1c00
Fix usage of special-character prefixes (#8772)
* Fix import

* Support arbitrary prefixes

* Add test

* Update changelog
2022-07-04 14:42:27 -04:00
Jordan Pittman
00af2e8947
Don’t add spaces around raw / that are preceded by numbers (#8688)
* Don’t add spaces around raw `/` that are preceded by numbers

* Update changelog
2022-06-20 10:49:55 -04:00
Jordan Pittman
c5e7857362
Detect arbitrary variants with quotes (#8687)
* Refactor

* Support variants with quotes in them

We have to have two regexes here because this is actually ambiguous in the general case. The regex that generally handles `[&[foo='bar']]` would incorrectly match `['bar':'baz']` for instance. So, instead we’ll use multiple regexes and match both!

* Update changelog
2022-06-20 09:56:40 -04:00
Jordan Pittman
9778b528dc
Provide default to <alpha-value> when using theme() (#8652)
* Ensure default alpha is 1.0 when using new `<alpha-value>` format with the theme function

* Update changelog
2022-06-15 15:11:08 -04:00
Jordan Pittman
15dc5a3da9
Remove text opacity CSS variables from ::marker (#8622)
* Refactor

* Allow parallel variant fns to mutate the container

* Remove text color variable from marker pseudo class

wip

* Update changelog
2022-06-14 10:09:09 -04:00
Adam Wathan
22eaad17c3
Fix "Maximum call stack size exceeded" bug (#8636)
* Fix potential call stack size issue

* Update defaultExtractor.js

* add test to verify "Maximum call stack size exceeded" is fixed

* update changelog

Co-authored-by: Robin Malfait <malfait.robin@gmail.com>
2022-06-14 14:17:40 +02:00
Jordan Pittman
1c24d7a473
Detect alpha value in CSS theme() function when using quotes (#8625)
* Allow alpha value inside quotes

* Optimize regex

* Add test

* Update changelog
2022-06-13 15:32:52 -04:00
Dany Castillo
aad299cf90
Fix missing spaces around arithmetic operators (#8615)
* add tests for spaced around operators in CSS math functions

* fix CSS math functons besides calc not getting the love they deserve

* improve comment

* update changelog

* update changelog

Co-authored-by: Robin Malfait <malfait.robin@gmail.com>
2022-06-13 11:58:07 +02:00
Jordan Pittman
037396b4a6
Ignore PostCSS nodes returned by addVariant (#8608)
* Fix issue with returning postcss nodes in addVariant

It’s not a supported use case but it didn’t use to break so let’s just fail silently

* Update changelog
2022-06-12 10:50:41 -04:00
Jordan Pittman
a9c7e52a59
Fix extraction of multi-word utilities with arbitrary values and quotes (#8604)
* Fix extraction of multi-word utilityies with arbitrary values and quotes

* Update  changelog

* Fix changelog entry

This wasn’t in 3.1.2 oops
2022-06-12 10:10:10 -04:00
Robin Malfait
d32728b433
Ensure \ is a valid arbitrary variant token (#8576)
* `\` are valid arbitrary variant tokens

We use `\` for escaping `.` or `_` so they should be part of the
arbitrary variant regex.

* update changelog
2022-06-10 10:51:16 +02:00
Jordan Pittman
0664aae901
Fix class detection in markdown code fences and slim templates (#8569)
* Fix detection of classes in markdown code fences

* Fix candidate detection in `.slim` templates

* Update changelog
2022-06-09 16:53:02 -04:00
Jordan Pittman
6b1eb19079
Split ::backdrop into separate defaults group (#8567)
* Split `::backdrop` into separate defaults group

* Update tests

* Update changelog
2022-06-09 16:26:18 -04:00
Jordan Pittman
7aa2d4ddf3
Don’t clip slashes inside brackets when using the theme function (#8563) 2022-06-09 14:09:57 -04:00
Robin Malfait
9a5db88e54
Fix candidate extractor regression (#8558)
* fix regression

This is a regression where `%>utility<%` didn't properly abstract
`utility`

* update changelog
2022-06-09 18:22:20 +02:00
Adam Wathan
4f400767a8
Add ::backdrop to universal defaults (#8526)
* Add `::backdrop` to universal defaults

* Update changelog
2022-06-06 15:53:08 -04:00
Jordan Pittman
64b4e6df7b
Replace rgb and hsl helpers with <alpha-value> placeholder for colors with custom properties (#8501)
* implement <alpha-value>

* remove `rgb`/`hsl` helpers, use `<alpha-value>` instead

* never pass undefined to `withAlphaValue`

* WIP

* WIP

* WIP

* WIP

* Update changelog

* Cleanup

Co-authored-by: Robin Malfait <malfait.robin@gmail.com>
2022-06-02 10:21:20 -04:00
Adam Wathan
c65a1a2a79
Don't inherit gradient "to" from parent (#8489)
* Don't inherit gradient "to" from parent

* Update changelog
2022-06-01 15:25:45 -04:00
Adam Wathan
fca70850b2
Add optional variant (#8486)
* Add  variant

* Update changelog
2022-06-01 08:39:43 -04:00
Adam Wathan
2b944c5b10 Skip tests ending in .test.skip.js 2022-06-01 06:16:39 -04:00
Jordan Pittman
34fd0fb82a Feature flag matchVariant API 2022-05-31 13:15:14 -04:00
Robin Malfait
d2fdf9eb09
Allow returning parallel variants from addVariant or matchVariant callback functions (#8455)
* allow to return an array of format strings from matchVariant or
addVariant

* add parallel variant with function test

* upgrade test to use a function call

* allow to return parallel variants from variant function

Caveat: this now belongs to the same plugin and is not registered as
separate variants which means that sort order can differ.

* prevent crash if `.toMatchFormattedCss()` receives undefined

* update changelog

* ensure that we use a local list of variant functions

Now that a variant function can return a list of variant functions from
within the plugin, we have to make sure to executed and register those
functions as well.

However, we need to make sure that this list is local for the variant
and not "globally" registered otherwise we keep add a dynamic function
to the global list which results in duplicate output becaus multiple
duplicate variants will be registered.

* add little warning regarding potential clashes

* Update CHANGELOG.md
2022-05-31 15:03:06 +02:00
Jordan Pittman
3f4005e833 Disable filterDefault for ring opacity when using respectDefaultRingColorOpacity 2022-05-27 09:59:52 -04:00
Jordan Pittman
cab1fcecc5
Add future flag to preserve custom, default ring color opacity (#8448)
* Add future flag to preserve ring color opacity

* Update changelog
2022-05-27 09:48:27 -04:00
Jordan Pittman
50bed74cdc
Support alpha values for theme() function (#8416)
* Fix typo

* Support alpha modifier for theme color values

* Eliminate redundant object creation in resolveFunctionKeys

Building an object of N keys incrementally using Object.reduce + splat results in N intermediate objects. We should just create one object and assign each key.

* Switch to inline theme values in theme fn in config

* Add test case

And fix typos that were definitely not there

* Update changelog
2022-05-25 13:54:30 -04:00
Jordan Pittman
50024e4603 Fix grouping using different variant types inside nested groups 2022-05-23 15:43:12 -04:00
Jordan Pittman
b0e1f47b94 Be more direct about variant group extractions
Also adds a previously failing but now passing test case
2022-05-23 15:29:29 -04:00
Robin Malfait
68ff4ba500
Experimental support for variant grouping (#8405)
* WIP

* use correct separator

* run all tests

* Fix regex

* add a few more tests

* name the experimental feature flag `variantGrouping`

* update changelog

* rename test file `variant-grouping`

Co-authored-by: Jordan Pittman <jordan@cryptica.me>
2022-05-23 17:45:23 +02:00
Robin Malfait
816a0f26c9
Add prefers-contrast media query variants (#8410)
* Add prefers-contrast variants

* add tests for prefers contrast

* dark mode should have precedence over prefers contrast variants

* update changelog

Co-authored-by: Luke Warlow <projects@warlow.dev>
2022-05-23 17:40:14 +02:00
Adam Wathan
128030fcfa
Only apply hover styles when supported (future) (#8394)
* Only apply hover styles when supported (future)

Co-Authored-By: Andrew Brown <browner12@gmail.com>

* update changelog

Co-authored-by: Andrew Brown <browner12@gmail.com>
Co-authored-by: Robin Malfait <malfait.robin@gmail.com>
2022-05-20 11:20:20 -04:00
Adam Wathan
bb4f5dab6b
Fix matchVariants that use at-rules and placeholders (#8392)
* Fix matchVariants that use at-rules and placeholders

* update changelog

* Update CHANGELOG.md

* Only parseVariant when result is defined

Co-authored-by: Robin Malfait <malfait.robin@gmail.com>
2022-05-20 10:33:36 -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
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
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
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
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
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
Brad Cornes
cc696338b1
Improve type detection for arbitrary color values (#8201) 2022-04-28 11:18:51 +01: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
7ed46b6f52 Re-enable new features
This reverts commits 1456ed9021b3455dbb4458c2fb7d8ab66dfb3fed, d0269c24b3c7ad4557b7e3f2779bd15c5ac501f7, and 57699a04036c542d82e7b7102d775d4d2379493d.
2022-04-12 14:13:04 -04:00