Commit graph

123 commits

Author SHA1 Message Date
Brad Cornes
caa687a59b account for function values in theme function 2019-03-24 20:10:15 +00:00
Adam Wathan
f5e8c74639 Don't mutate variants in user's config 2019-03-22 13:13:39 -04:00
Adam Wathan
7e1113561a Don't mutate the user's config when resolving 2019-03-22 12:47:21 -04:00
Adam Wathan
aee1e44431 Fix code style 2019-03-18 11:42:56 -04:00
Adam Wathan
509b698bfc Simplify resolveConfig slightly, try to catch more in tests 2019-03-18 11:21:32 -04:00
Jarek Radosz
62972a7693 Lazily evaluate values in the extend section
In a way this combines PRs #655 and #774.
2019-03-17 05:31:35 +01:00
Adam Wathan
fcd0f364db Pass theme to closures as function instead of object 2019-03-16 16:22:31 -04:00
Adam Wathan
da4984e0e1 Support default key in color objects 2019-03-05 11:36:31 -05:00
Adam Wathan
9b07984144 Support nested object for borderColor plugin 2019-03-04 13:10:34 -05:00
Adam Wathan
e99753bc33 Update plugins to source their config themselves
Instead of plugins being configured directly, they grab their configuration from the Tailwind config passed to them. This makes core plugins consistent with how we will recommend third-party plugins be authored so that the configuration for everything in the system is readable through the theme.
2019-02-28 14:53:55 -05:00
Adam Wathan
007231fbfc Require plugin authors to manually escape variants
Not 100% convinced this is a net positive change, but I regret not having done things this way at the beginning.

In 0.x, we pass the `separator` and `className` values already escaped, so `:` comes through as `\:` for example, and `w-1/2` comes through as `w-1\/2`.

At first this sounds fine, less work for the plugin author right? But CSS escaping rules are kind of complicated and you have to escape characters differently depending on whether or not they are at the start of an identifier.

For example, it's totally fine for a class to contain a zero (`0` ), but it can't _start_ with a zero. For a class to start with a zero, it needs to be escaped like this: `\30 `

This means that as a general rule, trying to escape the individual segments of a class separately is a bad idea — you should escape the class as a whole so only the necessary escaping is applied. We break this rule when we pre-escape the separator and className for plugin authors who use the `modifySelectors` function.

We already require users to manually escape class names when they are using `addUtilities` or `addComponents`, so to me it feels more consistent for things to work this way and it's how they should have worked from day one.

Basically this code:

```js
function({ addVariant }) {
  addVariant('first-child', ({ modifySelectors, separator }) => {
    modifySelectors(({ className }) => {
      return `.first-child${separator}${className}:first-child`
    })
  })
},
```

...would need to be re-written like this if I merge this change:

```js
function({ addVariant, e }) {
  addVariant('first-child', ({ modifySelectors, separator }) => {
    modifySelectors(({ className }) => {
      return `.${e(`first-child${separator}${className}`)}:first-child`
    })
  })
},
```

Although I think this is the right way for this to work, I hesitate because it's a breaking change that makes any variant plugins authored for 0.x incompatible with 1.x. It's an easy fix on the plugin author's part, but it's still annoying.

I'm leaning towards merging so I don't regret this even more later when the plugin ecosystem is a lot bigger. Anyone have any thoughts?
2019-02-28 10:17:09 -05:00
Adam Wathan
5e935c10f7 Remove dependency on cssesc
Makes it easier to guarantee that our escape behavior stays in line with postcss-selector-parser if their internal implementation ever changes.
2019-02-27 16:40:19 -05:00
Adam Wathan
2f79cab8fa Switch from css.escape to cssesc
This is what postcss-selector-parser uses internally, best to rely on the same escaping logic everywhere.
2019-02-27 13:53:28 -05:00
Adam Wathan
b8f1078229 Use postcss-selector-parser class escape handling 2019-02-27 13:43:26 -05:00
Adam Wathan
db7f1e6728 Merge branch 'master' into next 2019-02-22 10:05:31 -05:00
Adam Wathan
10aa36533f Pass postcss to plugins explicitly 2019-02-22 09:50:36 -05:00
Adam Wathan
4754d225af Remove need for without function 2019-02-14 07:47:32 -05:00
Adam Wathan
d95d28eec8 Fix code style 2019-02-13 14:25:37 -05:00
Adam Wathan
2342d72c5e Use existing parameter 2019-02-13 14:22:45 -05:00
Adam Wathan
8ff2b59096 Add first class support for extending the default theme 2019-02-13 13:07:41 -05:00
Adam Wathan
76c40e4394 Fix style 2019-02-07 15:13:17 -05:00
Adam Wathan
1d0b4cd31c Test plugins can add base styles with object syntax 2019-02-07 14:05:00 -05:00
Adam Wathan
04e1274e86 Rename mergeConfig to resolveConfig
Accept configs to resolve as an array to allow reuse when only resolving from a single config, update processTailwindFeatures to use resolveConfig even when no config is provided, update defaultTheme to self-reference colors.
2019-02-05 20:36:54 -05:00
Adam Wathan
40413690a2 Add support for lazy values in theme 2019-02-05 20:18:19 -05:00
Adam Wathan
4afb9e45e6 Test core plugins fall back to a default config 2019-02-05 10:58:56 -05:00
Adam Wathan
c84b188626 Fix code style 2019-02-05 10:54:35 -05:00
Adam Wathan
ed20e59ba1 Test that setting a plugin to false in corePlugins disables it 2019-02-05 10:41:33 -05:00
Adam Wathan
083ab97e12 Fix code style 2019-02-01 12:32:50 -05:00
Adam Wathan
ffdc2b01c5 Intelligently deep merge user's config 2019-02-01 12:32:50 -05:00
Adam Wathan
f10f1825ef Remove special "modules" merge behavior
Modules key no longer actually exists in the config so this is pointless.
2019-02-01 12:32:50 -05:00
Adam Wathan
326f35a72a Remove options key from config 2019-02-01 12:32:50 -05:00
Adam Wathan
e8d16fcdb5 Move separator to top level config option 2019-02-01 12:32:50 -05:00
Adam Wathan
1a46f6b47d Move important to top level option 2019-02-01 12:32:50 -05:00
Adam Wathan
664f923312 Move prefix option to top-level in config 2019-02-01 12:32:16 -05:00
Adam Wathan
ffae87148d Revert "Allow plugins to register new config variables" 2019-02-01 12:32:04 -05:00
Adam Wathan
5ea8bbe798 Allow plugins to register new config variables 2019-02-01 12:32:04 -05:00
Adam Wathan
057b4ea767 More dead code discovered and deleted 2019-01-14 15:43:12 -05:00
Adam Wathan
b948c25499 Delete possibly last remnants of dead code 2019-01-14 15:43:12 -05:00
Adam Wathan
fe1b30b2d2 Remove prefixTree, update relevant tests 2019-01-14 15:43:12 -05:00
Adam Wathan
ca524ef7c2 Remove more dead code 2019-01-14 15:43:12 -05:00
Adam Wathan
6352843cde Port zIndex module to default plugin 2019-01-14 15:43:12 -05:00
Adam Wathan
146b984617 Accept plugins as separate processPlugins arg 2019-01-14 15:43:12 -05:00
Adam Wathan
cc9c91a60a Delete unused variant modules 2019-01-14 15:39:51 -05:00
Adam Wathan
2b5358d92a Update prefixSelector for latest selector parser 2019-01-14 14:45:01 -05:00
Adam Wathan
e1d276468b Get tests passing with updated dependencies
Latest postcss-selector-parser tries to be more intelligent about handling escape sequences for you. This is awesome! But our original code was handling escaping ourselves, so this change gets the tests passing for now, with the intent to stop doing escaping ourselves in the near future and instead rely on postcss-selector-parser to handle it for us, since I'm positive their implementation is significantly more robust.
2019-01-14 14:45:01 -05:00
Adam Wathan
76691a563d Allow modules: [...variants] syntax to bulk apply variants 2018-11-01 21:33:42 -04:00
Adam Wathan
655963a100 Apply all first-class variants using modules: all 2018-11-01 20:30:48 -04:00
SpiltCoffee
38ac38cf99 Fixed linting error 2018-09-15 13:07:29 +10:00
SpiltCoffee
002a4ba90d Changed Variant Generation to apply per selector in a ruleset (fixes #530) 2018-09-15 11:38:58 +10:00
Adam Wathan
1a9b87f085 Fix style 2018-07-12 11:02:13 -04:00