-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
23 lines (23 loc) · 807 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
module.exports = function colorVars({ colors, strategy = 'override', colorTransform } = {}) {
return function tailwindColorVarsPlugin({ addUtilities, addComponents, e, prefix, config }) {
if (colors && typeof colors === 'object') {
if (strategy === 'override') {
colors = Object.assign({}, config('colors'), colors)
} else if (strategy === 'replace') {
//colors = colors
} else if (strategy === 'extend') {
colors = Object.assign({}, colors, config('colors'))
}
} else {
colors = config('colors')
}
let names = Object.keys(colors)
let root = {}, css = {
':root': root,
}
names.forEach(col => {
root[`--${e(col)}`] = colorTransform ? colorTransform(colors[col]) : colors[col]
})
addComponents(css)
}
}