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

Allow variant plugins to tell Tailwind they should stack #2382

Merged
merged 4 commits into from
Sep 14, 2020

Conversation

adamwathan
Copy link
Member

@adamwathan adamwathan commented Sep 14, 2020

This PR makes it possible for variants to tell Tailwind they should "stack" using a new unstable_stack option, passed in through an options object to the addVariant function exposed through the plugin API:

tailwind.plugin(function({ addVariant }) {
  addVariant('motion-safe', ({ modifySelectors }) => {
    // ...
  }, { unstable_stack: true })
})

This ensures that if a user overrides a default variant by registering their own variant with the same name, that the user's variant does not automatically inherit the hard-coded stacking behavior of the built-in variant.

Marking it as unstable for now as I'm not sure this is going to be the best approach to a public stacking API going forward but it's fine for our internal use and solves the problem.

Resolves #2378.

JNavith and others added 4 commits September 14, 2020 08:37
…ant (#2380)

* Add failing tests for non-darkModeVariant "dark" variant stacking behavior

* Fix unwanted non-darkModeVariant "dark" variant stacking (by making the failing test pass)
@adamwathan adamwathan merged commit 32eac19 into master Sep 14, 2020
@adamwathan adamwathan deleted the override-variant-stacking branch September 14, 2020 13:12
adamwathan added a commit that referenced this pull request Sep 28, 2020
* Fix unwanted stacking behavior on any non-darkModeVariant "dark" variant (#2380)

* Add failing tests for non-darkModeVariant "dark" variant stacking behavior

* Fix unwanted non-darkModeVariant "dark" variant stacking (by making the failing test pass)

* Add unstable_stack option for variants to tell Tailwind they should stack

* Update eslint to allow unstable_ variables

* Update changelog

Co-authored-by: Navith <[email protected]>
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.

Unwanted stacking behavior on any variant named "dark" since 1.8 even if not the experimental darkModeVariant
2 participants