2021-09-09 15:22:50 +02:00
|
|
|
import fs from 'fs'
|
2021-10-07 12:49:32 +01:00
|
|
|
import * as path from 'path'
|
Remove AOT (#5340)
* make `jit` mode the default when no mode is specified
* unify JIT and AOT codepaths
* ensure `Object.entries` on undefined doesn't break
It could be that sometimes you don't have values in your config (e.g.: `presets: []`), this in turn will break some plugins where we assume we have a value.
* drop AOT specific tests
These tests are all covered by JIT mode already and were AOT specific.
* simplify tests, and add a few
Some of the tests were written for AOT specifically, some were missing. We also updated the way we write those tests, essentially making Tailwind a blackbox, by testing against the final output.
Now that JIT mode is the default, this is super fast because we only generate what is used, instead of partially testing in a 3MB file or building it all, then purging.
* add some todo's to make sure we warn in a few cases
* make `darkMode: 'media'`, the default
This also includes moving dark mode tests to its own dedicated file.
* remove PostCSS 7 compat mode
* update CLI to be JIT-first
* fix integration tests
This is not a _real_ fix, but it does solve the broken test for now.
* warn when using @responsive or @variants
* remove the JIT preview warning
* remove AOT-only code paths
* remove all `mode: 'jit'` blocks
Also remove `variants: {}` since they are not useful in `JIT` mode
anymore.
* drop unused dependencies
* rename `purge` to `content`
* remove static CDN builds
* mark `--purge` as deprecated in the CLI
This will still work, but a warning will be printed and it won't show up
in the `--help` output.
* cleanup nesting plugin
We don't have to duplicate it anymore since there is no PostCSS 7
version anymore.
* make sure integration tests run in band
* cleanup folder structure
* make sure nesting folder is available
* simplify resolving of purge/content information
2021-09-01 17:13:59 +02:00
|
|
|
import postcss from 'postcss'
|
2021-09-09 15:22:50 +02:00
|
|
|
import createUtilityPlugin from './util/createUtilityPlugin'
|
Remove AOT (#5340)
* make `jit` mode the default when no mode is specified
* unify JIT and AOT codepaths
* ensure `Object.entries` on undefined doesn't break
It could be that sometimes you don't have values in your config (e.g.: `presets: []`), this in turn will break some plugins where we assume we have a value.
* drop AOT specific tests
These tests are all covered by JIT mode already and were AOT specific.
* simplify tests, and add a few
Some of the tests were written for AOT specifically, some were missing. We also updated the way we write those tests, essentially making Tailwind a blackbox, by testing against the final output.
Now that JIT mode is the default, this is super fast because we only generate what is used, instead of partially testing in a 3MB file or building it all, then purging.
* add some todo's to make sure we warn in a few cases
* make `darkMode: 'media'`, the default
This also includes moving dark mode tests to its own dedicated file.
* remove PostCSS 7 compat mode
* update CLI to be JIT-first
* fix integration tests
This is not a _real_ fix, but it does solve the broken test for now.
* warn when using @responsive or @variants
* remove the JIT preview warning
* remove AOT-only code paths
* remove all `mode: 'jit'` blocks
Also remove `variants: {}` since they are not useful in `JIT` mode
anymore.
* drop unused dependencies
* rename `purge` to `content`
* remove static CDN builds
* mark `--purge` as deprecated in the CLI
This will still work, but a warning will be printed and it won't show up
in the `--help` output.
* cleanup nesting plugin
We don't have to duplicate it anymore since there is no PostCSS 7
version anymore.
* make sure integration tests run in band
* cleanup folder structure
* make sure nesting folder is available
* simplify resolving of purge/content information
2021-09-01 17:13:59 +02:00
|
|
|
import buildMediaQuery from './util/buildMediaQuery'
|
2021-09-09 15:22:50 +02:00
|
|
|
import parseAnimationValue from './util/parseAnimationValue'
|
|
|
|
|
import flattenColorPalette from './util/flattenColorPalette'
|
|
|
|
|
import withAlphaVariable, { withAlphaValue } from './util/withAlphaVariable'
|
|
|
|
|
import toColorValue from './util/toColorValue'
|
|
|
|
|
import isPlainObject from './util/isPlainObject'
|
|
|
|
|
import transformThemeValue from './util/transformThemeValue'
|
2021-09-28 17:09:16 +01:00
|
|
|
import { version as tailwindVersion } from '../package.json'
|
Remove AOT (#5340)
* make `jit` mode the default when no mode is specified
* unify JIT and AOT codepaths
* ensure `Object.entries` on undefined doesn't break
It could be that sometimes you don't have values in your config (e.g.: `presets: []`), this in turn will break some plugins where we assume we have a value.
* drop AOT specific tests
These tests are all covered by JIT mode already and were AOT specific.
* simplify tests, and add a few
Some of the tests were written for AOT specifically, some were missing. We also updated the way we write those tests, essentially making Tailwind a blackbox, by testing against the final output.
Now that JIT mode is the default, this is super fast because we only generate what is used, instead of partially testing in a 3MB file or building it all, then purging.
* add some todo's to make sure we warn in a few cases
* make `darkMode: 'media'`, the default
This also includes moving dark mode tests to its own dedicated file.
* remove PostCSS 7 compat mode
* update CLI to be JIT-first
* fix integration tests
This is not a _real_ fix, but it does solve the broken test for now.
* warn when using @responsive or @variants
* remove the JIT preview warning
* remove AOT-only code paths
* remove all `mode: 'jit'` blocks
Also remove `variants: {}` since they are not useful in `JIT` mode
anymore.
* drop unused dependencies
* rename `purge` to `content`
* remove static CDN builds
* mark `--purge` as deprecated in the CLI
This will still work, but a warning will be printed and it won't show up
in the `--help` output.
* cleanup nesting plugin
We don't have to duplicate it anymore since there is no PostCSS 7
version anymore.
* make sure integration tests run in band
* cleanup folder structure
* make sure nesting folder is available
* simplify resolving of purge/content information
2021-09-01 17:13:59 +02:00
|
|
|
import log from './util/log'
|
2019-02-05 13:36:41 -05:00
|
|
|
|
2021-10-01 17:31:09 +02:00
|
|
|
export let variantPlugins = {
|
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
|
|
|
pseudoElementVariants: ({ addVariant }) => {
|
|
|
|
|
addVariant('first-letter', '&::first-letter')
|
|
|
|
|
addVariant('first-line', '&::first-line')
|
2021-07-01 05:59:47 -04:00
|
|
|
|
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
|
|
|
addVariant('marker', ['& *::marker', '&::marker'])
|
|
|
|
|
addVariant('selection', ['& *::selection', '&::selection'])
|
Remove AOT (#5340)
* make `jit` mode the default when no mode is specified
* unify JIT and AOT codepaths
* ensure `Object.entries` on undefined doesn't break
It could be that sometimes you don't have values in your config (e.g.: `presets: []`), this in turn will break some plugins where we assume we have a value.
* drop AOT specific tests
These tests are all covered by JIT mode already and were AOT specific.
* simplify tests, and add a few
Some of the tests were written for AOT specifically, some were missing. We also updated the way we write those tests, essentially making Tailwind a blackbox, by testing against the final output.
Now that JIT mode is the default, this is super fast because we only generate what is used, instead of partially testing in a 3MB file or building it all, then purging.
* add some todo's to make sure we warn in a few cases
* make `darkMode: 'media'`, the default
This also includes moving dark mode tests to its own dedicated file.
* remove PostCSS 7 compat mode
* update CLI to be JIT-first
* fix integration tests
This is not a _real_ fix, but it does solve the broken test for now.
* warn when using @responsive or @variants
* remove the JIT preview warning
* remove AOT-only code paths
* remove all `mode: 'jit'` blocks
Also remove `variants: {}` since they are not useful in `JIT` mode
anymore.
* drop unused dependencies
* rename `purge` to `content`
* remove static CDN builds
* mark `--purge` as deprecated in the CLI
This will still work, but a warning will be printed and it won't show up
in the `--help` output.
* cleanup nesting plugin
We don't have to duplicate it anymore since there is no PostCSS 7
version anymore.
* make sure integration tests run in band
* cleanup folder structure
* make sure nesting folder is available
* simplify resolving of purge/content information
2021-09-01 17:13:59 +02:00
|
|
|
|
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
|
|
|
addVariant('file', '&::file-selector-button')
|
Remove AOT (#5340)
* make `jit` mode the default when no mode is specified
* unify JIT and AOT codepaths
* ensure `Object.entries` on undefined doesn't break
It could be that sometimes you don't have values in your config (e.g.: `presets: []`), this in turn will break some plugins where we assume we have a value.
* drop AOT specific tests
These tests are all covered by JIT mode already and were AOT specific.
* simplify tests, and add a few
Some of the tests were written for AOT specifically, some were missing. We also updated the way we write those tests, essentially making Tailwind a blackbox, by testing against the final output.
Now that JIT mode is the default, this is super fast because we only generate what is used, instead of partially testing in a 3MB file or building it all, then purging.
* add some todo's to make sure we warn in a few cases
* make `darkMode: 'media'`, the default
This also includes moving dark mode tests to its own dedicated file.
* remove PostCSS 7 compat mode
* update CLI to be JIT-first
* fix integration tests
This is not a _real_ fix, but it does solve the broken test for now.
* warn when using @responsive or @variants
* remove the JIT preview warning
* remove AOT-only code paths
* remove all `mode: 'jit'` blocks
Also remove `variants: {}` since they are not useful in `JIT` mode
anymore.
* drop unused dependencies
* rename `purge` to `content`
* remove static CDN builds
* mark `--purge` as deprecated in the CLI
This will still work, but a warning will be printed and it won't show up
in the `--help` output.
* cleanup nesting plugin
We don't have to duplicate it anymore since there is no PostCSS 7
version anymore.
* make sure integration tests run in band
* cleanup folder structure
* make sure nesting folder is available
* simplify resolving of purge/content information
2021-09-01 17:13:59 +02:00
|
|
|
|
2021-10-18 18:11:34 +02:00
|
|
|
addVariant('before', ({ container }) => {
|
|
|
|
|
container.walkRules((rule) => {
|
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
|
|
|
let foundContent = false
|
|
|
|
|
rule.walkDecls('content', () => {
|
|
|
|
|
foundContent = true
|
Remove AOT (#5340)
* make `jit` mode the default when no mode is specified
* unify JIT and AOT codepaths
* ensure `Object.entries` on undefined doesn't break
It could be that sometimes you don't have values in your config (e.g.: `presets: []`), this in turn will break some plugins where we assume we have a value.
* drop AOT specific tests
These tests are all covered by JIT mode already and were AOT specific.
* simplify tests, and add a few
Some of the tests were written for AOT specifically, some were missing. We also updated the way we write those tests, essentially making Tailwind a blackbox, by testing against the final output.
Now that JIT mode is the default, this is super fast because we only generate what is used, instead of partially testing in a 3MB file or building it all, then purging.
* add some todo's to make sure we warn in a few cases
* make `darkMode: 'media'`, the default
This also includes moving dark mode tests to its own dedicated file.
* remove PostCSS 7 compat mode
* update CLI to be JIT-first
* fix integration tests
This is not a _real_ fix, but it does solve the broken test for now.
* warn when using @responsive or @variants
* remove the JIT preview warning
* remove AOT-only code paths
* remove all `mode: 'jit'` blocks
Also remove `variants: {}` since they are not useful in `JIT` mode
anymore.
* drop unused dependencies
* rename `purge` to `content`
* remove static CDN builds
* mark `--purge` as deprecated in the CLI
This will still work, but a warning will be printed and it won't show up
in the `--help` output.
* cleanup nesting plugin
We don't have to duplicate it anymore since there is no PostCSS 7
version anymore.
* make sure integration tests run in band
* cleanup folder structure
* make sure nesting folder is available
* simplify resolving of purge/content information
2021-09-01 17:13:59 +02:00
|
|
|
})
|
2021-10-18 18:11:34 +02:00
|
|
|
|
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
|
|
|
if (!foundContent) {
|
2021-10-18 18:11:34 +02:00
|
|
|
rule.prepend(postcss.decl({ prop: 'content', value: 'var(--tw-content)' }))
|
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
|
|
|
}
|
|
|
|
|
})
|
Remove AOT (#5340)
* make `jit` mode the default when no mode is specified
* unify JIT and AOT codepaths
* ensure `Object.entries` on undefined doesn't break
It could be that sometimes you don't have values in your config (e.g.: `presets: []`), this in turn will break some plugins where we assume we have a value.
* drop AOT specific tests
These tests are all covered by JIT mode already and were AOT specific.
* simplify tests, and add a few
Some of the tests were written for AOT specifically, some were missing. We also updated the way we write those tests, essentially making Tailwind a blackbox, by testing against the final output.
Now that JIT mode is the default, this is super fast because we only generate what is used, instead of partially testing in a 3MB file or building it all, then purging.
* add some todo's to make sure we warn in a few cases
* make `darkMode: 'media'`, the default
This also includes moving dark mode tests to its own dedicated file.
* remove PostCSS 7 compat mode
* update CLI to be JIT-first
* fix integration tests
This is not a _real_ fix, but it does solve the broken test for now.
* warn when using @responsive or @variants
* remove the JIT preview warning
* remove AOT-only code paths
* remove all `mode: 'jit'` blocks
Also remove `variants: {}` since they are not useful in `JIT` mode
anymore.
* drop unused dependencies
* rename `purge` to `content`
* remove static CDN builds
* mark `--purge` as deprecated in the CLI
This will still work, but a warning will be printed and it won't show up
in the `--help` output.
* cleanup nesting plugin
We don't have to duplicate it anymore since there is no PostCSS 7
version anymore.
* make sure integration tests run in band
* cleanup folder structure
* make sure nesting folder is available
* simplify resolving of purge/content information
2021-09-01 17:13:59 +02:00
|
|
|
|
2021-10-18 18:11:34 +02:00
|
|
|
return '&::before'
|
|
|
|
|
})
|
Remove AOT (#5340)
* make `jit` mode the default when no mode is specified
* unify JIT and AOT codepaths
* ensure `Object.entries` on undefined doesn't break
It could be that sometimes you don't have values in your config (e.g.: `presets: []`), this in turn will break some plugins where we assume we have a value.
* drop AOT specific tests
These tests are all covered by JIT mode already and were AOT specific.
* simplify tests, and add a few
Some of the tests were written for AOT specifically, some were missing. We also updated the way we write those tests, essentially making Tailwind a blackbox, by testing against the final output.
Now that JIT mode is the default, this is super fast because we only generate what is used, instead of partially testing in a 3MB file or building it all, then purging.
* add some todo's to make sure we warn in a few cases
* make `darkMode: 'media'`, the default
This also includes moving dark mode tests to its own dedicated file.
* remove PostCSS 7 compat mode
* update CLI to be JIT-first
* fix integration tests
This is not a _real_ fix, but it does solve the broken test for now.
* warn when using @responsive or @variants
* remove the JIT preview warning
* remove AOT-only code paths
* remove all `mode: 'jit'` blocks
Also remove `variants: {}` since they are not useful in `JIT` mode
anymore.
* drop unused dependencies
* rename `purge` to `content`
* remove static CDN builds
* mark `--purge` as deprecated in the CLI
This will still work, but a warning will be printed and it won't show up
in the `--help` output.
* cleanup nesting plugin
We don't have to duplicate it anymore since there is no PostCSS 7
version anymore.
* make sure integration tests run in band
* cleanup folder structure
* make sure nesting folder is available
* simplify resolving of purge/content information
2021-09-01 17:13:59 +02:00
|
|
|
|
2021-10-18 18:11:34 +02:00
|
|
|
addVariant('after', ({ container }) => {
|
|
|
|
|
container.walkRules((rule) => {
|
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
|
|
|
let foundContent = false
|
|
|
|
|
rule.walkDecls('content', () => {
|
|
|
|
|
foundContent = true
|
2021-09-24 18:57:01 +02:00
|
|
|
})
|
Remove AOT (#5340)
* make `jit` mode the default when no mode is specified
* unify JIT and AOT codepaths
* ensure `Object.entries` on undefined doesn't break
It could be that sometimes you don't have values in your config (e.g.: `presets: []`), this in turn will break some plugins where we assume we have a value.
* drop AOT specific tests
These tests are all covered by JIT mode already and were AOT specific.
* simplify tests, and add a few
Some of the tests were written for AOT specifically, some were missing. We also updated the way we write those tests, essentially making Tailwind a blackbox, by testing against the final output.
Now that JIT mode is the default, this is super fast because we only generate what is used, instead of partially testing in a 3MB file or building it all, then purging.
* add some todo's to make sure we warn in a few cases
* make `darkMode: 'media'`, the default
This also includes moving dark mode tests to its own dedicated file.
* remove PostCSS 7 compat mode
* update CLI to be JIT-first
* fix integration tests
This is not a _real_ fix, but it does solve the broken test for now.
* warn when using @responsive or @variants
* remove the JIT preview warning
* remove AOT-only code paths
* remove all `mode: 'jit'` blocks
Also remove `variants: {}` since they are not useful in `JIT` mode
anymore.
* drop unused dependencies
* rename `purge` to `content`
* remove static CDN builds
* mark `--purge` as deprecated in the CLI
This will still work, but a warning will be printed and it won't show up
in the `--help` output.
* cleanup nesting plugin
We don't have to duplicate it anymore since there is no PostCSS 7
version anymore.
* make sure integration tests run in band
* cleanup folder structure
* make sure nesting folder is available
* simplify resolving of purge/content information
2021-09-01 17:13:59 +02:00
|
|
|
|
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
|
|
|
if (!foundContent) {
|
2021-10-18 18:11:34 +02:00
|
|
|
rule.prepend(postcss.decl({ prop: 'content', value: 'var(--tw-content)' }))
|
2021-09-24 18:57:01 +02:00
|
|
|
}
|
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
|
|
|
})
|
2021-10-18 18:11:34 +02:00
|
|
|
|
|
|
|
|
return '&::after'
|
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
|
|
|
})
|
2021-09-24 18:57:01 +02:00
|
|
|
},
|
|
|
|
|
|
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
|
|
|
pseudoClassVariants: ({ addVariant }) => {
|
2021-09-24 18:57:01 +02:00
|
|
|
let pseudoVariants = [
|
|
|
|
|
// Positional
|
2021-09-28 11:13:58 -04:00
|
|
|
['first', ':first-child'],
|
|
|
|
|
['last', ':last-child'],
|
|
|
|
|
['only', ':only-child'],
|
|
|
|
|
['odd', ':nth-child(odd)'],
|
|
|
|
|
['even', ':nth-child(even)'],
|
2021-09-24 18:57:01 +02:00
|
|
|
'first-of-type',
|
|
|
|
|
'last-of-type',
|
|
|
|
|
'only-of-type',
|
|
|
|
|
|
|
|
|
|
// State
|
|
|
|
|
'visited',
|
|
|
|
|
'target',
|
2021-09-28 11:13:58 -04:00
|
|
|
['open', '[open]'],
|
2021-09-24 18:57:01 +02:00
|
|
|
|
|
|
|
|
// Forms
|
|
|
|
|
'default',
|
|
|
|
|
'checked',
|
|
|
|
|
'indeterminate',
|
|
|
|
|
'placeholder-shown',
|
|
|
|
|
'autofill',
|
|
|
|
|
'required',
|
|
|
|
|
'valid',
|
|
|
|
|
'invalid',
|
|
|
|
|
'in-range',
|
|
|
|
|
'out-of-range',
|
|
|
|
|
'read-only',
|
|
|
|
|
|
|
|
|
|
// Content
|
|
|
|
|
'empty',
|
|
|
|
|
|
|
|
|
|
// Interactive
|
|
|
|
|
'focus-within',
|
|
|
|
|
'hover',
|
|
|
|
|
'focus',
|
|
|
|
|
'focus-visible',
|
|
|
|
|
'active',
|
|
|
|
|
'disabled',
|
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
|
|
|
].map((variant) => (Array.isArray(variant) ? variant : [variant, `:${variant}`]))
|
Remove AOT (#5340)
* make `jit` mode the default when no mode is specified
* unify JIT and AOT codepaths
* ensure `Object.entries` on undefined doesn't break
It could be that sometimes you don't have values in your config (e.g.: `presets: []`), this in turn will break some plugins where we assume we have a value.
* drop AOT specific tests
These tests are all covered by JIT mode already and were AOT specific.
* simplify tests, and add a few
Some of the tests were written for AOT specifically, some were missing. We also updated the way we write those tests, essentially making Tailwind a blackbox, by testing against the final output.
Now that JIT mode is the default, this is super fast because we only generate what is used, instead of partially testing in a 3MB file or building it all, then purging.
* add some todo's to make sure we warn in a few cases
* make `darkMode: 'media'`, the default
This also includes moving dark mode tests to its own dedicated file.
* remove PostCSS 7 compat mode
* update CLI to be JIT-first
* fix integration tests
This is not a _real_ fix, but it does solve the broken test for now.
* warn when using @responsive or @variants
* remove the JIT preview warning
* remove AOT-only code paths
* remove all `mode: 'jit'` blocks
Also remove `variants: {}` since they are not useful in `JIT` mode
anymore.
* drop unused dependencies
* rename `purge` to `content`
* remove static CDN builds
* mark `--purge` as deprecated in the CLI
This will still work, but a warning will be printed and it won't show up
in the `--help` output.
* cleanup nesting plugin
We don't have to duplicate it anymore since there is no PostCSS 7
version anymore.
* make sure integration tests run in band
* cleanup folder structure
* make sure nesting folder is available
* simplify resolving of purge/content information
2021-09-01 17:13:59 +02:00
|
|
|
|
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
|
|
|
for (let [variantName, state] of pseudoVariants) {
|
|
|
|
|
addVariant(variantName, `&${state}`)
|
2021-09-24 18:57:01 +02:00
|
|
|
}
|
Remove AOT (#5340)
* make `jit` mode the default when no mode is specified
* unify JIT and AOT codepaths
* ensure `Object.entries` on undefined doesn't break
It could be that sometimes you don't have values in your config (e.g.: `presets: []`), this in turn will break some plugins where we assume we have a value.
* drop AOT specific tests
These tests are all covered by JIT mode already and were AOT specific.
* simplify tests, and add a few
Some of the tests were written for AOT specifically, some were missing. We also updated the way we write those tests, essentially making Tailwind a blackbox, by testing against the final output.
Now that JIT mode is the default, this is super fast because we only generate what is used, instead of partially testing in a 3MB file or building it all, then purging.
* add some todo's to make sure we warn in a few cases
* make `darkMode: 'media'`, the default
This also includes moving dark mode tests to its own dedicated file.
* remove PostCSS 7 compat mode
* update CLI to be JIT-first
* fix integration tests
This is not a _real_ fix, but it does solve the broken test for now.
* warn when using @responsive or @variants
* remove the JIT preview warning
* remove AOT-only code paths
* remove all `mode: 'jit'` blocks
Also remove `variants: {}` since they are not useful in `JIT` mode
anymore.
* drop unused dependencies
* rename `purge` to `content`
* remove static CDN builds
* mark `--purge` as deprecated in the CLI
This will still work, but a warning will be printed and it won't show up
in the `--help` output.
* cleanup nesting plugin
We don't have to duplicate it anymore since there is no PostCSS 7
version anymore.
* make sure integration tests run in band
* cleanup folder structure
* make sure nesting folder is available
* simplify resolving of purge/content information
2021-09-01 17:13:59 +02:00
|
|
|
|
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
|
|
|
for (let [variantName, state] of pseudoVariants) {
|
|
|
|
|
addVariant(`group-${variantName}`, `:merge(.group)${state} &`)
|
|
|
|
|
}
|
2021-09-09 15:22:50 +02:00
|
|
|
|
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
|
|
|
for (let [variantName, state] of pseudoVariants) {
|
|
|
|
|
addVariant(`peer-${variantName}`, `:merge(.peer)${state} ~ &`)
|
2021-09-24 18:57:01 +02:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
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
|
|
|
directionVariants: ({ addVariant }) => {
|
2021-10-18 18:11:34 +02:00
|
|
|
addVariant('ltr', () => {
|
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
|
|
|
log.warn('rtl-experimental', [
|
|
|
|
|
'The RTL features in Tailwind CSS are currently in preview.',
|
|
|
|
|
'Preview features are not covered by semver, and may be improved in breaking ways at any time.',
|
|
|
|
|
])
|
2021-09-24 18:57:01 +02:00
|
|
|
|
2021-10-18 18:11:34 +02:00
|
|
|
return '[dir="ltr"] &'
|
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
|
|
|
})
|
2021-09-24 18:57:01 +02:00
|
|
|
|
2021-10-18 18:11:34 +02:00
|
|
|
addVariant('rtl', () => {
|
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
|
|
|
log.warn('rtl-experimental', [
|
|
|
|
|
'The RTL features in Tailwind CSS are currently in preview.',
|
|
|
|
|
'Preview features are not covered by semver, and may be improved in breaking ways at any time.',
|
|
|
|
|
])
|
Remove AOT (#5340)
* make `jit` mode the default when no mode is specified
* unify JIT and AOT codepaths
* ensure `Object.entries` on undefined doesn't break
It could be that sometimes you don't have values in your config (e.g.: `presets: []`), this in turn will break some plugins where we assume we have a value.
* drop AOT specific tests
These tests are all covered by JIT mode already and were AOT specific.
* simplify tests, and add a few
Some of the tests were written for AOT specifically, some were missing. We also updated the way we write those tests, essentially making Tailwind a blackbox, by testing against the final output.
Now that JIT mode is the default, this is super fast because we only generate what is used, instead of partially testing in a 3MB file or building it all, then purging.
* add some todo's to make sure we warn in a few cases
* make `darkMode: 'media'`, the default
This also includes moving dark mode tests to its own dedicated file.
* remove PostCSS 7 compat mode
* update CLI to be JIT-first
* fix integration tests
This is not a _real_ fix, but it does solve the broken test for now.
* warn when using @responsive or @variants
* remove the JIT preview warning
* remove AOT-only code paths
* remove all `mode: 'jit'` blocks
Also remove `variants: {}` since they are not useful in `JIT` mode
anymore.
* drop unused dependencies
* rename `purge` to `content`
* remove static CDN builds
* mark `--purge` as deprecated in the CLI
This will still work, but a warning will be printed and it won't show up
in the `--help` output.
* cleanup nesting plugin
We don't have to duplicate it anymore since there is no PostCSS 7
version anymore.
* make sure integration tests run in band
* cleanup folder structure
* make sure nesting folder is available
* simplify resolving of purge/content information
2021-09-01 17:13:59 +02:00
|
|
|
|
2021-10-18 18:11:34 +02:00
|
|
|
return '[dir="rtl"] &'
|
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
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
reducedMotionVariants: ({ addVariant }) => {
|
|
|
|
|
addVariant('motion-safe', '@media (prefers-reduced-motion: no-preference)')
|
|
|
|
|
addVariant('motion-reduce', '@media (prefers-reduced-motion: reduce)')
|
2021-09-24 18:57:01 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
darkVariants: ({ config, addVariant }) => {
|
|
|
|
|
let mode = config('darkMode', 'media')
|
|
|
|
|
if (mode === false) {
|
|
|
|
|
mode = 'media'
|
2021-09-30 21:16:01 -04:00
|
|
|
log.warn('darkmode-false', [
|
2021-10-01 11:47:02 -04:00
|
|
|
'The `darkMode` option in your Tailwind CSS configuration is set to `false`, which now behaves the same as `media`.',
|
|
|
|
|
'Change `darkMode` to `media` or remove it entirely.',
|
2021-09-24 18:57:01 +02:00
|
|
|
])
|
|
|
|
|
}
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
if (mode === 'class') {
|
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
|
|
|
addVariant('dark', '.dark &')
|
2021-09-24 18:57:01 +02:00
|
|
|
} else if (mode === 'media') {
|
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
|
|
|
addVariant('dark', '@media (prefers-color-scheme: dark)')
|
Remove AOT (#5340)
* make `jit` mode the default when no mode is specified
* unify JIT and AOT codepaths
* ensure `Object.entries` on undefined doesn't break
It could be that sometimes you don't have values in your config (e.g.: `presets: []`), this in turn will break some plugins where we assume we have a value.
* drop AOT specific tests
These tests are all covered by JIT mode already and were AOT specific.
* simplify tests, and add a few
Some of the tests were written for AOT specifically, some were missing. We also updated the way we write those tests, essentially making Tailwind a blackbox, by testing against the final output.
Now that JIT mode is the default, this is super fast because we only generate what is used, instead of partially testing in a 3MB file or building it all, then purging.
* add some todo's to make sure we warn in a few cases
* make `darkMode: 'media'`, the default
This also includes moving dark mode tests to its own dedicated file.
* remove PostCSS 7 compat mode
* update CLI to be JIT-first
* fix integration tests
This is not a _real_ fix, but it does solve the broken test for now.
* warn when using @responsive or @variants
* remove the JIT preview warning
* remove AOT-only code paths
* remove all `mode: 'jit'` blocks
Also remove `variants: {}` since they are not useful in `JIT` mode
anymore.
* drop unused dependencies
* rename `purge` to `content`
* remove static CDN builds
* mark `--purge` as deprecated in the CLI
This will still work, but a warning will be printed and it won't show up
in the `--help` output.
* cleanup nesting plugin
We don't have to duplicate it anymore since there is no PostCSS 7
version anymore.
* make sure integration tests run in band
* cleanup folder structure
* make sure nesting folder is available
* simplify resolving of purge/content information
2021-09-01 17:13:59 +02:00
|
|
|
}
|
2021-09-24 18:57:01 +02:00
|
|
|
},
|
|
|
|
|
|
2021-10-27 10:21:02 -04:00
|
|
|
printVariant: ({ addVariant }) => {
|
|
|
|
|
addVariant('print', '@media print')
|
|
|
|
|
},
|
|
|
|
|
|
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
|
|
|
screenVariants: ({ theme, addVariant }) => {
|
2021-09-24 18:57:01 +02:00
|
|
|
for (let screen in theme('screens')) {
|
|
|
|
|
let size = theme('screens')[screen]
|
|
|
|
|
let query = buildMediaQuery(size)
|
|
|
|
|
|
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
|
|
|
addVariant(screen, `@media ${query}`)
|
2021-09-09 15:22:50 +02:00
|
|
|
}
|
2021-09-24 18:57:01 +02:00
|
|
|
},
|
2021-10-01 17:31:09 +02:00
|
|
|
}
|
2021-09-24 18:57:01 +02:00
|
|
|
|
2021-10-01 17:31:09 +02:00
|
|
|
export let corePlugins = {
|
2021-09-24 18:57:01 +02:00
|
|
|
preflight: ({ addBase }) => {
|
2021-10-07 12:33:23 +01:00
|
|
|
let preflightStyles = postcss.parse(
|
2021-10-07 12:49:32 +01:00
|
|
|
fs.readFileSync(path.join(__dirname, './css/preflight.css'), 'utf8')
|
2021-10-07 12:33:23 +01:00
|
|
|
)
|
2021-09-24 18:57:01 +02:00
|
|
|
|
|
|
|
|
addBase([
|
|
|
|
|
postcss.comment({
|
2021-09-28 17:09:16 +01:00
|
|
|
text: `! tailwindcss v${tailwindVersion} | MIT License | https://tailwindcss.com`,
|
2021-09-24 18:57:01 +02:00
|
|
|
}),
|
|
|
|
|
...preflightStyles.nodes,
|
|
|
|
|
])
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
container: (() => {
|
|
|
|
|
function extractMinWidths(breakpoints) {
|
|
|
|
|
return Object.values(breakpoints ?? {}).flatMap((breakpoints) => {
|
|
|
|
|
if (typeof breakpoints === 'string') {
|
|
|
|
|
breakpoints = { min: breakpoints }
|
|
|
|
|
}
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
if (!Array.isArray(breakpoints)) {
|
|
|
|
|
breakpoints = [breakpoints]
|
|
|
|
|
}
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
return breakpoints
|
|
|
|
|
.filter((breakpoint) => {
|
|
|
|
|
return breakpoint?.hasOwnProperty?.('min') || breakpoint?.hasOwnProperty('min-width')
|
|
|
|
|
})
|
|
|
|
|
.map((breakpoint) => {
|
|
|
|
|
return breakpoint['min-width'] ?? breakpoint.min
|
|
|
|
|
})
|
2021-09-09 15:22:50 +02:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
function mapMinWidthsToPadding(minWidths, screens, paddings) {
|
|
|
|
|
if (typeof paddings === 'undefined') {
|
|
|
|
|
return []
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!(typeof paddings === 'object' && paddings !== null)) {
|
|
|
|
|
return [
|
|
|
|
|
{
|
|
|
|
|
screen: 'DEFAULT',
|
|
|
|
|
minWidth: 0,
|
|
|
|
|
padding: paddings,
|
|
|
|
|
},
|
|
|
|
|
]
|
|
|
|
|
}
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
let mapping = []
|
|
|
|
|
|
|
|
|
|
if (paddings.DEFAULT) {
|
|
|
|
|
mapping.push({
|
|
|
|
|
screen: 'DEFAULT',
|
|
|
|
|
minWidth: 0,
|
|
|
|
|
padding: paddings.DEFAULT,
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (let minWidth of minWidths) {
|
|
|
|
|
for (let [screen, value] of Object.entries(screens)) {
|
|
|
|
|
let screenMinWidth =
|
|
|
|
|
typeof value === 'object' && value !== null ? value.min || value['min-width'] : value
|
|
|
|
|
|
|
|
|
|
if (`${screenMinWidth}` === `${minWidth}`) {
|
|
|
|
|
mapping.push({
|
|
|
|
|
screen,
|
|
|
|
|
minWidth,
|
|
|
|
|
padding: paddings[screen],
|
|
|
|
|
})
|
|
|
|
|
}
|
2021-09-09 15:22:50 +02:00
|
|
|
}
|
|
|
|
|
}
|
2021-09-24 18:57:01 +02:00
|
|
|
|
|
|
|
|
return mapping
|
2021-09-09 15:22:50 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
return function ({ addComponents, theme }) {
|
|
|
|
|
let screens = theme('container.screens', theme('screens'))
|
|
|
|
|
let minWidths = extractMinWidths(screens)
|
|
|
|
|
let paddings = mapMinWidthsToPadding(minWidths, screens, theme('container.padding'))
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
let generatePaddingFor = (minWidth) => {
|
|
|
|
|
let paddingConfig = paddings.find((padding) => `${padding.minWidth}` === `${minWidth}`)
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
if (!paddingConfig) {
|
|
|
|
|
return {}
|
|
|
|
|
}
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
return {
|
|
|
|
|
paddingRight: paddingConfig.padding,
|
|
|
|
|
paddingLeft: paddingConfig.padding,
|
|
|
|
|
}
|
2021-09-09 15:22:50 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
let atRules = Array.from(
|
|
|
|
|
new Set(minWidths.slice().sort((a, z) => parseInt(a) - parseInt(z)))
|
|
|
|
|
).map((minWidth) => ({
|
|
|
|
|
[`@media (min-width: ${minWidth})`]: {
|
|
|
|
|
'.container': {
|
|
|
|
|
'max-width': minWidth,
|
|
|
|
|
...generatePaddingFor(minWidth),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
}))
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
addComponents([
|
|
|
|
|
{
|
|
|
|
|
'.container': Object.assign(
|
|
|
|
|
{ width: '100%' },
|
|
|
|
|
theme('container.center', false) ? { marginRight: 'auto', marginLeft: 'auto' } : {},
|
|
|
|
|
generatePaddingFor(0)
|
|
|
|
|
),
|
2021-09-09 15:22:50 +02:00
|
|
|
},
|
2021-09-24 18:57:01 +02:00
|
|
|
...atRules,
|
|
|
|
|
])
|
|
|
|
|
}
|
|
|
|
|
})(),
|
|
|
|
|
|
|
|
|
|
accessibility: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.sr-only': {
|
|
|
|
|
position: 'absolute',
|
|
|
|
|
width: '1px',
|
|
|
|
|
height: '1px',
|
|
|
|
|
padding: '0',
|
|
|
|
|
margin: '-1px',
|
|
|
|
|
overflow: 'hidden',
|
|
|
|
|
clip: 'rect(0, 0, 0, 0)',
|
|
|
|
|
whiteSpace: 'nowrap',
|
|
|
|
|
borderWidth: '0',
|
2021-09-09 15:22:50 +02:00
|
|
|
},
|
2021-09-24 18:57:01 +02:00
|
|
|
'.not-sr-only': {
|
|
|
|
|
position: 'static',
|
|
|
|
|
width: 'auto',
|
|
|
|
|
height: 'auto',
|
|
|
|
|
padding: '0',
|
|
|
|
|
margin: '0',
|
|
|
|
|
overflow: 'visible',
|
|
|
|
|
clip: 'auto',
|
|
|
|
|
whiteSpace: 'normal',
|
2021-09-09 15:22:50 +02:00
|
|
|
},
|
2021-09-24 18:57:01 +02:00
|
|
|
})
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
pointerEvents: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.pointer-events-none': { 'pointer-events': 'none' },
|
|
|
|
|
'.pointer-events-auto': { 'pointer-events': 'auto' },
|
|
|
|
|
})
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
visibility: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.visible': { visibility: 'visible' },
|
|
|
|
|
'.invisible': { visibility: 'hidden' },
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
position: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.static': { position: 'static' },
|
|
|
|
|
'.fixed': { position: 'fixed' },
|
|
|
|
|
'.absolute': { position: 'absolute' },
|
|
|
|
|
'.relative': { position: 'relative' },
|
|
|
|
|
'.sticky': { position: 'sticky' },
|
|
|
|
|
})
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-10-06 13:42:05 -04:00
|
|
|
inset: createUtilityPlugin(
|
|
|
|
|
'inset',
|
2021-09-24 18:57:01 +02:00
|
|
|
[
|
2021-10-06 13:42:05 -04:00
|
|
|
['inset', ['top', 'right', 'bottom', 'left']],
|
|
|
|
|
[
|
|
|
|
|
['inset-x', ['left', 'right']],
|
|
|
|
|
['inset-y', ['top', 'bottom']],
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
['top', ['top']],
|
|
|
|
|
['right', ['right']],
|
|
|
|
|
['bottom', ['bottom']],
|
|
|
|
|
['left', ['left']],
|
|
|
|
|
],
|
2021-09-24 18:57:01 +02:00
|
|
|
],
|
2021-10-06 13:42:05 -04:00
|
|
|
{ supportsNegativeValues: true }
|
|
|
|
|
),
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
isolation: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.isolate': { isolation: 'isolate' },
|
|
|
|
|
'.isolation-auto': { isolation: 'auto' },
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
2021-10-06 13:42:05 -04:00
|
|
|
zIndex: createUtilityPlugin('zIndex', [['z', ['zIndex']]], { supportsNegativeValues: true }),
|
|
|
|
|
order: createUtilityPlugin('order', undefined, { supportsNegativeValues: true }),
|
2021-09-24 18:57:01 +02:00
|
|
|
gridColumn: createUtilityPlugin('gridColumn', [['col', ['gridColumn']]]),
|
|
|
|
|
gridColumnStart: createUtilityPlugin('gridColumnStart', [['col-start', ['gridColumnStart']]]),
|
|
|
|
|
gridColumnEnd: createUtilityPlugin('gridColumnEnd', [['col-end', ['gridColumnEnd']]]),
|
|
|
|
|
gridRow: createUtilityPlugin('gridRow', [['row', ['gridRow']]]),
|
|
|
|
|
gridRowStart: createUtilityPlugin('gridRowStart', [['row-start', ['gridRowStart']]]),
|
|
|
|
|
gridRowEnd: createUtilityPlugin('gridRowEnd', [['row-end', ['gridRowEnd']]]),
|
|
|
|
|
|
|
|
|
|
float: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.float-right': { float: 'right' },
|
|
|
|
|
'.float-left': { float: 'left' },
|
|
|
|
|
'.float-none': { float: 'none' },
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
clear: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.clear-left': { clear: 'left' },
|
|
|
|
|
'.clear-right': { clear: 'right' },
|
|
|
|
|
'.clear-both': { clear: 'both' },
|
|
|
|
|
'.clear-none': { clear: 'none' },
|
|
|
|
|
})
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-10-06 13:42:05 -04:00
|
|
|
margin: createUtilityPlugin(
|
|
|
|
|
'margin',
|
2021-09-24 18:57:01 +02:00
|
|
|
[
|
2021-10-06 13:42:05 -04:00
|
|
|
['m', ['margin']],
|
|
|
|
|
[
|
|
|
|
|
['mx', ['margin-left', 'margin-right']],
|
|
|
|
|
['my', ['margin-top', 'margin-bottom']],
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
['mt', ['margin-top']],
|
|
|
|
|
['mr', ['margin-right']],
|
|
|
|
|
['mb', ['margin-bottom']],
|
|
|
|
|
['ml', ['margin-left']],
|
|
|
|
|
],
|
2021-09-24 18:57:01 +02:00
|
|
|
],
|
2021-10-06 13:42:05 -04:00
|
|
|
{ supportsNegativeValues: true }
|
|
|
|
|
),
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
boxSizing: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.box-border': { 'box-sizing': 'border-box' },
|
|
|
|
|
'.box-content': { 'box-sizing': 'content-box' },
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
display: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.block': { display: 'block' },
|
|
|
|
|
'.inline-block': { display: 'inline-block' },
|
|
|
|
|
'.inline': { display: 'inline' },
|
|
|
|
|
'.flex': { display: 'flex' },
|
|
|
|
|
'.inline-flex': { display: 'inline-flex' },
|
|
|
|
|
'.table': { display: 'table' },
|
|
|
|
|
'.inline-table': { display: 'inline-table' },
|
|
|
|
|
'.table-caption': { display: 'table-caption' },
|
|
|
|
|
'.table-cell': { display: 'table-cell' },
|
|
|
|
|
'.table-column': { display: 'table-column' },
|
|
|
|
|
'.table-column-group': { display: 'table-column-group' },
|
|
|
|
|
'.table-footer-group': { display: 'table-footer-group' },
|
|
|
|
|
'.table-header-group': { display: 'table-header-group' },
|
|
|
|
|
'.table-row-group': { display: 'table-row-group' },
|
|
|
|
|
'.table-row': { display: 'table-row' },
|
|
|
|
|
'.flow-root': { display: 'flow-root' },
|
|
|
|
|
'.grid': { display: 'grid' },
|
|
|
|
|
'.inline-grid': { display: 'inline-grid' },
|
|
|
|
|
'.contents': { display: 'contents' },
|
|
|
|
|
'.list-item': { display: 'list-item' },
|
|
|
|
|
'.hidden': { display: 'none' },
|
|
|
|
|
})
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
aspectRatio: createUtilityPlugin('aspectRatio', [['aspect', ['aspect-ratio']]]),
|
2021-09-24 18:45:42 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
height: createUtilityPlugin('height', [['h', ['height']]]),
|
|
|
|
|
maxHeight: createUtilityPlugin('maxHeight', [['max-h', ['maxHeight']]]),
|
|
|
|
|
minHeight: createUtilityPlugin('minHeight', [['min-h', ['minHeight']]]),
|
2021-09-24 18:45:42 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
width: createUtilityPlugin('width', [['w', ['width']]]),
|
|
|
|
|
minWidth: createUtilityPlugin('minWidth', [['min-w', ['minWidth']]]),
|
|
|
|
|
maxWidth: createUtilityPlugin('maxWidth', [['max-w', ['maxWidth']]]),
|
2021-09-24 18:45:42 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
flex: createUtilityPlugin('flex'),
|
2021-10-09 09:48:12 -04:00
|
|
|
flexShrink: createUtilityPlugin('flexShrink', [
|
|
|
|
|
['flex-shrink', ['flex-shrink']], // Deprecated
|
|
|
|
|
['shrink', ['flex-shrink']],
|
|
|
|
|
]),
|
|
|
|
|
flexGrow: createUtilityPlugin('flexGrow', [
|
|
|
|
|
['flex-grow', ['flex-grow']], // Deprecated
|
|
|
|
|
['grow', ['flex-grow']],
|
|
|
|
|
]),
|
2021-10-04 15:47:14 -04:00
|
|
|
flexBasis: createUtilityPlugin('flexBasis', [['basis', ['flex-basis']]]),
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
tableLayout: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.table-auto': { 'table-layout': 'auto' },
|
|
|
|
|
'.table-fixed': { 'table-layout': 'fixed' },
|
|
|
|
|
})
|
|
|
|
|
},
|
Remove AOT (#5340)
* make `jit` mode the default when no mode is specified
* unify JIT and AOT codepaths
* ensure `Object.entries` on undefined doesn't break
It could be that sometimes you don't have values in your config (e.g.: `presets: []`), this in turn will break some plugins where we assume we have a value.
* drop AOT specific tests
These tests are all covered by JIT mode already and were AOT specific.
* simplify tests, and add a few
Some of the tests were written for AOT specifically, some were missing. We also updated the way we write those tests, essentially making Tailwind a blackbox, by testing against the final output.
Now that JIT mode is the default, this is super fast because we only generate what is used, instead of partially testing in a 3MB file or building it all, then purging.
* add some todo's to make sure we warn in a few cases
* make `darkMode: 'media'`, the default
This also includes moving dark mode tests to its own dedicated file.
* remove PostCSS 7 compat mode
* update CLI to be JIT-first
* fix integration tests
This is not a _real_ fix, but it does solve the broken test for now.
* warn when using @responsive or @variants
* remove the JIT preview warning
* remove AOT-only code paths
* remove all `mode: 'jit'` blocks
Also remove `variants: {}` since they are not useful in `JIT` mode
anymore.
* drop unused dependencies
* rename `purge` to `content`
* remove static CDN builds
* mark `--purge` as deprecated in the CLI
This will still work, but a warning will be printed and it won't show up
in the `--help` output.
* cleanup nesting plugin
We don't have to duplicate it anymore since there is no PostCSS 7
version anymore.
* make sure integration tests run in band
* cleanup folder structure
* make sure nesting folder is available
* simplify resolving of purge/content information
2021-09-01 17:13:59 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
borderCollapse: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.border-collapse': { 'border-collapse': 'collapse' },
|
|
|
|
|
'.border-separate': { 'border-collapse': 'separate' },
|
|
|
|
|
})
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
transformOrigin: createUtilityPlugin('transformOrigin', [['origin', ['transformOrigin']]]),
|
2021-10-06 13:42:05 -04:00
|
|
|
translate: createUtilityPlugin(
|
|
|
|
|
'translate',
|
2021-09-09 15:22:50 +02:00
|
|
|
[
|
2021-09-24 18:57:01 +02:00
|
|
|
[
|
2021-10-06 13:42:05 -04:00
|
|
|
[
|
|
|
|
|
'translate-x',
|
|
|
|
|
[['@defaults transform', {}], '--tw-translate-x', ['transform', 'var(--tw-transform)']],
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'translate-y',
|
|
|
|
|
[['@defaults transform', {}], '--tw-translate-y', ['transform', 'var(--tw-transform)']],
|
|
|
|
|
],
|
2021-09-24 18:57:01 +02:00
|
|
|
],
|
2021-09-09 15:22:50 +02:00
|
|
|
],
|
2021-10-06 13:42:05 -04:00
|
|
|
{ supportsNegativeValues: true }
|
|
|
|
|
),
|
|
|
|
|
rotate: createUtilityPlugin(
|
|
|
|
|
'rotate',
|
2021-09-09 15:22:50 +02:00
|
|
|
[
|
2021-09-24 18:57:01 +02:00
|
|
|
[
|
2021-10-06 13:42:05 -04:00
|
|
|
'rotate',
|
|
|
|
|
[['@defaults transform', {}], '--tw-rotate', ['transform', 'var(--tw-transform)']],
|
2021-09-24 18:57:01 +02:00
|
|
|
],
|
2021-10-06 13:42:05 -04:00
|
|
|
],
|
|
|
|
|
{ supportsNegativeValues: true }
|
|
|
|
|
),
|
|
|
|
|
skew: createUtilityPlugin(
|
|
|
|
|
'skew',
|
|
|
|
|
[
|
2021-09-24 18:57:01 +02:00
|
|
|
[
|
2021-10-06 13:42:05 -04:00
|
|
|
[
|
|
|
|
|
'skew-x',
|
|
|
|
|
[['@defaults transform', {}], '--tw-skew-x', ['transform', 'var(--tw-transform)']],
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'skew-y',
|
|
|
|
|
[['@defaults transform', {}], '--tw-skew-y', ['transform', 'var(--tw-transform)']],
|
|
|
|
|
],
|
2021-09-24 18:57:01 +02:00
|
|
|
],
|
2021-09-09 15:22:50 +02:00
|
|
|
],
|
2021-10-06 13:42:05 -04:00
|
|
|
{ supportsNegativeValues: true }
|
|
|
|
|
),
|
2021-09-24 18:57:01 +02:00
|
|
|
scale: createUtilityPlugin('scale', [
|
2021-09-09 15:22:50 +02:00
|
|
|
[
|
2021-09-24 18:57:01 +02:00
|
|
|
'scale',
|
|
|
|
|
[
|
|
|
|
|
['@defaults transform', {}],
|
|
|
|
|
'--tw-scale-x',
|
|
|
|
|
'--tw-scale-y',
|
|
|
|
|
['transform', 'var(--tw-transform)'],
|
|
|
|
|
],
|
2021-09-09 15:22:50 +02:00
|
|
|
],
|
|
|
|
|
[
|
2021-09-24 18:57:01 +02:00
|
|
|
[
|
|
|
|
|
'scale-x',
|
|
|
|
|
[['@defaults transform', {}], '--tw-scale-x', ['transform', 'var(--tw-transform)']],
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
'scale-y',
|
|
|
|
|
[['@defaults transform', {}], '--tw-scale-y', ['transform', 'var(--tw-transform)']],
|
|
|
|
|
],
|
2021-09-09 15:22:50 +02:00
|
|
|
],
|
2021-09-24 18:57:01 +02:00
|
|
|
]),
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
transform: ({ addBase, addUtilities }) => {
|
|
|
|
|
addBase({
|
|
|
|
|
'@defaults transform': {
|
|
|
|
|
'--tw-translate-x': '0',
|
|
|
|
|
'--tw-translate-y': '0',
|
|
|
|
|
'--tw-rotate': '0',
|
|
|
|
|
'--tw-skew-x': '0',
|
|
|
|
|
'--tw-skew-y': '0',
|
|
|
|
|
'--tw-scale-x': '1',
|
|
|
|
|
'--tw-scale-y': '1',
|
|
|
|
|
'--tw-transform': [
|
|
|
|
|
'translateX(var(--tw-translate-x))',
|
|
|
|
|
'translateY(var(--tw-translate-y))',
|
|
|
|
|
'rotate(var(--tw-rotate))',
|
|
|
|
|
'skewX(var(--tw-skew-x))',
|
|
|
|
|
'skewY(var(--tw-skew-y))',
|
|
|
|
|
'scaleX(var(--tw-scale-x))',
|
|
|
|
|
'scaleY(var(--tw-scale-y))',
|
|
|
|
|
].join(' '),
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
})
|
2021-09-24 18:57:01 +02:00
|
|
|
addUtilities({
|
|
|
|
|
'.transform': { '@defaults transform': {}, transform: 'var(--tw-transform)' },
|
|
|
|
|
'.transform-cpu': {
|
|
|
|
|
'--tw-transform': [
|
|
|
|
|
'translateX(var(--tw-translate-x))',
|
|
|
|
|
'translateY(var(--tw-translate-y))',
|
|
|
|
|
'rotate(var(--tw-rotate))',
|
|
|
|
|
'skewX(var(--tw-skew-x))',
|
|
|
|
|
'skewY(var(--tw-skew-y))',
|
|
|
|
|
'scaleX(var(--tw-scale-x))',
|
|
|
|
|
'scaleY(var(--tw-scale-y))',
|
|
|
|
|
].join(' '),
|
|
|
|
|
},
|
|
|
|
|
'.transform-gpu': {
|
|
|
|
|
'--tw-transform': [
|
|
|
|
|
'translate3d(var(--tw-translate-x), var(--tw-translate-y), 0)',
|
|
|
|
|
'rotate(var(--tw-rotate))',
|
|
|
|
|
'skewX(var(--tw-skew-x))',
|
|
|
|
|
'skewY(var(--tw-skew-y))',
|
|
|
|
|
'scaleX(var(--tw-scale-x))',
|
|
|
|
|
'scaleY(var(--tw-scale-y))',
|
|
|
|
|
].join(' '),
|
|
|
|
|
},
|
|
|
|
|
'.transform-none': { transform: 'none' },
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
animation: ({ matchUtilities, theme, prefix }) => {
|
|
|
|
|
let prefixName = (name) => prefix(`.${name}`).slice(1)
|
|
|
|
|
let keyframes = Object.fromEntries(
|
|
|
|
|
Object.entries(theme('keyframes') ?? {}).map(([key, value]) => {
|
2021-10-01 17:31:09 +02:00
|
|
|
return [key, { [`@keyframes ${prefixName(key)}`]: value }]
|
2021-09-24 18:57:01 +02:00
|
|
|
})
|
|
|
|
|
)
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
matchUtilities(
|
|
|
|
|
{
|
2021-10-01 17:31:09 +02:00
|
|
|
animate: (value) => {
|
2021-09-24 18:57:01 +02:00
|
|
|
let animations = parseAnimationValue(value)
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-10-01 17:31:09 +02:00
|
|
|
return [
|
|
|
|
|
...animations.flatMap((animation) => keyframes[animation.name]),
|
|
|
|
|
{
|
|
|
|
|
animation: animations
|
|
|
|
|
.map(({ name, value }) => {
|
|
|
|
|
if (name === undefined || keyframes[name] === undefined) {
|
|
|
|
|
return value
|
|
|
|
|
}
|
|
|
|
|
return value.replace(name, prefixName(name))
|
|
|
|
|
})
|
|
|
|
|
.join(', '),
|
|
|
|
|
},
|
|
|
|
|
]
|
2021-09-24 18:57:01 +02:00
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
},
|
2021-09-24 18:57:01 +02:00
|
|
|
{ values: theme('animation') }
|
|
|
|
|
)
|
|
|
|
|
},
|
Remove AOT (#5340)
* make `jit` mode the default when no mode is specified
* unify JIT and AOT codepaths
* ensure `Object.entries` on undefined doesn't break
It could be that sometimes you don't have values in your config (e.g.: `presets: []`), this in turn will break some plugins where we assume we have a value.
* drop AOT specific tests
These tests are all covered by JIT mode already and were AOT specific.
* simplify tests, and add a few
Some of the tests were written for AOT specifically, some were missing. We also updated the way we write those tests, essentially making Tailwind a blackbox, by testing against the final output.
Now that JIT mode is the default, this is super fast because we only generate what is used, instead of partially testing in a 3MB file or building it all, then purging.
* add some todo's to make sure we warn in a few cases
* make `darkMode: 'media'`, the default
This also includes moving dark mode tests to its own dedicated file.
* remove PostCSS 7 compat mode
* update CLI to be JIT-first
* fix integration tests
This is not a _real_ fix, but it does solve the broken test for now.
* warn when using @responsive or @variants
* remove the JIT preview warning
* remove AOT-only code paths
* remove all `mode: 'jit'` blocks
Also remove `variants: {}` since they are not useful in `JIT` mode
anymore.
* drop unused dependencies
* rename `purge` to `content`
* remove static CDN builds
* mark `--purge` as deprecated in the CLI
This will still work, but a warning will be printed and it won't show up
in the `--help` output.
* cleanup nesting plugin
We don't have to duplicate it anymore since there is no PostCSS 7
version anymore.
* make sure integration tests run in band
* cleanup folder structure
* make sure nesting folder is available
* simplify resolving of purge/content information
2021-09-01 17:13:59 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
cursor: createUtilityPlugin('cursor'),
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-26 09:41:36 -04:00
|
|
|
touchAction: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.touch-auto': { 'touch-action': 'auto' },
|
|
|
|
|
'.touch-none': { 'touch-action': 'none' },
|
|
|
|
|
'.touch-pan-x': { 'touch-action': 'pan-x' },
|
|
|
|
|
'.touch-pan-left': { 'touch-action': 'pan-left' },
|
|
|
|
|
'.touch-pan-right': { 'touch-action': 'pan-right' },
|
|
|
|
|
'.touch-pan-y': { 'touch-action': 'pan-y' },
|
|
|
|
|
'.touch-pan-up': { 'touch-action': 'pan-up' },
|
|
|
|
|
'.touch-pan-down': { 'touch-action': 'pan-down' },
|
|
|
|
|
'.touch-pinch-zoom': { 'touch-action': 'pinch-zoom' },
|
|
|
|
|
'.touch-manipulation': { 'touch-action': 'manipulation' },
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
userSelect: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.select-none': { 'user-select': 'none' },
|
|
|
|
|
'.select-text': { 'user-select': 'text' },
|
|
|
|
|
'.select-all': { 'user-select': 'all' },
|
|
|
|
|
'.select-auto': { 'user-select': 'auto' },
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
resize: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.resize-none': { resize: 'none' },
|
|
|
|
|
'.resize-y': { resize: 'vertical' },
|
|
|
|
|
'.resize-x': { resize: 'horizontal' },
|
|
|
|
|
'.resize': { resize: 'both' },
|
|
|
|
|
})
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-29 09:57:26 -04:00
|
|
|
scrollSnapType: ({ addUtilities, addBase }) => {
|
|
|
|
|
addBase({
|
|
|
|
|
'@defaults scroll-snap-type': {
|
|
|
|
|
'--tw-scroll-snap-strictness': 'proximity',
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.snap-none': { 'scroll-snap-type': 'none' },
|
|
|
|
|
'.snap-x': {
|
|
|
|
|
'@defaults scroll-snap-type': {},
|
|
|
|
|
'scroll-snap-type': 'x var(--tw-scroll-snap-strictness)',
|
|
|
|
|
},
|
|
|
|
|
'.snap-y': {
|
|
|
|
|
'@defaults scroll-snap-type': {},
|
|
|
|
|
'scroll-snap-type': 'y var(--tw-scroll-snap-strictness)',
|
|
|
|
|
},
|
|
|
|
|
'.snap-both': {
|
|
|
|
|
'@defaults scroll-snap-type': {},
|
|
|
|
|
'scroll-snap-type': 'both var(--tw-scroll-snap-strictness)',
|
|
|
|
|
},
|
|
|
|
|
'.snap-mandatory': { '--tw-scroll-snap-strictness': 'mandatory' },
|
|
|
|
|
'.snap-proximity': { '--tw-scroll-snap-strictness': 'proximity' },
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
scrollSnapAlign: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.snap-start': { 'scroll-snap-align': 'start' },
|
|
|
|
|
'.snap-end': { 'scroll-snap-align': 'end' },
|
|
|
|
|
'.snap-center': { 'scroll-snap-align': 'center' },
|
|
|
|
|
'.snap-align-none': { 'scroll-snap-align': 'none' },
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
scrollSnapStop: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.snap-normal': { 'scroll-snap-stop': 'normal' },
|
|
|
|
|
'.snap-always': { 'scroll-snap-stop': 'always' },
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
2021-10-06 13:42:05 -04:00
|
|
|
scrollMargin: createUtilityPlugin(
|
|
|
|
|
'scrollMargin',
|
2021-09-29 09:57:26 -04:00
|
|
|
[
|
2021-10-06 13:42:05 -04:00
|
|
|
['scroll-m', ['scroll-margin']],
|
|
|
|
|
[
|
|
|
|
|
['scroll-mx', ['scroll-margin-left', 'scroll-margin-right']],
|
|
|
|
|
['scroll-my', ['scroll-margin-top', 'scroll-margin-bottom']],
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
['scroll-mt', ['scroll-margin-top']],
|
|
|
|
|
['scroll-mr', ['scroll-margin-right']],
|
|
|
|
|
['scroll-mb', ['scroll-margin-bottom']],
|
|
|
|
|
['scroll-ml', ['scroll-margin-left']],
|
|
|
|
|
],
|
2021-09-29 09:57:26 -04:00
|
|
|
],
|
2021-10-06 13:42:05 -04:00
|
|
|
{ supportsNegativeValues: true }
|
|
|
|
|
),
|
2021-09-29 09:57:26 -04:00
|
|
|
|
|
|
|
|
scrollPadding: createUtilityPlugin('scrollPadding', [
|
|
|
|
|
['scroll-p', ['scroll-padding']],
|
|
|
|
|
[
|
|
|
|
|
['scroll-px', ['scroll-padding-left', 'scroll-padding-right']],
|
|
|
|
|
['scroll-py', ['scroll-padding-top', 'scroll-padding-bottom']],
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
['scroll-pt', ['scroll-padding-top']],
|
|
|
|
|
['scroll-pr', ['scroll-padding-right']],
|
|
|
|
|
['scroll-pb', ['scroll-padding-bottom']],
|
|
|
|
|
['scroll-pl', ['scroll-padding-left']],
|
|
|
|
|
],
|
|
|
|
|
]),
|
|
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
listStylePosition: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.list-inside': { 'list-style-position': 'inside' },
|
|
|
|
|
'.list-outside': { 'list-style-position': 'outside' },
|
|
|
|
|
})
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
listStyleType: createUtilityPlugin('listStyleType', [['list', ['listStyleType']]]),
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
appearance: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.appearance-none': { appearance: 'none' },
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
columns: createUtilityPlugin('columns', [['columns', ['columns']]]),
|
|
|
|
|
|
|
|
|
|
breakBefore: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.break-before-auto': { 'break-before': 'auto' },
|
|
|
|
|
'.break-before-avoid': { 'break-before': 'avoid' },
|
|
|
|
|
'.break-before-all': { 'break-before': 'all' },
|
|
|
|
|
'.break-before-avoid-page': { 'break-before': 'avoid-page' },
|
|
|
|
|
'.break-before-page': { 'break-before': 'page' },
|
|
|
|
|
'.break-before-left': { 'break-before': 'left' },
|
|
|
|
|
'.break-before-right': { 'break-before': 'right' },
|
|
|
|
|
'.break-before-column': { 'break-before': 'column' },
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
breakInside: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.break-inside-auto': { 'break-inside': 'auto' },
|
|
|
|
|
'.break-inside-avoid': { 'break-inside': 'avoid' },
|
|
|
|
|
'.break-inside-avoid-page': { 'break-inside': 'avoid-page' },
|
|
|
|
|
'.break-inside-avoid-column': { 'break-inside': 'avoid-column' },
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
breakAfter: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.break-after-auto': { 'break-after': 'auto' },
|
|
|
|
|
'.break-after-avoid': { 'break-after': 'avoid' },
|
|
|
|
|
'.break-after-all': { 'break-after': 'all' },
|
|
|
|
|
'.break-after-avoid-page': { 'break-after': 'avoid-page' },
|
|
|
|
|
'.break-after-page': { 'break-after': 'page' },
|
|
|
|
|
'.break-after-left': { 'break-after': 'left' },
|
|
|
|
|
'.break-after-right': { 'break-after': 'right' },
|
|
|
|
|
'.break-after-column': { 'break-after': 'column' },
|
|
|
|
|
})
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
gridAutoColumns: createUtilityPlugin('gridAutoColumns', [['auto-cols', ['gridAutoColumns']]]),
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
gridAutoFlow: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.grid-flow-row': { gridAutoFlow: 'row' },
|
|
|
|
|
'.grid-flow-col': { gridAutoFlow: 'column' },
|
|
|
|
|
'.grid-flow-row-dense': { gridAutoFlow: 'row dense' },
|
|
|
|
|
'.grid-flow-col-dense': { gridAutoFlow: 'column dense' },
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
gridAutoRows: createUtilityPlugin('gridAutoRows', [['auto-rows', ['gridAutoRows']]]),
|
|
|
|
|
gridTemplateColumns: createUtilityPlugin('gridTemplateColumns', [
|
|
|
|
|
['grid-cols', ['gridTemplateColumns']],
|
|
|
|
|
]),
|
|
|
|
|
gridTemplateRows: createUtilityPlugin('gridTemplateRows', [['grid-rows', ['gridTemplateRows']]]),
|
|
|
|
|
|
|
|
|
|
flexDirection: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.flex-row': { 'flex-direction': 'row' },
|
|
|
|
|
'.flex-row-reverse': { 'flex-direction': 'row-reverse' },
|
|
|
|
|
'.flex-col': { 'flex-direction': 'column' },
|
|
|
|
|
'.flex-col-reverse': { 'flex-direction': 'column-reverse' },
|
|
|
|
|
})
|
|
|
|
|
},
|
2021-09-23 14:31:23 -04:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
flexWrap: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.flex-wrap': { 'flex-wrap': 'wrap' },
|
|
|
|
|
'.flex-wrap-reverse': { 'flex-wrap': 'wrap-reverse' },
|
|
|
|
|
'.flex-nowrap': { 'flex-wrap': 'nowrap' },
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
placeContent: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.place-content-center': { 'place-content': 'center' },
|
|
|
|
|
'.place-content-start': { 'place-content': 'start' },
|
|
|
|
|
'.place-content-end': { 'place-content': 'end' },
|
|
|
|
|
'.place-content-between': { 'place-content': 'space-between' },
|
|
|
|
|
'.place-content-around': { 'place-content': 'space-around' },
|
|
|
|
|
'.place-content-evenly': { 'place-content': 'space-evenly' },
|
|
|
|
|
'.place-content-stretch': { 'place-content': 'stretch' },
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
placeItems: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.place-items-start': { 'place-items': 'start' },
|
|
|
|
|
'.place-items-end': { 'place-items': 'end' },
|
|
|
|
|
'.place-items-center': { 'place-items': 'center' },
|
|
|
|
|
'.place-items-stretch': { 'place-items': 'stretch' },
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
alignContent: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.content-center': { 'align-content': 'center' },
|
|
|
|
|
'.content-start': { 'align-content': 'flex-start' },
|
|
|
|
|
'.content-end': { 'align-content': 'flex-end' },
|
|
|
|
|
'.content-between': { 'align-content': 'space-between' },
|
|
|
|
|
'.content-around': { 'align-content': 'space-around' },
|
|
|
|
|
'.content-evenly': { 'align-content': 'space-evenly' },
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
alignItems: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.items-start': { 'align-items': 'flex-start' },
|
|
|
|
|
'.items-end': { 'align-items': 'flex-end' },
|
|
|
|
|
'.items-center': { 'align-items': 'center' },
|
|
|
|
|
'.items-baseline': { 'align-items': 'baseline' },
|
|
|
|
|
'.items-stretch': { 'align-items': 'stretch' },
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
justifyContent: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.justify-start': { 'justify-content': 'flex-start' },
|
|
|
|
|
'.justify-end': { 'justify-content': 'flex-end' },
|
|
|
|
|
'.justify-center': { 'justify-content': 'center' },
|
|
|
|
|
'.justify-between': { 'justify-content': 'space-between' },
|
|
|
|
|
'.justify-around': { 'justify-content': 'space-around' },
|
|
|
|
|
'.justify-evenly': { 'justify-content': 'space-evenly' },
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
justifyItems: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.justify-items-start': { 'justify-items': 'start' },
|
|
|
|
|
'.justify-items-end': { 'justify-items': 'end' },
|
|
|
|
|
'.justify-items-center': { 'justify-items': 'center' },
|
|
|
|
|
'.justify-items-stretch': { 'justify-items': 'stretch' },
|
|
|
|
|
})
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
gap: createUtilityPlugin('gap', [
|
|
|
|
|
['gap', ['gap']],
|
|
|
|
|
[
|
|
|
|
|
['gap-x', ['columnGap']],
|
|
|
|
|
['gap-y', ['rowGap']],
|
|
|
|
|
],
|
|
|
|
|
]),
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
space: ({ matchUtilities, addUtilities, theme }) => {
|
|
|
|
|
matchUtilities(
|
|
|
|
|
{
|
|
|
|
|
'space-x': (value) => {
|
|
|
|
|
value = value === '0' ? '0px' : value
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
return {
|
|
|
|
|
'& > :not([hidden]) ~ :not([hidden])': {
|
|
|
|
|
'--tw-space-x-reverse': '0',
|
|
|
|
|
'margin-right': `calc(${value} * var(--tw-space-x-reverse))`,
|
|
|
|
|
'margin-left': `calc(${value} * calc(1 - var(--tw-space-x-reverse)))`,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
'space-y': (value) => {
|
|
|
|
|
value = value === '0' ? '0px' : value
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
return {
|
|
|
|
|
'& > :not([hidden]) ~ :not([hidden])': {
|
|
|
|
|
'--tw-space-y-reverse': '0',
|
|
|
|
|
'margin-top': `calc(${value} * calc(1 - var(--tw-space-y-reverse)))`,
|
|
|
|
|
'margin-bottom': `calc(${value} * var(--tw-space-y-reverse))`,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
2021-10-06 13:42:05 -04:00
|
|
|
{ values: theme('space'), supportsNegativeValues: true }
|
2021-09-24 18:57:01 +02:00
|
|
|
)
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
addUtilities({
|
|
|
|
|
'.space-y-reverse > :not([hidden]) ~ :not([hidden])': { '--tw-space-y-reverse': '1' },
|
|
|
|
|
'.space-x-reverse > :not([hidden]) ~ :not([hidden])': { '--tw-space-x-reverse': '1' },
|
|
|
|
|
})
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
divideWidth: ({ matchUtilities, addUtilities, theme }) => {
|
|
|
|
|
matchUtilities(
|
|
|
|
|
{
|
|
|
|
|
'divide-x': (value) => {
|
|
|
|
|
value = value === '0' ? '0px' : value
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
return {
|
|
|
|
|
'& > :not([hidden]) ~ :not([hidden])': {
|
|
|
|
|
'@defaults border-width': {},
|
|
|
|
|
'--tw-divide-x-reverse': '0',
|
|
|
|
|
'border-right-width': `calc(${value} * var(--tw-divide-x-reverse))`,
|
|
|
|
|
'border-left-width': `calc(${value} * calc(1 - var(--tw-divide-x-reverse)))`,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
'divide-y': (value) => {
|
|
|
|
|
value = value === '0' ? '0px' : value
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
return {
|
|
|
|
|
'& > :not([hidden]) ~ :not([hidden])': {
|
|
|
|
|
'@defaults border-width': {},
|
|
|
|
|
'--tw-divide-y-reverse': '0',
|
|
|
|
|
'border-top-width': `calc(${value} * calc(1 - var(--tw-divide-y-reverse)))`,
|
|
|
|
|
'border-bottom-width': `calc(${value} * var(--tw-divide-y-reverse))`,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
},
|
2021-09-24 18:57:01 +02:00
|
|
|
{ values: theme('divideWidth'), type: ['line-width', 'length'] }
|
|
|
|
|
)
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
addUtilities({
|
|
|
|
|
'.divide-y-reverse > :not([hidden]) ~ :not([hidden])': {
|
|
|
|
|
'@defaults border-width': {},
|
|
|
|
|
'--tw-divide-y-reverse': '1',
|
2021-09-09 15:22:50 +02:00
|
|
|
},
|
2021-09-24 18:57:01 +02:00
|
|
|
'.divide-x-reverse > :not([hidden]) ~ :not([hidden])': {
|
|
|
|
|
'@defaults border-width': {},
|
|
|
|
|
'--tw-divide-x-reverse': '1',
|
2021-09-09 15:22:50 +02:00
|
|
|
},
|
2021-09-24 18:57:01 +02:00
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
divideStyle: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.divide-solid > :not([hidden]) ~ :not([hidden])': { 'border-style': 'solid' },
|
|
|
|
|
'.divide-dashed > :not([hidden]) ~ :not([hidden])': { 'border-style': 'dashed' },
|
|
|
|
|
'.divide-dotted > :not([hidden]) ~ :not([hidden])': { 'border-style': 'dotted' },
|
|
|
|
|
'.divide-double > :not([hidden]) ~ :not([hidden])': { 'border-style': 'double' },
|
|
|
|
|
'.divide-none > :not([hidden]) ~ :not([hidden])': { 'border-style': 'none' },
|
|
|
|
|
})
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
divideColor: ({ matchUtilities, theme, corePlugins }) => {
|
|
|
|
|
matchUtilities(
|
|
|
|
|
{
|
|
|
|
|
divide: (value) => {
|
|
|
|
|
if (!corePlugins('divideOpacity')) {
|
|
|
|
|
return {
|
|
|
|
|
['& > :not([hidden]) ~ :not([hidden])']: {
|
|
|
|
|
'border-color': toColorValue(value),
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-10 09:35:15 -04:00
|
|
|
return {
|
2021-09-24 18:57:01 +02:00
|
|
|
['& > :not([hidden]) ~ :not([hidden])']: withAlphaVariable({
|
|
|
|
|
color: value,
|
|
|
|
|
property: 'border-color',
|
|
|
|
|
variable: '--tw-divide-opacity',
|
|
|
|
|
}),
|
2021-09-10 09:35:15 -04:00
|
|
|
}
|
2021-09-24 18:57:01 +02:00
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
},
|
2021-09-24 18:57:01 +02:00
|
|
|
{
|
|
|
|
|
values: (({ DEFAULT: _, ...colors }) => colors)(flattenColorPalette(theme('divideColor'))),
|
|
|
|
|
type: 'color',
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
divideOpacity: ({ matchUtilities, theme }) => {
|
|
|
|
|
matchUtilities(
|
|
|
|
|
{
|
|
|
|
|
'divide-opacity': (value) => {
|
|
|
|
|
return { [`& > :not([hidden]) ~ :not([hidden])`]: { '--tw-divide-opacity': value } }
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
},
|
2021-09-24 18:57:01 +02:00
|
|
|
{ values: theme('divideOpacity') }
|
|
|
|
|
)
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
placeSelf: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.place-self-auto': { 'place-self': 'auto' },
|
|
|
|
|
'.place-self-start': { 'place-self': 'start' },
|
|
|
|
|
'.place-self-end': { 'place-self': 'end' },
|
|
|
|
|
'.place-self-center': { 'place-self': 'center' },
|
|
|
|
|
'.place-self-stretch': { 'place-self': 'stretch' },
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
alignSelf: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.self-auto': { 'align-self': 'auto' },
|
|
|
|
|
'.self-start': { 'align-self': 'flex-start' },
|
|
|
|
|
'.self-end': { 'align-self': 'flex-end' },
|
|
|
|
|
'.self-center': { 'align-self': 'center' },
|
|
|
|
|
'.self-stretch': { 'align-self': 'stretch' },
|
|
|
|
|
'.self-baseline': { 'align-self': 'baseline' },
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
justifySelf: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.justify-self-auto': { 'justify-self': 'auto' },
|
|
|
|
|
'.justify-self-start': { 'justify-self': 'start' },
|
|
|
|
|
'.justify-self-end': { 'justify-self': 'end' },
|
|
|
|
|
'.justify-self-center': { 'justify-self': 'center' },
|
|
|
|
|
'.justify-self-stretch': { 'justify-self': 'stretch' },
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
overflow: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.overflow-auto': { overflow: 'auto' },
|
|
|
|
|
'.overflow-hidden': { overflow: 'hidden' },
|
2021-09-28 14:17:41 -04:00
|
|
|
'.overflow-clip': { overflow: 'clip' },
|
2021-09-24 18:57:01 +02:00
|
|
|
'.overflow-visible': { overflow: 'visible' },
|
|
|
|
|
'.overflow-scroll': { overflow: 'scroll' },
|
|
|
|
|
'.overflow-x-auto': { 'overflow-x': 'auto' },
|
|
|
|
|
'.overflow-y-auto': { 'overflow-y': 'auto' },
|
|
|
|
|
'.overflow-x-hidden': { 'overflow-x': 'hidden' },
|
|
|
|
|
'.overflow-y-hidden': { 'overflow-y': 'hidden' },
|
2021-09-28 14:17:41 -04:00
|
|
|
'.overflow-x-clip': { 'overflow-x': 'clip' },
|
|
|
|
|
'.overflow-y-clip': { 'overflow-y': 'clip' },
|
2021-09-24 18:57:01 +02:00
|
|
|
'.overflow-x-visible': { 'overflow-x': 'visible' },
|
|
|
|
|
'.overflow-y-visible': { 'overflow-y': 'visible' },
|
|
|
|
|
'.overflow-x-scroll': { 'overflow-x': 'scroll' },
|
|
|
|
|
'.overflow-y-scroll': { 'overflow-y': 'scroll' },
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
overscrollBehavior: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.overscroll-auto': { 'overscroll-behavior': 'auto' },
|
|
|
|
|
'.overscroll-contain': { 'overscroll-behavior': 'contain' },
|
|
|
|
|
'.overscroll-none': { 'overscroll-behavior': 'none' },
|
|
|
|
|
'.overscroll-y-auto': { 'overscroll-behavior-y': 'auto' },
|
|
|
|
|
'.overscroll-y-contain': { 'overscroll-behavior-y': 'contain' },
|
|
|
|
|
'.overscroll-y-none': { 'overscroll-behavior-y': 'none' },
|
|
|
|
|
'.overscroll-x-auto': { 'overscroll-behavior-x': 'auto' },
|
|
|
|
|
'.overscroll-x-contain': { 'overscroll-behavior-x': 'contain' },
|
|
|
|
|
'.overscroll-x-none': { 'overscroll-behavior-x': 'none' },
|
|
|
|
|
})
|
|
|
|
|
},
|
2021-09-11 14:13:28 +01:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
scrollBehavior: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.scroll-auto': { 'scroll-behavior': 'auto' },
|
|
|
|
|
'.scroll-smooth': { 'scroll-behavior': 'smooth' },
|
|
|
|
|
})
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
textOverflow: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.truncate': { overflow: 'hidden', 'text-overflow': 'ellipsis', 'white-space': 'nowrap' },
|
2021-09-28 14:17:41 -04:00
|
|
|
'.overflow-ellipsis': { 'text-overflow': 'ellipsis' }, // Deprecated
|
|
|
|
|
'.text-ellipsis': { 'text-overflow': 'ellipsis' },
|
|
|
|
|
'.text-clip': { 'text-overflow': 'clip' },
|
2021-09-24 18:57:01 +02:00
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
whitespace: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.whitespace-normal': { 'white-space': 'normal' },
|
|
|
|
|
'.whitespace-nowrap': { 'white-space': 'nowrap' },
|
|
|
|
|
'.whitespace-pre': { 'white-space': 'pre' },
|
|
|
|
|
'.whitespace-pre-line': { 'white-space': 'pre-line' },
|
|
|
|
|
'.whitespace-pre-wrap': { 'white-space': 'pre-wrap' },
|
|
|
|
|
})
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
wordBreak: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.break-normal': { 'overflow-wrap': 'normal', 'word-break': 'normal' },
|
|
|
|
|
'.break-words': { 'overflow-wrap': 'break-word' },
|
|
|
|
|
'.break-all': { 'word-break': 'break-all' },
|
|
|
|
|
})
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
borderRadius: createUtilityPlugin('borderRadius', [
|
|
|
|
|
['rounded', ['border-radius']],
|
2021-09-09 15:22:50 +02:00
|
|
|
[
|
2021-09-24 18:57:01 +02:00
|
|
|
['rounded-t', ['border-top-left-radius', 'border-top-right-radius']],
|
|
|
|
|
['rounded-r', ['border-top-right-radius', 'border-bottom-right-radius']],
|
|
|
|
|
['rounded-b', ['border-bottom-right-radius', 'border-bottom-left-radius']],
|
|
|
|
|
['rounded-l', ['border-top-left-radius', 'border-bottom-left-radius']],
|
2021-09-09 15:22:50 +02:00
|
|
|
],
|
2021-09-24 18:57:01 +02:00
|
|
|
[
|
|
|
|
|
['rounded-tl', ['border-top-left-radius']],
|
|
|
|
|
['rounded-tr', ['border-top-right-radius']],
|
|
|
|
|
['rounded-br', ['border-bottom-right-radius']],
|
|
|
|
|
['rounded-bl', ['border-bottom-left-radius']],
|
|
|
|
|
],
|
|
|
|
|
]),
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
borderWidth: createUtilityPlugin(
|
|
|
|
|
'borderWidth',
|
|
|
|
|
[
|
|
|
|
|
['border', [['@defaults border-width', {}], 'border-width']],
|
2021-09-29 10:32:31 -04:00
|
|
|
[
|
|
|
|
|
['border-x', [['@defaults border-width', {}], 'border-left-width', 'border-right-width']],
|
|
|
|
|
['border-y', [['@defaults border-width', {}], 'border-top-width', 'border-bottom-width']],
|
|
|
|
|
],
|
2021-09-24 18:57:01 +02:00
|
|
|
[
|
|
|
|
|
['border-t', [['@defaults border-width', {}], 'border-top-width']],
|
|
|
|
|
['border-r', [['@defaults border-width', {}], 'border-right-width']],
|
|
|
|
|
['border-b', [['@defaults border-width', {}], 'border-bottom-width']],
|
|
|
|
|
['border-l', [['@defaults border-width', {}], 'border-left-width']],
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
{ type: ['line-width', 'length'] }
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
borderStyle: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.border-solid': { 'border-style': 'solid' },
|
|
|
|
|
'.border-dashed': { 'border-style': 'dashed' },
|
|
|
|
|
'.border-dotted': { 'border-style': 'dotted' },
|
|
|
|
|
'.border-double': { 'border-style': 'double' },
|
|
|
|
|
'.border-hidden': { 'border-style': 'hidden' },
|
|
|
|
|
'.border-none': { 'border-style': 'none' },
|
2021-09-09 15:22:50 +02:00
|
|
|
})
|
2021-09-24 18:57:01 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
borderColor: ({ addBase, matchUtilities, theme, corePlugins }) => {
|
|
|
|
|
if (!corePlugins('borderOpacity')) {
|
|
|
|
|
let value = theme('borderColor.DEFAULT', 'currentColor')
|
|
|
|
|
addBase({
|
|
|
|
|
'@defaults border-width': {
|
|
|
|
|
'border-color': toColorValue(value),
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
} else {
|
|
|
|
|
addBase({
|
|
|
|
|
'@defaults border-width': withAlphaVariable({
|
|
|
|
|
color: theme('borderColor.DEFAULT', 'currentColor'),
|
2021-09-09 15:22:50 +02:00
|
|
|
property: 'border-color',
|
|
|
|
|
variable: '--tw-border-opacity',
|
2021-09-24 18:57:01 +02:00
|
|
|
}),
|
|
|
|
|
})
|
2021-09-09 15:22:50 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
matchUtilities(
|
|
|
|
|
{
|
|
|
|
|
border: (value) => {
|
|
|
|
|
if (!corePlugins('borderOpacity')) {
|
|
|
|
|
return {
|
|
|
|
|
'border-color': toColorValue(value),
|
|
|
|
|
}
|
2021-09-10 09:35:15 -04:00
|
|
|
}
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
return withAlphaVariable({
|
|
|
|
|
color: value,
|
|
|
|
|
property: 'border-color',
|
|
|
|
|
variable: '--tw-border-opacity',
|
|
|
|
|
})
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
},
|
2021-09-24 18:57:01 +02:00
|
|
|
{
|
|
|
|
|
values: (({ DEFAULT: _, ...colors }) => colors)(flattenColorPalette(theme('borderColor'))),
|
|
|
|
|
type: ['color'],
|
|
|
|
|
}
|
|
|
|
|
)
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-29 10:32:31 -04:00
|
|
|
matchUtilities(
|
|
|
|
|
{
|
|
|
|
|
'border-x': (value) => {
|
|
|
|
|
if (!corePlugins('borderOpacity')) {
|
|
|
|
|
return {
|
|
|
|
|
'border-left-color': toColorValue(value),
|
|
|
|
|
'border-right-color': toColorValue(value),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return withAlphaVariable({
|
|
|
|
|
color: value,
|
|
|
|
|
property: ['border-left-color', 'border-right-color'],
|
|
|
|
|
variable: '--tw-border-opacity',
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
'border-y': (value) => {
|
|
|
|
|
if (!corePlugins('borderOpacity')) {
|
|
|
|
|
return {
|
|
|
|
|
'border-top-color': toColorValue(value),
|
|
|
|
|
'border-bottom-color': toColorValue(value),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return withAlphaVariable({
|
|
|
|
|
color: value,
|
|
|
|
|
property: ['border-top-color', 'border-bottom-color'],
|
|
|
|
|
variable: '--tw-border-opacity',
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
values: (({ DEFAULT: _, ...colors }) => colors)(flattenColorPalette(theme('borderColor'))),
|
|
|
|
|
type: 'color',
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
matchUtilities(
|
|
|
|
|
{
|
|
|
|
|
'border-t': (value) => {
|
|
|
|
|
if (!corePlugins('borderOpacity')) {
|
|
|
|
|
return {
|
|
|
|
|
'border-top-color': toColorValue(value),
|
|
|
|
|
}
|
2021-09-10 09:35:15 -04:00
|
|
|
}
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
return withAlphaVariable({
|
|
|
|
|
color: value,
|
|
|
|
|
property: 'border-top-color',
|
|
|
|
|
variable: '--tw-border-opacity',
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
'border-r': (value) => {
|
|
|
|
|
if (!corePlugins('borderOpacity')) {
|
|
|
|
|
return {
|
|
|
|
|
'border-right-color': toColorValue(value),
|
|
|
|
|
}
|
2021-09-10 09:35:15 -04:00
|
|
|
}
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
return withAlphaVariable({
|
|
|
|
|
color: value,
|
|
|
|
|
property: 'border-right-color',
|
|
|
|
|
variable: '--tw-border-opacity',
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
'border-b': (value) => {
|
|
|
|
|
if (!corePlugins('borderOpacity')) {
|
|
|
|
|
return {
|
|
|
|
|
'border-bottom-color': toColorValue(value),
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
return withAlphaVariable({
|
|
|
|
|
color: value,
|
|
|
|
|
property: 'border-bottom-color',
|
|
|
|
|
variable: '--tw-border-opacity',
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
'border-l': (value) => {
|
|
|
|
|
if (!corePlugins('borderOpacity')) {
|
|
|
|
|
return {
|
|
|
|
|
'border-left-color': toColorValue(value),
|
|
|
|
|
}
|
2021-09-10 09:35:15 -04:00
|
|
|
}
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
return withAlphaVariable({
|
|
|
|
|
color: value,
|
|
|
|
|
property: 'border-left-color',
|
|
|
|
|
variable: '--tw-border-opacity',
|
|
|
|
|
})
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
},
|
2021-09-24 18:57:01 +02:00
|
|
|
{
|
|
|
|
|
values: (({ DEFAULT: _, ...colors }) => colors)(flattenColorPalette(theme('borderColor'))),
|
|
|
|
|
type: 'color',
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
borderOpacity: createUtilityPlugin('borderOpacity', [
|
|
|
|
|
['border-opacity', ['--tw-border-opacity']],
|
|
|
|
|
]),
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
backgroundColor: ({ matchUtilities, theme, corePlugins }) => {
|
2021-09-09 15:22:50 +02:00
|
|
|
matchUtilities(
|
|
|
|
|
{
|
2021-09-24 18:57:01 +02:00
|
|
|
bg: (value) => {
|
|
|
|
|
if (!corePlugins('backgroundOpacity')) {
|
|
|
|
|
return {
|
|
|
|
|
'background-color': toColorValue(value),
|
|
|
|
|
}
|
2021-09-09 15:22:50 +02:00
|
|
|
}
|
|
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
return withAlphaVariable({
|
|
|
|
|
color: value,
|
|
|
|
|
property: 'background-color',
|
|
|
|
|
variable: '--tw-bg-opacity',
|
|
|
|
|
})
|
2021-09-09 15:22:50 +02:00
|
|
|
},
|
|
|
|
|
},
|
2021-09-24 18:57:01 +02:00
|
|
|
{ values: flattenColorPalette(theme('backgroundColor')), type: 'color' }
|
2021-09-09 15:22:50 +02:00
|
|
|
)
|
2021-09-24 18:57:01 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
backgroundOpacity: createUtilityPlugin('backgroundOpacity', [
|
|
|
|
|
['bg-opacity', ['--tw-bg-opacity']],
|
|
|
|
|
]),
|
|
|
|
|
backgroundImage: createUtilityPlugin('backgroundImage', [['bg', ['background-image']]], {
|
|
|
|
|
type: ['lookup', 'image', 'url'],
|
|
|
|
|
}),
|
|
|
|
|
gradientColorStops: (() => {
|
|
|
|
|
function transparentTo(value) {
|
|
|
|
|
return withAlphaValue(value, 0, 'rgb(255 255 255 / 0)')
|
|
|
|
|
}
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
return function ({ matchUtilities, theme }) {
|
|
|
|
|
let options = {
|
|
|
|
|
values: flattenColorPalette(theme('gradientColorStops')),
|
|
|
|
|
type: ['color', 'any'],
|
|
|
|
|
}
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
matchUtilities(
|
|
|
|
|
{
|
|
|
|
|
from: (value) => {
|
|
|
|
|
let transparentToValue = transparentTo(value)
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
return {
|
|
|
|
|
'--tw-gradient-from': toColorValue(value, 'from'),
|
|
|
|
|
'--tw-gradient-stops': `var(--tw-gradient-from), var(--tw-gradient-to, ${transparentToValue})`,
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
options
|
|
|
|
|
)
|
|
|
|
|
matchUtilities(
|
|
|
|
|
{
|
|
|
|
|
via: (value) => {
|
|
|
|
|
let transparentToValue = transparentTo(value)
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
'--tw-gradient-stops': `var(--tw-gradient-from), ${toColorValue(
|
|
|
|
|
value,
|
|
|
|
|
'via'
|
|
|
|
|
)}, var(--tw-gradient-to, ${transparentToValue})`,
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
options
|
|
|
|
|
)
|
|
|
|
|
matchUtilities(
|
|
|
|
|
{ to: (value) => ({ '--tw-gradient-to': toColorValue(value, 'to') }) },
|
|
|
|
|
options
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
})(),
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
boxDecorationBreak: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.decoration-slice': { 'box-decoration-break': 'slice' },
|
|
|
|
|
'.decoration-clone': { 'box-decoration-break': 'clone' },
|
|
|
|
|
})
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
backgroundSize: createUtilityPlugin('backgroundSize', [['bg', ['background-size']]], {
|
|
|
|
|
type: ['lookup', 'length', 'percentage'],
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
|
|
backgroundAttachment: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.bg-fixed': { 'background-attachment': 'fixed' },
|
|
|
|
|
'.bg-local': { 'background-attachment': 'local' },
|
|
|
|
|
'.bg-scroll': { 'background-attachment': 'scroll' },
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
backgroundClip: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.bg-clip-border': { 'background-clip': 'border-box' },
|
|
|
|
|
'.bg-clip-padding': { 'background-clip': 'padding-box' },
|
|
|
|
|
'.bg-clip-content': { 'background-clip': 'content-box' },
|
|
|
|
|
'.bg-clip-text': { 'background-clip': 'text' },
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
backgroundPosition: createUtilityPlugin('backgroundPosition', [['bg', ['background-position']]], {
|
|
|
|
|
type: ['lookup', 'position'],
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
|
|
backgroundRepeat: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.bg-repeat': { 'background-repeat': 'repeat' },
|
|
|
|
|
'.bg-no-repeat': { 'background-repeat': 'no-repeat' },
|
|
|
|
|
'.bg-repeat-x': { 'background-repeat': 'repeat-x' },
|
|
|
|
|
'.bg-repeat-y': { 'background-repeat': 'repeat-y' },
|
|
|
|
|
'.bg-repeat-round': { 'background-repeat': 'round' },
|
|
|
|
|
'.bg-repeat-space': { 'background-repeat': 'space' },
|
|
|
|
|
})
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
backgroundOrigin: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.bg-origin-border': { 'background-origin': 'border-box' },
|
|
|
|
|
'.bg-origin-padding': { 'background-origin': 'padding-box' },
|
|
|
|
|
'.bg-origin-content': { 'background-origin': 'content-box' },
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
fill: ({ matchUtilities, theme }) => {
|
|
|
|
|
matchUtilities(
|
|
|
|
|
{
|
|
|
|
|
fill: (value) => {
|
|
|
|
|
return { fill: toColorValue(value) }
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
},
|
2021-09-24 18:57:01 +02:00
|
|
|
{ values: flattenColorPalette(theme('fill')), type: ['color', 'any'] }
|
|
|
|
|
)
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
stroke: ({ matchUtilities, theme }) => {
|
|
|
|
|
matchUtilities(
|
|
|
|
|
{
|
|
|
|
|
stroke: (value) => {
|
|
|
|
|
return { stroke: toColorValue(value) }
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
},
|
2021-09-24 18:57:01 +02:00
|
|
|
{ values: flattenColorPalette(theme('stroke')), type: ['color', 'url'] }
|
|
|
|
|
)
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
strokeWidth: createUtilityPlugin('strokeWidth', [['stroke', ['stroke-width']]], {
|
|
|
|
|
type: ['length', 'number', 'percentage'],
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
|
|
objectFit: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.object-contain': { 'object-fit': 'contain' },
|
|
|
|
|
'.object-cover': { 'object-fit': 'cover' },
|
|
|
|
|
'.object-fill': { 'object-fit': 'fill' },
|
|
|
|
|
'.object-none': { 'object-fit': 'none' },
|
|
|
|
|
'.object-scale-down': { 'object-fit': 'scale-down' },
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
objectPosition: createUtilityPlugin('objectPosition', [['object', ['object-position']]]),
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
padding: createUtilityPlugin('padding', [
|
|
|
|
|
['p', ['padding']],
|
|
|
|
|
[
|
|
|
|
|
['px', ['padding-left', 'padding-right']],
|
|
|
|
|
['py', ['padding-top', 'padding-bottom']],
|
|
|
|
|
],
|
|
|
|
|
[
|
|
|
|
|
['pt', ['padding-top']],
|
|
|
|
|
['pr', ['padding-right']],
|
|
|
|
|
['pb', ['padding-bottom']],
|
|
|
|
|
['pl', ['padding-left']],
|
|
|
|
|
],
|
|
|
|
|
]),
|
|
|
|
|
|
|
|
|
|
textAlign: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.text-left': { 'text-align': 'left' },
|
|
|
|
|
'.text-center': { 'text-align': 'center' },
|
|
|
|
|
'.text-right': { 'text-align': 'right' },
|
|
|
|
|
'.text-justify': { 'text-align': 'justify' },
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
2021-10-06 13:42:05 -04:00
|
|
|
textIndent: createUtilityPlugin('textIndent', [['indent', ['text-indent']]], {
|
|
|
|
|
supportsNegativeValues: true,
|
|
|
|
|
}),
|
2021-09-24 18:57:01 +02:00
|
|
|
|
|
|
|
|
verticalAlign: ({ addUtilities, matchUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.align-baseline': { 'vertical-align': 'baseline' },
|
|
|
|
|
'.align-top': { 'vertical-align': 'top' },
|
|
|
|
|
'.align-middle': { 'vertical-align': 'middle' },
|
|
|
|
|
'.align-bottom': { 'vertical-align': 'bottom' },
|
|
|
|
|
'.align-text-top': { 'vertical-align': 'text-top' },
|
|
|
|
|
'.align-text-bottom': { 'vertical-align': 'text-bottom' },
|
|
|
|
|
'.align-sub': { 'vertical-align': 'sub' },
|
|
|
|
|
'.align-super': { 'vertical-align': 'super' },
|
|
|
|
|
})
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
matchUtilities({ align: (value) => ({ 'vertical-align': value }) })
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
fontFamily: createUtilityPlugin('fontFamily', [['font', ['fontFamily']]], {
|
|
|
|
|
type: ['lookup', 'generic-name', 'family-name'],
|
|
|
|
|
}),
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
fontSize: ({ matchUtilities, theme }) => {
|
|
|
|
|
matchUtilities(
|
|
|
|
|
{
|
|
|
|
|
text: (value) => {
|
|
|
|
|
let [fontSize, options] = Array.isArray(value) ? value : [value]
|
|
|
|
|
let { lineHeight, letterSpacing } = isPlainObject(options)
|
|
|
|
|
? options
|
|
|
|
|
: { lineHeight: options }
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
return {
|
|
|
|
|
'font-size': fontSize,
|
|
|
|
|
...(lineHeight === undefined ? {} : { 'line-height': lineHeight }),
|
|
|
|
|
...(letterSpacing === undefined ? {} : { 'letter-spacing': letterSpacing }),
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
},
|
2021-09-24 18:57:01 +02:00
|
|
|
{
|
|
|
|
|
values: theme('fontSize'),
|
|
|
|
|
type: ['absolute-size', 'relative-size', 'length', 'percentage'],
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
fontWeight: createUtilityPlugin('fontWeight', [['font', ['fontWeight']]], {
|
|
|
|
|
type: ['lookup', 'number'],
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
|
|
textTransform: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.uppercase': { 'text-transform': 'uppercase' },
|
|
|
|
|
'.lowercase': { 'text-transform': 'lowercase' },
|
|
|
|
|
'.capitalize': { 'text-transform': 'capitalize' },
|
|
|
|
|
'.normal-case': { 'text-transform': 'none' },
|
|
|
|
|
})
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
fontStyle: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.italic': { 'font-style': 'italic' },
|
|
|
|
|
'.not-italic': { 'font-style': 'normal' },
|
|
|
|
|
})
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
fontVariantNumeric: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
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
|
|
|
'@defaults font-variant-numeric': {
|
|
|
|
|
'--tw-ordinal': 'var(--tw-empty,/*!*/ /*!*/)',
|
|
|
|
|
'--tw-slashed-zero': 'var(--tw-empty,/*!*/ /*!*/)',
|
|
|
|
|
'--tw-numeric-figure': 'var(--tw-empty,/*!*/ /*!*/)',
|
|
|
|
|
'--tw-numeric-spacing': 'var(--tw-empty,/*!*/ /*!*/)',
|
|
|
|
|
'--tw-numeric-fraction': 'var(--tw-empty,/*!*/ /*!*/)',
|
|
|
|
|
'--tw-font-variant-numeric':
|
|
|
|
|
'var(--tw-ordinal) var(--tw-slashed-zero) var(--tw-numeric-figure) var(--tw-numeric-spacing) var(--tw-numeric-fraction)',
|
|
|
|
|
},
|
2021-09-24 18:57:01 +02:00
|
|
|
'.normal-nums': { 'font-variant-numeric': 'normal' },
|
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
|
|
|
'.ordinal': {
|
|
|
|
|
'@defaults font-variant-numeric': {},
|
|
|
|
|
'--tw-ordinal': 'ordinal',
|
|
|
|
|
'font-variant-numeric': 'var(--tw-font-variant-numeric)',
|
|
|
|
|
},
|
|
|
|
|
'.slashed-zero': {
|
|
|
|
|
'@defaults font-variant-numeric': {},
|
|
|
|
|
'--tw-slashed-zero': 'slashed-zero',
|
|
|
|
|
'font-variant-numeric': 'var(--tw-font-variant-numeric)',
|
|
|
|
|
},
|
|
|
|
|
'.lining-nums': {
|
|
|
|
|
'@defaults font-variant-numeric': {},
|
|
|
|
|
'--tw-numeric-figure': 'lining-nums',
|
|
|
|
|
'font-variant-numeric': 'var(--tw-font-variant-numeric)',
|
|
|
|
|
},
|
|
|
|
|
'.oldstyle-nums': {
|
|
|
|
|
'@defaults font-variant-numeric': {},
|
|
|
|
|
'--tw-numeric-figure': 'oldstyle-nums',
|
|
|
|
|
'font-variant-numeric': 'var(--tw-font-variant-numeric)',
|
|
|
|
|
},
|
|
|
|
|
'.proportional-nums': {
|
|
|
|
|
'@defaults font-variant-numeric': {},
|
|
|
|
|
'--tw-numeric-spacing': 'proportional-nums',
|
|
|
|
|
'font-variant-numeric': 'var(--tw-font-variant-numeric)',
|
|
|
|
|
},
|
|
|
|
|
'.tabular-nums': {
|
|
|
|
|
'@defaults font-variant-numeric': {},
|
|
|
|
|
'--tw-numeric-spacing': 'tabular-nums',
|
|
|
|
|
'font-variant-numeric': 'var(--tw-font-variant-numeric)',
|
|
|
|
|
},
|
|
|
|
|
'.diagonal-fractions': {
|
|
|
|
|
'@defaults font-variant-numeric': {},
|
|
|
|
|
'--tw-numeric-fraction': 'diagonal-fractions',
|
|
|
|
|
'font-variant-numeric': 'var(--tw-font-variant-numeric)',
|
|
|
|
|
},
|
|
|
|
|
'.stacked-fractions': {
|
|
|
|
|
'@defaults font-variant-numeric': {},
|
|
|
|
|
'--tw-numeric-fraction': 'stacked-fractions',
|
|
|
|
|
'font-variant-numeric': 'var(--tw-font-variant-numeric)',
|
|
|
|
|
},
|
2021-09-24 18:57:01 +02:00
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
lineHeight: createUtilityPlugin('lineHeight', [['leading', ['lineHeight']]]),
|
2021-10-06 13:42:05 -04:00
|
|
|
letterSpacing: createUtilityPlugin('letterSpacing', [['tracking', ['letterSpacing']]], {
|
|
|
|
|
supportsNegativeValues: true,
|
|
|
|
|
}),
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
textColor: ({ matchUtilities, theme, corePlugins }) => {
|
|
|
|
|
matchUtilities(
|
2021-09-09 15:22:50 +02:00
|
|
|
{
|
2021-09-24 18:57:01 +02:00
|
|
|
text: (value) => {
|
|
|
|
|
if (!corePlugins('textOpacity')) {
|
|
|
|
|
return { color: toColorValue(value) }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return withAlphaVariable({
|
|
|
|
|
color: value,
|
|
|
|
|
property: 'color',
|
|
|
|
|
variable: '--tw-text-opacity',
|
|
|
|
|
})
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
},
|
2021-09-24 18:57:01 +02:00
|
|
|
{ values: flattenColorPalette(theme('textColor')), type: 'color' }
|
|
|
|
|
)
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
textOpacity: createUtilityPlugin('textOpacity', [['text-opacity', ['--tw-text-opacity']]]),
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
textDecoration: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.underline': { 'text-decoration': 'underline' },
|
|
|
|
|
'.line-through': { 'text-decoration': 'line-through' },
|
|
|
|
|
'.no-underline': { 'text-decoration': 'none' },
|
|
|
|
|
})
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-10-12 13:35:59 -04:00
|
|
|
textDecorationColor: ({ matchUtilities, theme }) => {
|
|
|
|
|
matchUtilities(
|
|
|
|
|
{
|
|
|
|
|
decoration: (value) => {
|
|
|
|
|
return { 'text-decoration-color': toColorValue(value) }
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{ values: flattenColorPalette(theme('textDecorationColor')), type: ['color', 'any'] }
|
|
|
|
|
)
|
|
|
|
|
},
|
|
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
fontSmoothing: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.antialiased': {
|
|
|
|
|
'-webkit-font-smoothing': 'antialiased',
|
|
|
|
|
'-moz-osx-font-smoothing': 'grayscale',
|
2021-09-09 15:22:50 +02:00
|
|
|
},
|
2021-09-24 18:57:01 +02:00
|
|
|
'.subpixel-antialiased': {
|
|
|
|
|
'-webkit-font-smoothing': 'auto',
|
|
|
|
|
'-moz-osx-font-smoothing': 'auto',
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
placeholderColor: ({ matchUtilities, theme, corePlugins }) => {
|
|
|
|
|
matchUtilities(
|
|
|
|
|
{
|
|
|
|
|
placeholder: (value) => {
|
|
|
|
|
if (!corePlugins('placeholderOpacity')) {
|
|
|
|
|
return {
|
|
|
|
|
'&::placeholder': {
|
|
|
|
|
color: toColorValue(value),
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-10 09:35:15 -04:00
|
|
|
return {
|
2021-09-24 18:57:01 +02:00
|
|
|
'&::placeholder': withAlphaVariable({
|
|
|
|
|
color: value,
|
|
|
|
|
property: 'color',
|
|
|
|
|
variable: '--tw-placeholder-opacity',
|
|
|
|
|
}),
|
2021-09-10 09:35:15 -04:00
|
|
|
}
|
2021-09-24 18:57:01 +02:00
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
},
|
2021-09-24 18:57:01 +02:00
|
|
|
{ values: flattenColorPalette(theme('placeholderColor')), type: ['color', 'any'] }
|
|
|
|
|
)
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
placeholderOpacity: ({ matchUtilities, theme }) => {
|
|
|
|
|
matchUtilities(
|
|
|
|
|
{
|
|
|
|
|
'placeholder-opacity': (value) => {
|
|
|
|
|
return { ['&::placeholder']: { '--tw-placeholder-opacity': value } }
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
},
|
2021-09-24 18:57:01 +02:00
|
|
|
{ values: theme('placeholderOpacity') }
|
|
|
|
|
)
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
caretColor: ({ matchUtilities, theme }) => {
|
|
|
|
|
matchUtilities(
|
|
|
|
|
{
|
|
|
|
|
caret: (value) => {
|
|
|
|
|
return { 'caret-color': toColorValue(value) }
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
},
|
2021-09-24 18:57:01 +02:00
|
|
|
{ values: flattenColorPalette(theme('caretColor')), type: ['color', 'any'] }
|
|
|
|
|
)
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
accentColor: ({ matchUtilities, theme }) => {
|
|
|
|
|
matchUtilities(
|
|
|
|
|
{
|
|
|
|
|
accent: (value) => {
|
|
|
|
|
return { 'accent-color': toColorValue(value) }
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
},
|
2021-09-24 18:57:01 +02:00
|
|
|
{ values: flattenColorPalette(theme('accentColor')), type: ['color', 'any'] }
|
|
|
|
|
)
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
opacity: createUtilityPlugin('opacity', [['opacity', ['opacity']]]),
|
|
|
|
|
|
|
|
|
|
backgroundBlendMode: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.bg-blend-normal': { 'background-blend-mode': 'normal' },
|
|
|
|
|
'.bg-blend-multiply': { 'background-blend-mode': 'multiply' },
|
|
|
|
|
'.bg-blend-screen': { 'background-blend-mode': 'screen' },
|
|
|
|
|
'.bg-blend-overlay': { 'background-blend-mode': 'overlay' },
|
|
|
|
|
'.bg-blend-darken': { 'background-blend-mode': 'darken' },
|
|
|
|
|
'.bg-blend-lighten': { 'background-blend-mode': 'lighten' },
|
|
|
|
|
'.bg-blend-color-dodge': { 'background-blend-mode': 'color-dodge' },
|
|
|
|
|
'.bg-blend-color-burn': { 'background-blend-mode': 'color-burn' },
|
|
|
|
|
'.bg-blend-hard-light': { 'background-blend-mode': 'hard-light' },
|
|
|
|
|
'.bg-blend-soft-light': { 'background-blend-mode': 'soft-light' },
|
|
|
|
|
'.bg-blend-difference': { 'background-blend-mode': 'difference' },
|
|
|
|
|
'.bg-blend-exclusion': { 'background-blend-mode': 'exclusion' },
|
|
|
|
|
'.bg-blend-hue': { 'background-blend-mode': 'hue' },
|
|
|
|
|
'.bg-blend-saturation': { 'background-blend-mode': 'saturation' },
|
|
|
|
|
'.bg-blend-color': { 'background-blend-mode': 'color' },
|
|
|
|
|
'.bg-blend-luminosity': { 'background-blend-mode': 'luminosity' },
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
mixBlendMode: ({ addUtilities }) => {
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.mix-blend-normal': { 'mix-blend-mode': 'normal' },
|
|
|
|
|
'.mix-blend-multiply': { 'mix-blend-mode': 'multiply' },
|
|
|
|
|
'.mix-blend-screen': { 'mix-blend-mode': 'screen' },
|
|
|
|
|
'.mix-blend-overlay': { 'mix-blend-mode': 'overlay' },
|
|
|
|
|
'.mix-blend-darken': { 'mix-blend-mode': 'darken' },
|
|
|
|
|
'.mix-blend-lighten': { 'mix-blend-mode': 'lighten' },
|
|
|
|
|
'.mix-blend-color-dodge': { 'mix-blend-mode': 'color-dodge' },
|
|
|
|
|
'.mix-blend-color-burn': { 'mix-blend-mode': 'color-burn' },
|
|
|
|
|
'.mix-blend-hard-light': { 'mix-blend-mode': 'hard-light' },
|
|
|
|
|
'.mix-blend-soft-light': { 'mix-blend-mode': 'soft-light' },
|
|
|
|
|
'.mix-blend-difference': { 'mix-blend-mode': 'difference' },
|
|
|
|
|
'.mix-blend-exclusion': { 'mix-blend-mode': 'exclusion' },
|
|
|
|
|
'.mix-blend-hue': { 'mix-blend-mode': 'hue' },
|
|
|
|
|
'.mix-blend-saturation': { 'mix-blend-mode': 'saturation' },
|
|
|
|
|
'.mix-blend-color': { 'mix-blend-mode': 'color' },
|
|
|
|
|
'.mix-blend-luminosity': { 'mix-blend-mode': 'luminosity' },
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
boxShadow: (() => {
|
|
|
|
|
let transformValue = transformThemeValue('boxShadow')
|
|
|
|
|
let defaultBoxShadow = [
|
|
|
|
|
`var(--tw-ring-offset-shadow, 0 0 #0000)`,
|
|
|
|
|
`var(--tw-ring-shadow, 0 0 #0000)`,
|
|
|
|
|
`var(--tw-shadow)`,
|
|
|
|
|
].join(', ')
|
|
|
|
|
|
|
|
|
|
return function ({ matchUtilities, addBase, theme }) {
|
|
|
|
|
addBase({
|
|
|
|
|
'@defaults box-shadow': {
|
|
|
|
|
'--tw-ring-offset-shadow': '0 0 #0000',
|
|
|
|
|
'--tw-ring-shadow': '0 0 #0000',
|
|
|
|
|
'--tw-shadow': '0 0 #0000',
|
|
|
|
|
},
|
|
|
|
|
})
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
matchUtilities(
|
|
|
|
|
{
|
|
|
|
|
shadow: (value) => {
|
|
|
|
|
value = transformValue(value)
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
'@defaults box-shadow': {},
|
|
|
|
|
'--tw-shadow': value === 'none' ? '0 0 #0000' : value,
|
|
|
|
|
'box-shadow': defaultBoxShadow,
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{ values: theme('boxShadow') }
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
})(),
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
outline: ({ matchUtilities, theme }) => {
|
|
|
|
|
matchUtilities(
|
|
|
|
|
{
|
|
|
|
|
outline: (value) => {
|
|
|
|
|
value = Array.isArray(value) ? value : value.split(',')
|
|
|
|
|
let [outline, outlineOffset = '0'] = Array.isArray(value) ? value : [value]
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
return { outline, 'outline-offset': outlineOffset }
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{ values: theme('outline') }
|
|
|
|
|
)
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
ringWidth: ({ matchUtilities, addBase, addUtilities, theme }) => {
|
|
|
|
|
let ringOpacityDefault = theme('ringOpacity.DEFAULT', '0.5')
|
|
|
|
|
let ringColorDefault = withAlphaValue(
|
|
|
|
|
theme('ringColor.DEFAULT'),
|
|
|
|
|
ringOpacityDefault,
|
|
|
|
|
`rgb(147 197 253 / ${ringOpacityDefault})`
|
|
|
|
|
)
|
2021-09-09 15:22:50 +02:00
|
|
|
|
|
|
|
|
addBase({
|
2021-09-24 18:57:01 +02:00
|
|
|
'@defaults ring-width': {
|
|
|
|
|
'--tw-ring-inset': 'var(--tw-empty,/*!*/ /*!*/)',
|
|
|
|
|
'--tw-ring-offset-width': theme('ringOffsetWidth.DEFAULT', '0px'),
|
|
|
|
|
'--tw-ring-offset-color': theme('ringOffsetColor.DEFAULT', '#fff'),
|
|
|
|
|
'--tw-ring-color': ringColorDefault,
|
2021-09-09 15:22:50 +02:00
|
|
|
'--tw-ring-offset-shadow': '0 0 #0000',
|
|
|
|
|
'--tw-ring-shadow': '0 0 #0000',
|
|
|
|
|
'--tw-shadow': '0 0 #0000',
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
matchUtilities(
|
|
|
|
|
{
|
2021-09-24 18:57:01 +02:00
|
|
|
ring: (value) => {
|
2021-09-09 15:22:50 +02:00
|
|
|
return {
|
2021-09-24 18:57:01 +02:00
|
|
|
'@defaults ring-width': {},
|
|
|
|
|
'--tw-ring-offset-shadow': `var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color)`,
|
|
|
|
|
'--tw-ring-shadow': `var(--tw-ring-inset) 0 0 0 calc(${value} + var(--tw-ring-offset-width)) var(--tw-ring-color)`,
|
|
|
|
|
'box-shadow': [
|
|
|
|
|
`var(--tw-ring-offset-shadow)`,
|
|
|
|
|
`var(--tw-ring-shadow)`,
|
|
|
|
|
`var(--tw-shadow, 0 0 #0000)`,
|
|
|
|
|
].join(', '),
|
2021-09-09 15:22:50 +02:00
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
},
|
2021-09-24 18:57:01 +02:00
|
|
|
{ values: theme('ringWidth'), type: 'length' }
|
2021-09-09 15:22:50 +02:00
|
|
|
)
|
|
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
addUtilities({
|
|
|
|
|
'.ring-inset': { '@defaults ring-width': {}, '--tw-ring-inset': 'inset' },
|
|
|
|
|
})
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
ringColor: ({ matchUtilities, theme }) => {
|
|
|
|
|
matchUtilities(
|
|
|
|
|
{
|
|
|
|
|
ring: (value) => {
|
|
|
|
|
return withAlphaVariable({
|
|
|
|
|
color: value,
|
|
|
|
|
property: '--tw-ring-color',
|
|
|
|
|
variable: '--tw-ring-opacity',
|
|
|
|
|
})
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
},
|
2021-09-24 18:57:01 +02:00
|
|
|
{
|
|
|
|
|
values: Object.fromEntries(
|
|
|
|
|
Object.entries(flattenColorPalette(theme('ringColor'))).filter(
|
|
|
|
|
([modifier]) => modifier !== 'DEFAULT'
|
|
|
|
|
)
|
|
|
|
|
),
|
|
|
|
|
type: 'color',
|
|
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
ringOpacity: createUtilityPlugin('ringOpacity', [['ring-opacity', ['--tw-ring-opacity']]], {
|
|
|
|
|
filterDefault: true,
|
|
|
|
|
}),
|
|
|
|
|
ringOffsetWidth: createUtilityPlugin(
|
|
|
|
|
'ringOffsetWidth',
|
|
|
|
|
[['ring-offset', ['--tw-ring-offset-width']]],
|
|
|
|
|
{ type: 'length' }
|
|
|
|
|
),
|
|
|
|
|
|
|
|
|
|
ringOffsetColor: ({ matchUtilities, theme }) => {
|
|
|
|
|
matchUtilities(
|
|
|
|
|
{
|
|
|
|
|
'ring-offset': (value) => {
|
|
|
|
|
return {
|
|
|
|
|
'--tw-ring-offset-color': toColorValue(value),
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
},
|
2021-09-24 18:57:01 +02:00
|
|
|
{ values: flattenColorPalette(theme('ringOffsetColor')), type: 'color' }
|
|
|
|
|
)
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
blur: ({ matchUtilities, theme }) => {
|
|
|
|
|
matchUtilities(
|
|
|
|
|
{
|
|
|
|
|
blur: (value) => {
|
|
|
|
|
return {
|
|
|
|
|
'--tw-blur': `blur(${value})`,
|
|
|
|
|
'@defaults filter': {},
|
|
|
|
|
filter: 'var(--tw-filter)',
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
},
|
2021-09-24 18:57:01 +02:00
|
|
|
{ values: theme('blur') }
|
|
|
|
|
)
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
brightness: ({ matchUtilities, theme }) => {
|
|
|
|
|
matchUtilities(
|
|
|
|
|
{
|
|
|
|
|
brightness: (value) => {
|
|
|
|
|
return {
|
|
|
|
|
'--tw-brightness': `brightness(${value})`,
|
|
|
|
|
'@defaults filter': {},
|
|
|
|
|
filter: 'var(--tw-filter)',
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
},
|
2021-09-24 18:57:01 +02:00
|
|
|
{ values: theme('brightness') }
|
|
|
|
|
)
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
contrast: ({ matchUtilities, theme }) => {
|
|
|
|
|
matchUtilities(
|
|
|
|
|
{
|
|
|
|
|
contrast: (value) => {
|
|
|
|
|
return {
|
|
|
|
|
'--tw-contrast': `contrast(${value})`,
|
|
|
|
|
'@defaults filter': {},
|
|
|
|
|
filter: 'var(--tw-filter)',
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
},
|
2021-09-24 18:57:01 +02:00
|
|
|
{ values: theme('contrast') }
|
|
|
|
|
)
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
dropShadow: ({ matchUtilities, theme }) => {
|
|
|
|
|
matchUtilities(
|
|
|
|
|
{
|
|
|
|
|
'drop-shadow': (value) => {
|
|
|
|
|
return {
|
|
|
|
|
'--tw-drop-shadow': Array.isArray(value)
|
|
|
|
|
? value.map((v) => `drop-shadow(${v})`).join(' ')
|
|
|
|
|
: `drop-shadow(${value})`,
|
|
|
|
|
'@defaults filter': {},
|
|
|
|
|
filter: 'var(--tw-filter)',
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
},
|
2021-09-24 18:57:01 +02:00
|
|
|
{ values: theme('dropShadow') }
|
|
|
|
|
)
|
|
|
|
|
},
|
Remove AOT (#5340)
* make `jit` mode the default when no mode is specified
* unify JIT and AOT codepaths
* ensure `Object.entries` on undefined doesn't break
It could be that sometimes you don't have values in your config (e.g.: `presets: []`), this in turn will break some plugins where we assume we have a value.
* drop AOT specific tests
These tests are all covered by JIT mode already and were AOT specific.
* simplify tests, and add a few
Some of the tests were written for AOT specifically, some were missing. We also updated the way we write those tests, essentially making Tailwind a blackbox, by testing against the final output.
Now that JIT mode is the default, this is super fast because we only generate what is used, instead of partially testing in a 3MB file or building it all, then purging.
* add some todo's to make sure we warn in a few cases
* make `darkMode: 'media'`, the default
This also includes moving dark mode tests to its own dedicated file.
* remove PostCSS 7 compat mode
* update CLI to be JIT-first
* fix integration tests
This is not a _real_ fix, but it does solve the broken test for now.
* warn when using @responsive or @variants
* remove the JIT preview warning
* remove AOT-only code paths
* remove all `mode: 'jit'` blocks
Also remove `variants: {}` since they are not useful in `JIT` mode
anymore.
* drop unused dependencies
* rename `purge` to `content`
* remove static CDN builds
* mark `--purge` as deprecated in the CLI
This will still work, but a warning will be printed and it won't show up
in the `--help` output.
* cleanup nesting plugin
We don't have to duplicate it anymore since there is no PostCSS 7
version anymore.
* make sure integration tests run in band
* cleanup folder structure
* make sure nesting folder is available
* simplify resolving of purge/content information
2021-09-01 17:13:59 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
grayscale: ({ matchUtilities, theme }) => {
|
|
|
|
|
matchUtilities(
|
|
|
|
|
{
|
|
|
|
|
grayscale: (value) => {
|
|
|
|
|
return {
|
|
|
|
|
'--tw-grayscale': `grayscale(${value})`,
|
|
|
|
|
'@defaults filter': {},
|
|
|
|
|
filter: 'var(--tw-filter)',
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
},
|
2021-09-24 18:57:01 +02:00
|
|
|
{ values: theme('grayscale') }
|
|
|
|
|
)
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
hueRotate: ({ matchUtilities, theme }) => {
|
|
|
|
|
matchUtilities(
|
|
|
|
|
{
|
|
|
|
|
'hue-rotate': (value) => {
|
|
|
|
|
return {
|
|
|
|
|
'--tw-hue-rotate': `hue-rotate(${value})`,
|
|
|
|
|
'@defaults filter': {},
|
|
|
|
|
filter: 'var(--tw-filter)',
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-09-09 18:10:04 +02:00
|
|
|
},
|
2021-10-06 13:42:05 -04:00
|
|
|
{ values: theme('hueRotate'), supportsNegativeValues: true }
|
2021-09-24 18:57:01 +02:00
|
|
|
)
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
invert: ({ matchUtilities, theme }) => {
|
|
|
|
|
matchUtilities(
|
|
|
|
|
{
|
|
|
|
|
invert: (value) => {
|
|
|
|
|
return {
|
|
|
|
|
'--tw-invert': `invert(${value})`,
|
|
|
|
|
'@defaults filter': {},
|
|
|
|
|
filter: 'var(--tw-filter)',
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
},
|
2021-09-24 18:57:01 +02:00
|
|
|
{ values: theme('invert') }
|
|
|
|
|
)
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
saturate: ({ matchUtilities, theme }) => {
|
|
|
|
|
matchUtilities(
|
|
|
|
|
{
|
|
|
|
|
saturate: (value) => {
|
|
|
|
|
return {
|
|
|
|
|
'--tw-saturate': `saturate(${value})`,
|
|
|
|
|
'@defaults filter': {},
|
|
|
|
|
filter: 'var(--tw-filter)',
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
},
|
2021-09-24 18:57:01 +02:00
|
|
|
{ values: theme('saturate') }
|
|
|
|
|
)
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
sepia: ({ matchUtilities, theme }) => {
|
|
|
|
|
matchUtilities(
|
|
|
|
|
{
|
|
|
|
|
sepia: (value) => {
|
|
|
|
|
return {
|
|
|
|
|
'--tw-sepia': `sepia(${value})`,
|
|
|
|
|
'@defaults filter': {},
|
|
|
|
|
filter: 'var(--tw-filter)',
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
},
|
2021-09-24 18:57:01 +02:00
|
|
|
{ values: theme('sepia') }
|
|
|
|
|
)
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
filter: ({ addBase, addUtilities }) => {
|
|
|
|
|
addBase({
|
|
|
|
|
'@defaults filter': {
|
|
|
|
|
'--tw-blur': 'var(--tw-empty,/*!*/ /*!*/)',
|
|
|
|
|
'--tw-brightness': 'var(--tw-empty,/*!*/ /*!*/)',
|
|
|
|
|
'--tw-contrast': 'var(--tw-empty,/*!*/ /*!*/)',
|
|
|
|
|
'--tw-grayscale': 'var(--tw-empty,/*!*/ /*!*/)',
|
|
|
|
|
'--tw-hue-rotate': 'var(--tw-empty,/*!*/ /*!*/)',
|
|
|
|
|
'--tw-invert': 'var(--tw-empty,/*!*/ /*!*/)',
|
|
|
|
|
'--tw-saturate': 'var(--tw-empty,/*!*/ /*!*/)',
|
|
|
|
|
'--tw-sepia': 'var(--tw-empty,/*!*/ /*!*/)',
|
|
|
|
|
'--tw-drop-shadow': 'var(--tw-empty,/*!*/ /*!*/)',
|
|
|
|
|
'--tw-filter': [
|
|
|
|
|
'var(--tw-blur)',
|
|
|
|
|
'var(--tw-brightness)',
|
|
|
|
|
'var(--tw-contrast)',
|
|
|
|
|
'var(--tw-grayscale)',
|
|
|
|
|
'var(--tw-hue-rotate)',
|
|
|
|
|
'var(--tw-invert)',
|
|
|
|
|
'var(--tw-saturate)',
|
|
|
|
|
'var(--tw-sepia)',
|
|
|
|
|
'var(--tw-drop-shadow)',
|
|
|
|
|
].join(' '),
|
2021-09-09 15:22:50 +02:00
|
|
|
},
|
2021-09-24 18:57:01 +02:00
|
|
|
})
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.filter': { '@defaults filter': {}, filter: 'var(--tw-filter)' },
|
|
|
|
|
'.filter-none': { filter: 'none' },
|
|
|
|
|
})
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
backdropBlur: ({ matchUtilities, theme }) => {
|
|
|
|
|
matchUtilities(
|
|
|
|
|
{
|
|
|
|
|
'backdrop-blur': (value) => {
|
|
|
|
|
return {
|
|
|
|
|
'--tw-backdrop-blur': `blur(${value})`,
|
|
|
|
|
'@defaults backdrop-filter': {},
|
|
|
|
|
'backdrop-filter': 'var(--tw-backdrop-filter)',
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
},
|
2021-09-24 18:57:01 +02:00
|
|
|
{ values: theme('backdropBlur') }
|
|
|
|
|
)
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
backdropBrightness: ({ matchUtilities, theme }) => {
|
|
|
|
|
matchUtilities(
|
|
|
|
|
{
|
|
|
|
|
'backdrop-brightness': (value) => {
|
|
|
|
|
return {
|
|
|
|
|
'--tw-backdrop-brightness': `brightness(${value})`,
|
|
|
|
|
'@defaults backdrop-filter': {},
|
|
|
|
|
'backdrop-filter': 'var(--tw-backdrop-filter)',
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
},
|
2021-09-24 18:57:01 +02:00
|
|
|
{ values: theme('backdropBrightness') }
|
|
|
|
|
)
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
backdropContrast: ({ matchUtilities, theme }) => {
|
|
|
|
|
matchUtilities(
|
|
|
|
|
{
|
|
|
|
|
'backdrop-contrast': (value) => {
|
|
|
|
|
return {
|
|
|
|
|
'--tw-backdrop-contrast': `contrast(${value})`,
|
|
|
|
|
'@defaults backdrop-filter': {},
|
|
|
|
|
'backdrop-filter': 'var(--tw-backdrop-filter)',
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
},
|
2021-09-24 18:57:01 +02:00
|
|
|
{ values: theme('backdropContrast') }
|
|
|
|
|
)
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
backdropGrayscale: ({ matchUtilities, theme }) => {
|
|
|
|
|
matchUtilities(
|
|
|
|
|
{
|
|
|
|
|
'backdrop-grayscale': (value) => {
|
|
|
|
|
return {
|
|
|
|
|
'--tw-backdrop-grayscale': `grayscale(${value})`,
|
|
|
|
|
'@defaults backdrop-filter': {},
|
|
|
|
|
'backdrop-filter': 'var(--tw-backdrop-filter)',
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
},
|
2021-09-24 18:57:01 +02:00
|
|
|
{ values: theme('backdropGrayscale') }
|
|
|
|
|
)
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
backdropHueRotate: ({ matchUtilities, theme }) => {
|
|
|
|
|
matchUtilities(
|
|
|
|
|
{
|
|
|
|
|
'backdrop-hue-rotate': (value) => {
|
|
|
|
|
return {
|
|
|
|
|
'--tw-backdrop-hue-rotate': `hue-rotate(${value})`,
|
|
|
|
|
'@defaults backdrop-filter': {},
|
|
|
|
|
'backdrop-filter': 'var(--tw-backdrop-filter)',
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
},
|
2021-10-06 13:42:05 -04:00
|
|
|
{ values: theme('backdropHueRotate'), supportsNegativeValues: true }
|
2021-09-24 18:57:01 +02:00
|
|
|
)
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
backdropInvert: ({ matchUtilities, theme }) => {
|
|
|
|
|
matchUtilities(
|
|
|
|
|
{
|
|
|
|
|
'backdrop-invert': (value) => {
|
|
|
|
|
return {
|
|
|
|
|
'--tw-backdrop-invert': `invert(${value})`,
|
|
|
|
|
'@defaults backdrop-filter': {},
|
|
|
|
|
'backdrop-filter': 'var(--tw-backdrop-filter)',
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
},
|
2021-09-24 18:57:01 +02:00
|
|
|
{ values: theme('backdropInvert') }
|
|
|
|
|
)
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
backdropOpacity: ({ matchUtilities, theme }) => {
|
|
|
|
|
matchUtilities(
|
|
|
|
|
{
|
|
|
|
|
'backdrop-opacity': (value) => {
|
|
|
|
|
return {
|
|
|
|
|
'--tw-backdrop-opacity': `opacity(${value})`,
|
|
|
|
|
'@defaults backdrop-filter': {},
|
|
|
|
|
'backdrop-filter': 'var(--tw-backdrop-filter)',
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
},
|
2021-09-24 18:57:01 +02:00
|
|
|
{ values: theme('backdropOpacity') }
|
|
|
|
|
)
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
backdropSaturate: ({ matchUtilities, theme }) => {
|
|
|
|
|
matchUtilities(
|
|
|
|
|
{
|
|
|
|
|
'backdrop-saturate': (value) => {
|
|
|
|
|
return {
|
|
|
|
|
'--tw-backdrop-saturate': `saturate(${value})`,
|
|
|
|
|
'@defaults backdrop-filter': {},
|
|
|
|
|
'backdrop-filter': 'var(--tw-backdrop-filter)',
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
},
|
2021-09-24 18:57:01 +02:00
|
|
|
{ values: theme('backdropSaturate') }
|
|
|
|
|
)
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
backdropSepia: ({ matchUtilities, theme }) => {
|
|
|
|
|
matchUtilities(
|
|
|
|
|
{
|
|
|
|
|
'backdrop-sepia': (value) => {
|
|
|
|
|
return {
|
|
|
|
|
'--tw-backdrop-sepia': `sepia(${value})`,
|
|
|
|
|
'@defaults backdrop-filter': {},
|
|
|
|
|
'backdrop-filter': 'var(--tw-backdrop-filter)',
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
},
|
2021-09-24 18:57:01 +02:00
|
|
|
{ values: theme('backdropSepia') }
|
|
|
|
|
)
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
backdropFilter: ({ addBase, addUtilities }) => {
|
|
|
|
|
addBase({
|
|
|
|
|
'@defaults backdrop-filter': {
|
|
|
|
|
'--tw-backdrop-blur': 'var(--tw-empty,/*!*/ /*!*/)',
|
|
|
|
|
'--tw-backdrop-brightness': 'var(--tw-empty,/*!*/ /*!*/)',
|
|
|
|
|
'--tw-backdrop-contrast': 'var(--tw-empty,/*!*/ /*!*/)',
|
|
|
|
|
'--tw-backdrop-grayscale': 'var(--tw-empty,/*!*/ /*!*/)',
|
|
|
|
|
'--tw-backdrop-hue-rotate': 'var(--tw-empty,/*!*/ /*!*/)',
|
|
|
|
|
'--tw-backdrop-invert': 'var(--tw-empty,/*!*/ /*!*/)',
|
|
|
|
|
'--tw-backdrop-opacity': 'var(--tw-empty,/*!*/ /*!*/)',
|
|
|
|
|
'--tw-backdrop-saturate': 'var(--tw-empty,/*!*/ /*!*/)',
|
|
|
|
|
'--tw-backdrop-sepia': 'var(--tw-empty,/*!*/ /*!*/)',
|
|
|
|
|
'--tw-backdrop-filter': [
|
|
|
|
|
'var(--tw-backdrop-blur)',
|
|
|
|
|
'var(--tw-backdrop-brightness)',
|
|
|
|
|
'var(--tw-backdrop-contrast)',
|
|
|
|
|
'var(--tw-backdrop-grayscale)',
|
|
|
|
|
'var(--tw-backdrop-hue-rotate)',
|
|
|
|
|
'var(--tw-backdrop-invert)',
|
|
|
|
|
'var(--tw-backdrop-opacity)',
|
|
|
|
|
'var(--tw-backdrop-saturate)',
|
|
|
|
|
'var(--tw-backdrop-sepia)',
|
|
|
|
|
].join(' '),
|
2021-09-09 15:22:50 +02:00
|
|
|
},
|
2021-09-24 18:57:01 +02:00
|
|
|
})
|
|
|
|
|
addUtilities({
|
|
|
|
|
'.backdrop-filter': {
|
|
|
|
|
'@defaults backdrop-filter': {},
|
|
|
|
|
'backdrop-filter': 'var(--tw-backdrop-filter)',
|
|
|
|
|
},
|
|
|
|
|
'.backdrop-filter-none': { 'backdrop-filter': 'none' },
|
|
|
|
|
})
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
transitionProperty: ({ matchUtilities, theme }) => {
|
|
|
|
|
let defaultTimingFunction = theme('transitionTimingFunction.DEFAULT')
|
|
|
|
|
let defaultDuration = theme('transitionDuration.DEFAULT')
|
2021-09-09 15:22:50 +02:00
|
|
|
|
2021-09-24 18:57:01 +02:00
|
|
|
matchUtilities(
|
|
|
|
|
{
|
|
|
|
|
transition: (value) => {
|
|
|
|
|
return {
|
|
|
|
|
'transition-property': value,
|
|
|
|
|
...(value === 'none'
|
|
|
|
|
? {}
|
|
|
|
|
: {
|
|
|
|
|
'transition-timing-function': defaultTimingFunction,
|
|
|
|
|
'transition-duration': defaultDuration,
|
|
|
|
|
}),
|
|
|
|
|
}
|
|
|
|
|
},
|
2021-09-09 15:22:50 +02:00
|
|
|
},
|
2021-09-24 18:57:01 +02:00
|
|
|
{ values: theme('transitionProperty') }
|
|
|
|
|
)
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
transitionDelay: createUtilityPlugin('transitionDelay', [['delay', ['transitionDelay']]]),
|
|
|
|
|
transitionDuration: createUtilityPlugin(
|
|
|
|
|
'transitionDuration',
|
|
|
|
|
[['duration', ['transitionDuration']]],
|
|
|
|
|
{ filterDefault: true }
|
|
|
|
|
),
|
|
|
|
|
transitionTimingFunction: createUtilityPlugin(
|
|
|
|
|
'transitionTimingFunction',
|
|
|
|
|
[['ease', ['transitionTimingFunction']]],
|
|
|
|
|
{ filterDefault: true }
|
|
|
|
|
),
|
|
|
|
|
willChange: createUtilityPlugin('willChange', [['will-change', ['will-change']]]),
|
2021-10-18 18:11:34 +02:00
|
|
|
content: createUtilityPlugin('content', [
|
|
|
|
|
['content', ['--tw-content', ['content', 'var(--tw-content)']]],
|
|
|
|
|
]),
|
2021-09-09 15:22:50 +02:00
|
|
|
}
|