Skip to content

Commit 6ebf5e9

Browse files
authored
Merge pull request #92 from tailwindlabs/color-modifiers
Add color modifiers
2 parents caa70b6 + 6f7feda commit 6ebf5e9

File tree

6 files changed

+2001
-379
lines changed

6 files changed

+2001
-379
lines changed

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,6 @@
4242
"react": "^16.8.6",
4343
"react-dom": "^16.8.6",
4444
"snapshot-diff": "^0.8.1",
45-
"tailwindcss": "^2.0.0-alpha.4"
45+
"tailwindcss": "^2.0.0-alpha.16"
4646
}
4747
}

Diff for: src/index.js

+19-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const merge = require('lodash/merge')
33
const castArray = require('lodash/castArray')
44
const uniq = require('lodash/uniq')
55
const styles = require('./styles')
6+
const { isUsableColor } = require('./utils')
67

78
const computed = {
89
// Reserved for future "magic properties", for example:
@@ -19,10 +20,22 @@ function configToCss(config = {}) {
1920
)
2021
}
2122

22-
const DEFAULT_MODIFIERS = ['DEFAULT', 'sm', 'lg', 'xl', '2xl']
2323
module.exports = plugin.withOptions(
24-
({ modifiers = DEFAULT_MODIFIERS, className = 'prose' } = {}) => {
24+
({ modifiers, className = 'prose' } = {}) => {
2525
return function ({ addComponents, theme, variants }) {
26+
const DEFAULT_MODIFIERS = [
27+
'DEFAULT',
28+
'sm',
29+
'lg',
30+
'xl',
31+
'2xl',
32+
...Object.entries(theme('colors'))
33+
.filter(([color, values]) => {
34+
return isUsableColor(color, values)
35+
})
36+
.map(([color]) => color),
37+
]
38+
modifiers = modifiers === undefined ? DEFAULT_MODIFIERS : modifiers
2639
const config = theme('typography')
2740

2841
const all = uniq([
@@ -41,5 +54,8 @@ module.exports = plugin.withOptions(
4154
)
4255
}
4356
},
44-
() => ({ theme: { typography: styles }, variants: { typography: ['responsive'] } })
57+
() => ({
58+
theme: { typography: styles },
59+
variants: { typography: ['responsive'] },
60+
})
4561
)

0 commit comments

Comments
 (0)