148 Commits

Author SHA1 Message Date
Adam Wathan
b91f0ef628 Ignore values not parseable by reduce-css-calc 2019-08-09 16:10:41 -04:00
Adam Wathan
763ee71033 Ensure all selectors in a rule receive important scope 2019-08-06 08:14:16 -04:00
Adam Wathan
19c74b106a Merge branch 'add-prefix-selector-support' of git://github.com/pxwee5/tailwindcss into pxwee5-add-prefix-selector-support 2019-08-06 07:56:34 -04:00
Adam Wathan
5da23984a5
Merge pull request #992 from AlexVipond/prefixNegativeModifiers_for_boxShadow_and_letterSpacing_and_lineHeight
Support negative prefix syntax for boxShadow and letterSpacing
2019-08-06 07:54:19 -04:00
Adam Wathan
25b3aba7d7 Use reduce-css-calc to avoid inspecting value to negate 2019-08-06 07:42:38 -04:00
Ari Seyhun
d3675ebd23 Add support for negative calc values 2019-08-01 13:32:10 +09:30
Ari Seyhun
c3075d97fe Add support for negative css custom properties 2019-08-01 12:57:46 +09:30
Adam Wathan
660ea44db2 Don't mutate nested rules when generating variants 2019-07-28 10:46:59 -04:00
ecrmnn
66e75b89ab Replaces use of Lodash isArray with built-in Array.isArray 2019-07-13 16:52:07 +02:00
James Wee
382075731d Added Prefix Selector support via important config 2019-07-11 17:07:24 +12:00
AlexVipond
a249bc4433 Handle default keyword for negative prefix syntax. Write tests for negative prefix syntax 2019-06-28 10:11:47 -06:00
AlexVipond
fd203a8906 support negative prefix for box shadow and letter spacing 2019-06-27 19:44:38 -06:00
Adam Wathan
5e7c263e0a Add test, fix style 2019-05-27 08:05:51 +02:00
Benoît Rouleau
6ce2cfe349 Bubble @screen at-rules when adding styles through plugins 2019-05-26 21:40:23 -04:00
Adam Wathan
0183b86b45 Fix global variants not working when configs are merged 2019-05-13 12:44:19 -04:00
Jarek Radosz
23b720bb31 Allow accessing deep paths with function values via theme helper
Example:

```js
theme: {
  spacing: {
    '0': '0',
  },
  width: theme => ({
    ...theme('spacing'),
    '1/3': '33.33333%',
  }),
  minWidth: theme => ({
    '1/3': theme('width.1/3'),
  }),
}
```
2019-05-08 22:11:10 +02:00
Adam Wathan
aac25d6a7a Fix bug where config utils was not passed through to nested closures 2019-04-27 16:55:21 -04:00
Adam Wathan
0735e3d27e Remove 'className' from plugin API
Certain plugins behave differently and the rules about `default` meaning "no suffix" are not universal (see the cursor plugin). The simplest thing to do right now is keep things as they are, which means only certain plugins respect the default option and only certain other plugins respect the negative prefix convention.
2019-04-26 08:19:23 -04:00
Adam Wathan
8fb2351463 Make second parameter to className optional 2019-04-25 07:59:47 -04:00
Adam Wathan
c6ae957aff Support negative values for inset 2019-04-24 16:37:13 -04:00
Adam Wathan
e8b64fdb62 Move negative margin logic into a helper
Adds a new `utils` bucket that's passed as a second arg when using a closure for theme values. The idea is you can destructure useful helper functions out of this argument, in this case a `negative` function that converts a positive scale to negative values. That's the only helper function right now, but making it a destructurable arg so we can add more if necessary without adding a bunch of positional arguments.
2019-04-24 15:15:30 -04:00
Michaël De Boey
d4b2b8b755
Make theme config directly accessible in the plugins 2019-04-18 23:29:07 +02:00
Adam Wathan
0e0ab3ab7a Make it possible to whitelist core plugins by passing an array 2019-04-18 10:31:14 -04:00
Adam Wathan
f0bc35a896 Support configuring a single list of variants to apply to all relevant plugins 2019-04-18 09:42:21 -04:00
Adam Wathan
27cef23a2c Support disabling all corePlugins with corePlugins: false 2019-04-17 08:15:37 -04:00
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