-
Notifications
You must be signed in to change notification settings - Fork 0
/
tailwind.config.cjs
58 lines (51 loc) · 1.4 KB
/
tailwind.config.cjs
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
52
53
54
55
56
57
58
const plugin = require('tailwindcss/plugin')
/** @type {import('tailwindcss').Config} */
module.exports = {
content: ['./src/**/*.{js,ts,jsx,tsx}'],
darkMode: 'class',
theme: {
extend: {
primary: [],
},
},
plugins: [
require('tailwindcss-logical'),
require('@tailwindcss/forms'),
require('@tailwindcss/container-queries'),
plugin(({ addVariant }) => {
addVariant('em', ({ container }) => {
container.walkRules(rule => {
rule.selector = `.em\\:${rule.selector.slice(1)}`
rule.walkDecls(decl => {
decl.value = decl.value.replace('rem', 'em')
})
})
})
}),
plugin(({ matchVariant }) => {
matchVariant('supports', value => `@supports(${value})`)
}),
plugin(({ addBase, theme }) => {
function extractColorVars(colorObj, colorGroup = '') {
return Object.keys(colorObj).reduce((vars, colorKey) => {
const value = colorObj[colorKey]
if (typeof value !== 'string') {
return { ...vars, ...extractColorVars(value, `-${colorKey}`) }
}
const key = `--color${colorGroup}-${colorKey}`
if (!/^#.{6}$/.test(value)) {
return { ...vars, [key]: value }
}
const color = value
.match(/(?<=#.*).{2}/g)
.map(byte => parseInt(byte, 16))
.join(' ')
return { ...vars, [key]: `rgb(${color} / var(--color-opacity, 1))` }
}, {})
}
addBase({
':root': extractColorVars(theme('colors')),
})
}),
],
}