Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix variants not working #7

Merged
merged 3 commits into from
Sep 13, 2019
Merged

Conversation

mauriciv
Copy link
Contributor

I noticed that variants weren't working, so I made a few changes and now they work.

  1. Since tailwind can't generate variants for @Keyframe rules, we extract those utilities to a second call to addUtilities.
  2. According to the README, the way to specify which variants to generate is passing an array as a 'variants' element on the passed object, so we don't need to call the variants() function that tailwind provides.
  3. Finally, we accept only one object argument, that has the settings and variants, instead of two arguments. This is mostly done to avoid modifications to the README and to avoid breaking changes. Before, if you used the plugin as is indicated in the README, the variants element in the object would be ignored, and only the default ['responsive'] argument would be used, but that one was also ignored, because of shadowing by the destructured variant helper function by tailwind

We can't add variants to @Keyframe selectors, because tailwind will complain
'Variant cannot be generated because selector contains no classes', so we need to
make two calls to addUtilities.
We don't actually need to call variants() inside our returned function,
because that looks up the variants element in the main tailwind config object,
and according to the README, the way to use this lib is to pass the variants directly.

Besides, the destructured variants was shadowing the 'variants' array passed in by
the user, so it was never used.
In trying to keep the README unmodified, we accept the passed in
options object and destructure it.
Before, the variants were passed in as part of the object, but they
were ignored, because in the function signature the 'variants' argument
was outside of the (now destructured) object.
@bentzibentz bentzibentz merged commit 6da7daa into bentzibentz:master Sep 13, 2019
@bentzibentz
Copy link
Owner

Nice, big thank for your contribution :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants