203 Commits

Author SHA1 Message Date
Gary Mathews
722232cb2e
Allow all classes for @apply (#6580)
* Always include css with apply in context

* Use let

We use it more consistently

* Remove early return

To match the style of the surrounding code

* Don't return layer directives

They do not need to be returned here. If it's needed in the future its easy enough to add it back.

* Use let

* Update changelog

* fix typo

And re-format comments

Co-authored-by: Jordan Pittman <jordan@cryptica.me>
Co-authored-by: Robin Malfait <malfait.robin@gmail.com>
2022-01-04 14:23:10 +01:00
Robin Malfait
b9af5a916b
Improve collapsing of duplicate declarations (#6856)
* improve collapsing of duplicate properties

In theory, we don't have to do anything because the browser is smart
enough to figure everything out. However, leaving in duplicate
properties is not that ideal for file size.

Our previous method was pretty simple: if you see a declaration you
already saw in this rule, delete the previous one and keep the current
one.

This works pretty well, but this gets rid of **all** the declarations
with the same property. This is not great for overrides for older
browsers.

In a perfect world, we can handle this based on your target browser but
this is a lot of unnecessary complexity and will slow things down
performance wise.

Alternative, we improved the solution by being a bit smarter:
1. Delete duplicate declarations that have the same property and value
   (this will get rid of **exact** duplications).
2. Delete declarations with the same property and the same **unit**.

This means that we will reduce this:
```css
.example {
  height: 50%;
  height: 100px;
  height: 20vh;
  height: 30%;
  height: 50px;
  height: 30vh;
  transform: var(--value);
  transform: var(--value);
}
```

To:
```diff-css
  .example {
-   height: 50%;    /* Another height exists later with a `%` unit */
-   height: 100px;  /* Another height exists later with a `px` unit */
-   height: 20vh;   /* Another height exists later with a `vh` unit */
    height: 30%;
    height: 50px;
    height: 30vh;
-   transform: var(--value); /* Value is too complex, but is **exactly** the same as the one below */
    transform: var(--value);
  }
```

This will reduce the values that we are 100% sure that can be safely
removed. This will still result in some overrides but the browser can
handle those for you.

Fixes: #6844

* update changelog
2022-01-03 15:41:49 +01:00
Robin Malfait
3149738035
Properly detect theme() value usage in arbitrary properties (#6854)
* properly detect theme value in arbitrary properties

* update changelog
2022-01-03 13:12:43 +01:00
Robin Malfait
c912434e0b
Validate theme() works in arbitray values (#6852)
* add tests to ensure theme value inside arbitrary values work

* update changelog
2022-01-03 11:29:18 +01:00
Robin Malfait
b341813d3f
Ensure we can use < and > characters in modifiers (#6851)
* ensure we can use "special" characters in modifiers

Fixes: #6778

* update changelog
2022-01-03 11:17:58 +01:00
Robin Malfait
875c850b37
Improve DEBUG parsing: only take care of tailwindcss and not tailwind (#6804)
* only take care of `tailwindcss` and not `tailwind`

* update changelog
2021-12-30 16:41:23 +01:00
Robin Malfait
10710b08b9
Improve DEBUG flag (#6797)
* improve DEBUG flag

* update changelog
2021-12-29 23:51:30 +01:00
Adam Wathan
1d5aa27e79
Support HSL with hue units in arbitrary values (#6726) 2021-12-24 13:20:35 -05:00
Adam Wathan
da7396cf77 Sketching out more specific tests for our default extractor 2021-12-24 12:56:53 -05:00
Robin Malfait
86e73b2063
Ensure @apply of a rule inside an AtRule works (#6594)
* ensure apply of rule inside atrule works

If that atrule happens to contain another rule that is technically
unrelated.

Co-authored-by: Jordan Pittman <jordan@cryptica.me>

* update changelog

Co-authored-by: Jordan Pittman <jordan@cryptica.me>
2021-12-17 18:40:20 +01:00
Robin Malfait
9e03a6800b
Improve jsx interpolation candidate matching (#6593)
* ensure that strangely used jsx with interpolation gets detected

Co-authored-by: Luke Warlow <projects@warlow.dev>
Co-authored-by: Jordan Pittman <jordan@cryptica.me>

* update changelog

Co-authored-by: Luke Warlow <projects@warlow.dev>
Co-authored-by: Jordan Pittman <jordan@cryptica.me>
2021-12-17 17:32:50 +01:00
Jordan Pittman
27c67fef43
Properly extract classes with arbitrary values in arrays and classes followed by escaped quotes (#6590)
Co-authored-by: Robin Malfait <malfait.robin@gmail.com>
2021-12-17 10:15:36 -05:00
Robin Malfait
2fdbe108cb
Only generate variants for non-user layers (#6589)
* only generate variants for non-user layers

If you have the following css:

```css
@tailwind utilities;
.foo {
  color: red;
}
```

And you HTML looks like this:
```html
<div class="hover:foo"></div>
```

Then the output should _not_ generate a `.hover\:foo {}` class.

* ensure that you can apply user csss (without variants)

* update changelog
2021-12-17 14:49:07 +01:00
Robin Malfait
7089a80ea1
Improve circular dependency detection when using @apply (#6588)
* improve circular dependency detection when using `@apply`

I also changed the message to the same message we used in V2.

* update changelog
2021-12-17 13:39:32 +01:00
Jordan Pittman
6cf3e3e55f
Don't mutate custom color palette when overriding per-plugin colors (#6546) 2021-12-16 16:19:54 -05:00
Jonathan Reinink
ec911c73f0 Improve order of color properties in transition and transition-colors utilities 2021-12-15 14:09:27 -05:00
Jonathan Reinink
1c7a793c94 Update order of color properties in transition and transition-colors utilities 2021-12-15 13:49:13 -05:00
Felix Klein
9934174867
Add 'text-decoration-color' to default 'transition' and 'transition-colors' utilities (#6405)
* Add 'text-decoration-color' to default 'transition' and 'transition-colors' utilities

* Add 'text-decoration-color' to default 'transition' and 'transition-colors' utilities

* Delete tailwind-output-flagged.css

* Delete tailwind-output-important.css

* Delete tailwind-output-no-color-opacity.css

* Delete tailwind-output.css

Co-authored-by: Jonathan Reinink <jonathan@reinink.ca>
2021-12-15 13:44:51 -05:00
Robin Malfait
0783a4275e
remove unused fixture files 2021-12-15 18:13:09 +01:00
Robin Malfait
deb68d5816
Ensure all plugins are executed for a given candidate (#6540)
* remove early return so that all plugins are handled

We had an early return so that once a plugin was matched, that we could
stop running the code through the other plugins. However, in this case
we have an issue that user defined css is technically also a plugin.

This means that:
  - `bg-green-light`
Would check for:
  - `bg-green-light` (no hit, continue)
  - `bg-green` (Hit! Don't execute next plugins)
  - `bg` (This is the one that would have generated `bg-green-light`)

We tested this change and it doesn't seem to have an impact functionally
and also not really performance wise.

* update changelog
2021-12-15 18:07:26 +01:00
Jordan Pittman
08a07f6e02
Support square bracket notation in paths (#6519) 2021-12-15 11:09:29 -05:00
Robin Malfait
083bca3d3f
Insert always on defaults layer in correct spot (#6526)
* insert in correct spot

We were injecting the always on `@tailwind defaults` layer at the beginning of
the file. However, if a `@tailwind base` layer is available, then that
will now be injected _after_ the defaults layer. The base layer does
contain some reset that are now overriding the defaults we set.

So now we will:
- Insert the `@tailwind defaults` layer at the beginning of the file
  _if_ there is no `@tailwind base`
- Insert the `@tailwind defaults` layer after the `@tailwind base` layer
  if it exists.

* update changelog
2021-12-15 12:34:53 +01:00
Simon J
a7263a8f6f
Add support for negative values in safelist patterns (#6480)
Co-authored-by: Simon Jarrett <simon.jarrett@churchmissionsociety.org>
2021-12-14 15:55:26 -05:00
Jordan Pittman
4041d04b89
Move defaults to their own always-on layer (#6500)
Default's declarations are now processed and merged even when there is no tailwind base directive included in the stylesheet. Without this applying tailwind utilities in css modules would break if they relied on defaults rules.

Co-authored-by: Robin Malfait <malfait.robin@gmail.com>
2021-12-14 12:21:38 -05:00
Oliver Williams
95dd82b749
use text-decoration-line instead of text-decoration (#6378)
* use text-decoration-line instead of text-decoration

* fix tests

Co-authored-by: Oliver Williams <oliver@Olivers-MacBook-Pro.local>
2021-12-13 16:09:14 -05:00
Jordan Pittman
399440eef1
Don't output unparsable values (#6469) 2021-12-13 12:39:17 -05:00
Robin Malfait
4b2482ff35
Warn about invalid globs in content (#6449)
* rewrite invalid globs if we can

* warn instead of rewrite

* update changelog
2021-12-13 16:00:31 +01:00
Jordan Pittman
429fe07a5f
Fix defaults optimization when vendor prefixes are involved (#6369) 2021-12-10 10:45:33 -05:00
Robin Malfait
08241c3f75
Detect circular dependencies when using @apply (#6365)
* detect circular dependencies when using `@apply`

* update changelog

* ensure we split by the separator
2021-12-10 16:08:45 +01:00
Robin Malfait
81f52a24f4
Ensure complex variants with multiple classes work (#6311)
* ensure complex variants with multiple classes work

* update changelog
2021-12-10 10:57:40 +01:00
Robin Malfait
36357786bf
Partially revert tuple syntax PR for screens: #6104 (#6289)
* partially revert tuple syntax PR for `screens`: #6104

* update changelog
2021-12-07 18:49:40 +01:00
Robin Malfait
b857d80e94
Ensure that we test every value for the length datatype (#6283)
* ensure that we test every value for the `length` datatype

* update changelog
2021-12-06 20:19:45 +01:00
Adam Wathan
c48e629955 Support negative scale values 2021-12-06 10:47:16 -05:00
Adam Wathan
9749e340e7 Use real files for custom transformer test 2021-12-04 13:38:40 -05:00
Robin Malfait
ea139f20a2
Improve [0] arbitrary value support (#6259)
* test `text-[0]` instead of `w-[0]`

* update changelog
2021-12-03 19:23:01 +01:00
Robin Malfait
078186a1ef
Add css functions to data types (#6258)
* update changelog

* add tests to verify that `w-[0]` works

* ensure that `min`, `max` and `clamp` also work with arbitrary values

* update changelog
2021-12-03 18:15:03 +01:00
Robin Malfait
12ea363e1a
Fix decoration utility ambiguity (#6217)
* remove `any` data type for decoration color plugin

The main reason for the `any` type is so that we don't have to parse the
value and can assume that this plugin handles "any" value you give it.

This is useful because `decoration-[var(--something)]` would be
correctly translated to the correct decoration property. However, we
introduce another plugin with the same `decoration` prefix.

This means that now both `textDecorationColor` and
`textDecorationThickness` have the same base utility name: `decoration`.

- `textDecorationColor` had ['color', 'any']
- `textDecorationThickness` had ['length', 'percentage']

This means that `3px` fit both in the `length` data type of the
`textDecorationThickness` plugin and in the `any` data type of the
`textDecorationColor` plugin.

Removing the `any` fixes this.

TL;DR: Only have `any` when there are no conflicting utility names.

* remove utility that doesn't generate css

Having `decoration-[var(--abc)]` is ambiguous because there are multiple
plugins that have a `decoration` utility name. In order for this to work
you have to prefix it with the type: `decoration-[color:var(--abc)]`
which is already tested in this file.
2021-11-29 15:25:43 +01:00
Robin Malfait
6b82ca89bc
Fix modifiers for arbitrary values (#6199)
* fix modifiers for arbitrary properties

The main issue was that we are splitting on the separator and popping
the last section of to know the _base_ utility. However, in this case it
would be something like `markers]` which is incorrect.

Instead we only split by the separator and ignore the separtor if it
exists between square brackets.

* add tests for modifiers + arbitrary values that contain the separator
2021-11-25 15:07:43 +01:00
Adam Wathan
22b7cb5418 Fix mistake in test to cause test to fail 2021-11-25 07:05:33 -05:00
Oscar Lee-Vermeren
d22604af04
Add remaining text-decoration utilities (#6004)
* Add `text-decoration-style` utilities

* Add remaining `text-decoration` utilities

* Add test for default underline offset

* Remove text-underline-position, don't rename underline utilities, remove DEFAULT values for decoration thickness and underline offset

* Add auto/from-font values, update tests

Co-authored-by: Adam Wathan <adam.wathan@gmail.com>
2021-11-24 12:13:08 -05:00
Luke Warlow
a321e3c843
Add variants for orientation media feature (#6046)
* Add variants for orientation media feature

* Rename to portrait and landscape

Co-authored-by: Adam Wathan <adam.wathan@gmail.com>
2021-11-23 14:59:25 -05:00
Adam Wathan
d261531e2a
Add support for arbitrary properties (#6161)
* Basic implementation + some failing tests for edge cases

* Use asClass instead of nameClass

* Solve edge cases around content with colons

* Avoid duplicating work when parsing arbitrary properties

* Update changelog
2021-11-22 12:38:37 -05:00
Robin Malfait
03f9de9008
Add combinable touch-action support (#6115)
* add combinable `touch-action` support

* update changelog
2021-11-17 16:04:13 +01:00
Robin Malfait
ef325ea35b
Add tuple syntax to guarantee screens order (#6104)
* add normalizeScreens function

This will allow us to normalize the various kinds of inputs to a stable
version that is consistent regardless of the input.

* use normalized screens

* add dedicated test for new tuple syntax

* make test consistent with other tests

While working on the normalizeScreens feature, some tests started
failing (the one with multiple screens), while looking at them I made
them consistent with the rest of the codebase.

* add test to ensure consistent order in screens output

* update changelog

* Update CHANGELOG.md

* Update CHANGELOG.md

Co-authored-by: Adam Wathan <adam.wathan@gmail.com>
2021-11-16 18:01:06 +01:00
Robin Malfait
6c4b86d438
Add placeholder variant (#6106)
* add `placeholder` variant

* update changelog
2021-11-16 15:33:30 +01:00
Robin Malfait
a3579bcf2f
Enforce the order of pseudo elements (#6018)
* enforce the order of some variants

* update changelog

* use better algorithm
2021-11-12 16:38:03 +01:00
Robin Malfait
4e21639903
Improve nesting detection (#6011) 2021-11-10 13:15:32 +01:00
Adam Wathan
a6bcd22722 Add test for using variants with multi-class selectors 2021-11-06 07:25:32 -04:00
Robin Malfait
7eabb74bec
add test to prove @supports is kept in @layer rule (#5992) 2021-11-05 15:12:35 +01:00
Adam Wathan
d1f066d97a
Add support for colored box shadows (#5979)
* WIP

* add box shadow parser

* use box shadow parser

* Update default shadows, add boxShadowColor key, add shadow datatype

* Update tests

* add `valid` flag to `boxShadow` parser

Co-authored-by: Robin Malfait <malfait.robin@gmail.com>
2021-11-04 10:14:13 -04:00