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.
This commit is contained in:
parent
51e60071cf
commit
e99753bc33
3 changed files with 10 additions and 190 deletions
|
|
@ -61,25 +61,10 @@ import whitespace from './plugins/whitespace'
|
|||
import width from './plugins/width'
|
||||
import zIndex from './plugins/zIndex'
|
||||
|
||||
import _ from 'lodash'
|
||||
import configurePlugins from './util/configurePlugins'
|
||||
|
||||
function loadPlugins({ theme, variants, corePlugins }, plugins) {
|
||||
const defaultCorePluginConfig = _.fromPairs(
|
||||
Object.keys(plugins).map(plugin => [
|
||||
plugin,
|
||||
{
|
||||
values: theme[plugin],
|
||||
variants: variants[plugin],
|
||||
},
|
||||
])
|
||||
)
|
||||
|
||||
return configurePlugins(plugins, corePlugins, defaultCorePluginConfig)
|
||||
}
|
||||
|
||||
export default function(config) {
|
||||
return loadPlugins(config, {
|
||||
export default function({ corePlugins: corePluginConfig }) {
|
||||
return configurePlugins(corePluginConfig, {
|
||||
preflight,
|
||||
listStyle,
|
||||
appearance,
|
||||
|
|
|
|||
|
|
@ -1,11 +1,9 @@
|
|||
import _ from 'lodash'
|
||||
|
||||
export default function(plugins, pluginConfig, defaultPluginConfig = {}) {
|
||||
export default function(pluginConfig, plugins) {
|
||||
return Object.keys(plugins)
|
||||
.filter(pluginName => {
|
||||
return pluginConfig[pluginName] !== false
|
||||
})
|
||||
.map(pluginName => {
|
||||
return plugins[pluginName](_.get(pluginConfig, pluginName, defaultPluginConfig[pluginName]))
|
||||
return plugins[pluginName]()
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue