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

Support defining presets as functions #2680

Merged
merged 1 commit into from
Oct 26, 2020
Merged

Support defining presets as functions #2680

merged 1 commit into from
Oct 26, 2020

Conversation

RobinMalfait
Copy link
Member

@RobinMalfait RobinMalfait commented Oct 26, 2020

Description by @adamwathan


This PR adds support for defining presets as functions in case users need to accept options in their presets. We don't actually provide anything to these functions, we just notice if you've given us a function and invoke it with no arguments on your behalf. This lets your preset be used like this:

module.exports = {
  // ...
  presets: [
    // Require it with no options
    require('@acmecorp/tailwind-base'),

    // Invoke it and pass options to your own options API
    require('@acmecorp/tailwind-base')({
      colorPalette: 'legacy',
    })
  ]
}

We need this internally for the Tailwind UI plugin which we're currently converting to a preset for Tailwind 2.0.

@codecov-io
Copy link

codecov-io commented Oct 26, 2020

Codecov Report

Merging #2680 into master will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2680   +/-   ##
=======================================
  Coverage   92.99%   92.99%           
=======================================
  Files         172      172           
  Lines        1727     1727           
  Branches      304      305    +1     
=======================================
  Hits         1606     1606           
  Misses        104      104           
  Partials       17       17           
Impacted Files Coverage Δ
src/util/getAllConfigs.js 75.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3c9c46c...4a8439c. Read the comment docs.

@adamwathan adamwathan changed the title presets can be functions Support defining presets as functions Oct 26, 2020
@adamwathan adamwathan merged commit 9e3700c into master Oct 26, 2020
@adamwathan adamwathan deleted the function-presets branch October 26, 2020 13:43
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.

3 participants