-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
51 lines (49 loc) · 1.49 KB
/
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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
const plugin = require('tailwindcss/plugin')
const semanticColors = plugin(
function ({ addUtilities, theme, variants, e }) {
const values = theme('semanticColors')
addUtilities(
[
Object.entries(values).map(([key, value]) => {
return {
[`.${e(`${key}`)}`]: {
backgroundColor: `${value.light.bg}`,
color: `${value.light.txt}`,
},
[`.txt-${e(`${key}`)}`]: {
color: `${value.light.bg}`,
},
[`.block-${e(`${key}`)}`]: {
backgroundColor: `${value.light.bg}`,
},
[`.bord-${e(`${key}`)}`]: {
borderColor: `${value.light.bg}`,
},
'.dark': {
[`& .${e(`${key}`)}`]: {
backgroundColor: `${value.dark.bg}`,
color: `${value.dark.txt}`,
},
[`& .txt-${e(`${key}`)}`]: {
color: `${value.dark.bg}`,
},
[`& .block-${e(`${key}`)}`]: {
backgroundColor: `${value.dark.bg}`,
},
[`& .bord-${e(`${key}`)}`]: {
borderColor: `${value.dark.bg}`,
},
},
}
}),
],
variants('semanticColors')
)
},
{
variants: {
semanticColors: ['hover', 'dark', 'responsive', 'active', 'focus', 'required', 'invalid', 'disabled', 'file', 'marker', 'selection'],
},
}
)
module.exports = semanticColors