4264 Commits

Author SHA1 Message Date
Dany Castillo
de1bdb4f5d
Fix debug mode being active although explicitly disabled (#5837)
* fix debug mode being active although explicitly disabled

* also set debug mode correctly in sharedState
2021-10-25 11:25:25 +02:00
depfu[bot]
68f18bfa64 Update autoprefixer to version 10.3.7 2021-10-24 08:14:13 +00:00
Robin Malfait
ee3f3fd0be
Ensure comments in @layer rules don't crash (#5854)
* ensure comments in @layer rules don't crash

* update changelog
2021-10-22 15:19:21 +02:00
Robin Malfait
0ab39c312a
Allow _ inside url() when using arbitrary values (#5853)
* allow for underscores in url()

* update changelog
2021-10-22 14:43:46 +02:00
depfu[bot]
ae0e83dad0
Update eslint to version 8.0.1 (#5807)
Co-authored-by: depfu[bot] <23717796+depfu[bot]@users.noreply.github.com>
2021-10-22 06:40:36 -04:00
Robin Malfait
ea6f14a499
Dedupe duplicate properties (#5830)
* add `collapseDuplicateDeclarations`

This will allow us to remove duplicate declarations. This occurs when
you are using `@apply` for example.

The reason I implemented it as a separate step, is because this doesn't
only happen for `@apply`, but it also happens if you do something like:

```js
addComponents({ '.btn-blue, .btm-red': { padding: '10px' } })
```

So instead of tracking down every place this is happening, it now
happens at the very end.

* use new plugin in processTailwindFeatures

* add/update tests by removing duplicate declarations

* update changelog
2021-10-21 11:54:23 +02:00
Robin Malfait
0c2f1a6472
Remove prefix as a function (#5829)
* mark `prefix` as a function as a breaking change

* remove `prefix` as a function related code

* remove `prefix` as a function related tests

* update changelog
2021-10-19 15:22:49 +02:00
Robin Malfait
36c880abab
Improve before and after variants (#5820)
* remove unused `withRule`

* ensure all ::before and ::after elements have content

* update --tw-content for the content plugin

* simplify `before` and `after` variants

* update tests, to reflect changes

* make new `format` and `wrap` API's private for now

* allow returning a format string from `addVariant` callback

* add `content: var(--tw-content)` for before/after variants

* update tests to add `content: var(--tw-content)`

* update changelog
2021-10-18 18:11:34 +02:00
Robin Malfait
f12c0e1fa5
Improve css expectations in tests (#5819)
* use String.raw for css escapes

This will allow us to write code like:
```css
.mobile\:font-bold {}
```
Instead of
```css
.mobile\\:font-bold {}
```

Which resembles "real" css way better in our tests.

* use String.raw in integration tests as well
2021-10-18 12:08:48 +02:00
Robin Malfait
5809c4d07c
Improve addVariant API (#5809)
* fix incorrect comment

Probably messed this up in another PR, so just a bit of cleaning.

* implement a formatVariantSelector function

This will be used to eventually simplify the addVariant API.

The idea is that it can take a list of strings that define a certain
format. Then it squashes everything to a single format how you would
expect it.

E.g.:

Input:
  - '&:hover'
  - '&:focus'
  - '.dark &'
  - ':merge(.group):hover &'
  - ':merge(.group):focus &'
Output:
  - ':merge(.group):focus:hover .dark &:focus:hover'

The API here is:
  - `&`, this means "The parent" or "The previous selector" (you can
    think of it like if you are using nested selectors)
  - `:merge(.group)`, this means insert a `.group` if it doesn't exist
    yet, but if it does exist already, then merge the new value with the
    old value. This allows us to merge group-focus, group-hover into a
    single `.group:focus:hover ...`

* add new `format`, `withRule` and `wrap` API for addVariant

* implement backwards compatibility

This will ensure that the backwards compatibility for `modifySelectors`
and direct mutations to the `container` will still work.

We will try to capture the changes made to the `rule.selector`, we will
also "backup" the existing selector. This allows us to diff the old and
new selectors and determine what actually happened.

Once we know this, we can restore the selector to the "old" selector and
add the diffed string e.g.: `.foo &`, to the `collectedFormats` as if
you called `format()` directly. This is a bunch of extra work, but it
allows us to be backwards compatible.

In the future we could also warn if you are using `modifySelectors`, but
it is going to be a little bit tricky, because usually that's
implemented by plugin authors and therefore you don't have direct
control over this. Maybe we can figure out the plugin this is used in
and change the warning somehow?

* fix incorrect test

This was clearly a bug, keyframes should not include escaped variants at
all. The reason this is here in the first place is because the nodes in
a keyframe are also "rule" nodes.

* swap the order of pseudo states

The current implementation had a strange side effect, that resulted in
incorrect class definitions. When you are combining the `:hover` and
`:focus` event, then there is no difference between `:hover:focus` and
`:focus:hover`.

However, when you use `:hover::file-selector-button` or `::file-selector-button:hover`,
then there is a big difference. In the first place, you can hover over the full file input
to apply changes to the `File selector button`.
In the second scenario you have to hover over the `File selector button` itself to apply changes.

You can think of it as function calls:
- focus(hover(text-center))

What you would expect is something like this:
`.focus\:hover\:text-center:hover:focus`, where `hover` is on the
inside, and `focus` is on the outside. However in the current
implementation this is implemented as
`.focus\:hover\:text-cener:focus:hover`

* add more variant tests for the new API

* update parallel variants tests to make use of new API

* implement core variants with new API

* simplify/cleanup existing plugin utils

We can get rid of this because we drastically simplified the new
addVariant API.

* add addVariant shorthand signature

The current API looks like this:

```js
addVariant('name', ({ format, wrap }) => {
  // Wrap in an atRule
  wrap(postcss.atRule({ name: 'media', params: '(prefers-reduced-motion: reduce)' }))

  // "Mutate" the selector, for example prepend `.dark`
  format('.dark &')
})
```

It is also pretty common to have this:
```js
addVariant('name', ({ format }) => format('.dark &'))
```
So we simplified this to:
```js
addVariant('name', '.dark &')
```

It is also pretty common to have this:
```js
addVariant('name', ({ wrap }) => wrap(postcss.atRule({ name: 'media', params: '(prefers-reduced-motion: reduce)' })))
```
So we simplified this to:
```js
addVariant('name', '@media (prefers-reduced-motion: reduce)')
```

* improve fontVariantNumeric implementation

We will use `@defaults`, so that only the resets are injected for the
utilities we actually use.

* fix typo

* allow for nested addVariant shorthand

This will allow to write something like:

```js
addVariant('name', `
  @supports (hover: hover) {
    @media (print) {
      &:hover
    }
  }
`)
// Or as a one-liner
addVariant('name', '@supports (hover: hover) { @media (print) { &:hover } }')
```

* update changelog
2021-10-18 11:26:11 +02:00
Sachin Raja
aeaa2a376b
update build script name in CONTRIBUTING.md (#5814) 2021-10-17 10:09:28 -04:00
depfu[bot]
2bef641909 Update @swc/cli to version 0.1.51 2021-10-16 10:58:31 +00:00
depfu[bot]
c4c10d55d4 Update jest-diff to version 27.2.5 2021-10-15 14:14:00 +00:00
Brad Cornes
be36eba7cf Update changelog 2021-10-13 20:06:47 +01:00
Brad Cornes
84a6c5d096
Neaten extract.DEFAULT resolution (#5778) 2021-10-13 19:58:58 +01:00
Brad Cornes
92df04d0c3
Fix CLI --content option (#5775)
* Add failing test

* Fix CLI `--content` option
2021-10-13 19:58:15 +01:00
Adam Wathan
1a08732382 Update changelog 2021-10-13 10:06:12 -04:00
Brad Cornes
f599430d56
Configure awaitWriteFinish for chokidar (#5774)
* Configure `awaitWriteFinish` for chokidar

* Enable `awaitWriteFinish` on Windows only
2021-10-13 12:59:26 +01:00
Adam Wathan
a7c89c8813
Don't use pointer cursor on disabled buttons by default (#5772) 2021-10-13 06:11:28 -04:00
Adam Wathan
25c8223d60 Update changelog 2021-10-12 13:36:44 -04:00
MichaelAllenWarner
8259dfdf48
Add text-decoration-color utilities (#5760)
* utilities and tests in place for textDecorationColor and textDecorationOpacity

* change 'backgroundColor' to 'textDecorationColor' in corePlugin declaration for latter

* remove explicit textDecorationOpacity utility (the JIT slash syntax suffices)

Co-authored-by: Michael Warner <michaelwarner@Michaels-MacBook-Pro.local>
2021-10-12 13:35:59 -04:00
depfu[bot]
35a5e64bf6 Update esbuild to version 0.13.4 2021-10-12 14:58:39 +00:00
Adam Wathan
0e0d71205b Update changelog 2021-10-09 09:49:01 -04:00
Adam Wathan
d2b53cd3af
Add grow and shrink aliases (#5733)
This adds `grow-*` and `shrink-*` utilities as aliases for `flex-grow-*` and `flex-shrink-*` since those names are unnecessarily verbose. We will stop documenting the long form ones and consider them deprecated.

```diff
- <div class="flex-grow-0 flex-shrink">
+ <div class="grow-0 shrink">
```
2021-10-09 09:48:12 -04:00
Adam Wathan
6d04c2dcc7 Update changelog 2021-10-09 09:47:50 -04:00
Sung M. Kim
10886b3a35
Support all utilities in JIT mode: https://github.com/tailwindlabs/tailwindcss/discussions/5724 (#5734) 2021-10-09 09:46:58 -04:00
Adam Wathan
899a46088d Remove reference to undefined variable in DEBUG mode 2021-10-08 10:13:58 -04:00
Adam Wathan
70d3e7f5e8 Update changelog 2021-10-07 15:25:07 -04:00
Adam Wathan
3942469e9c Update changelog 2021-10-07 09:14:24 -04:00
Luke Warlow
f2d2a0e3cd
Add min-content and max-content utilities for (min/max) height (#5729) 2021-10-07 09:13:50 -04:00
Brad Cornes
30b76cf472 Use join instead of resolve and update path import
This fixes `pkg` bundling
2021-10-07 12:49:32 +01:00
Brad Cornes
5b4baea1d6 Use path.resolve instead of string concatenation
This allows the path to be statically analysed when bundling, for example with `pkg`
2021-10-07 12:33:23 +01:00
Robin Malfait
ee0f32908d
Ensure we log flag notices (#5726) 2021-10-07 12:52:53 +02:00
Luke Warlow
31a9860fe5
Add fit-content utilities for (min/max) height and width (#5638) 2021-10-07 06:08:22 -04:00
depfu[bot]
579e922fc8 Update glob-parent to version 6.0.2 2021-10-06 22:27:47 +00:00
Adam Wathan
6ce8864f47 Update changelog 2021-10-06 13:42:49 -04:00
Adam Wathan
97062c398b
Make negative values a first-class feature, rather than theme-driven (#5709)
* WIP

* Add failing test for negating default values

* Add dynamic negative value opt-in (#5713)

* Add `supportsNegativeValues` plugin option

* Update `getClassList` to support dynamic negative values

* Add test for using a negative scale value with a plugin that does not support dynamic negative values

* Support dynamic negation of `DEFAULT` values (#5718)

* Add test case

Co-authored-by: Brad Cornes <bradlc41@gmail.com>
2021-10-06 13:42:05 -04:00
Robin Malfait
b661614265
Enable optimize universal defaults by default (#5635)
* enabled `optimizeUniversalDefaults` by default

This PR is done in a way so that the default is set to `true`, but you
can still disable it if it causes issues. In this case we do appreciate
an issue in that case 😅.

* update tests to use optimized universal selector

* update integration tests

* add dedicated tests for the optimized universal selector

* improve minimumImpactSelector algorithm

I think I cracked the algorithm, but I will probably need another pair
of eyes on the subject.

The current implementation works like this:

Prerequisites:

- The selector should already have been parsed using the selectorParser
  from 'postcss-selector-parser'.

Algorithm:

1. Remove all of the pseudo classes from the list of nodes.
  1.1. We do want to keep pseudo elements (E.g.: `::before`, `::first-line`, ...)
  1.2. We do want to keep pseudo classes that contain nodes (E.g.:
    `:not(...)`)
2. Reverse the list of nodes.
  This will make it easier to search from the end to the start. For
  example `.group:hover .group-hover` should result in `.group-hover`
  not `.group`.
  2.1. Find the index of the best match (class, id, attribute), and
    convert the node if required. (E.g.: `span#app` -> `#app` => `[id="app"]`)
  2.2. Remove the rest of the selector that is not important anymore
  2.3. Re-join the left-over nodes together

* update tests using new algorithm

* also look for `tag` types

* take `tag` into account

* simplify logic

* add test to prove `rest.reverse()` in first case is required

In case we don't find a match (idx === -1), we use `rest.reverse()`.
However, it looks like you can just use `nodes` instead.
This is not entirely true, because the `rest` variable will contain only
the nodes that are not pseudo elements.

`*:hover` would result in `*:hover` instead of just `*`

* replace all nodes after > with a single universal selector
2021-10-06 17:45:26 +02:00
depfu[bot]
7b94feaef3 Update jest to version 27.2.4 2021-10-05 10:27:50 +00:00
Adam Wathan
cca75e67fb Update changelog 2021-10-04 15:53:52 -04:00
Adam Wathan
a2676b0544
Add flex-basis utilities (#5671) 2021-10-04 15:47:14 -04:00
depfu[bot]
778bd37838 Update is-glob to version 4.0.3 2021-10-03 22:57:43 +00:00
Adam Wathan
e362272631 Update changelog 2021-10-02 05:59:15 -04:00
depfu[bot]
abad3b1a10 Update @swc/core to version 1.2.92 2021-10-02 08:13:04 +00:00
Jonathan Reinink
d50b049ae5 Update changelog 2021-10-01 15:43:14 -04:00
Jonathan Reinink
6b26174921 Update changelog 2021-10-01 15:32:26 -04:00
Jonathan Reinink
ba06a102d2 Update changelog 2021-10-01 15:02:36 -04:00
Jonathan Reinink
53ae5d53d8 Update changelog 2021-10-01 13:45:41 -04:00
Robin Malfait
86b254abda
update integration tests for alpha version 2021-10-01 19:06:24 +02:00
Robin Malfait
c42ffc10a1
update integration tests for alpha version 2021-10-01 18:56:47 +02:00