forked from techniq/svelte-ux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tailwind.config.cjs
41 lines (36 loc) · 1.09 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
const colors = require('tailwindcss/colors');
const plugin = require('tailwindcss/plugin');
module.exports = {
content: ['./src/**/*.{html,svelte,md,ts}'],
theme: {
extend: {
colors: {
'color-var': 'var(--color)',
accent: colors.blue,
},
},
},
variants: {
extend: {},
},
plugins: [
require('./src/lib/plugins/tailwind.cjs'),
require('@tailwindcss/typography'),
// Expose color palette as CSS variables (--color-xxx-yyy) - https://gist.github.com/Merott/d2a19b32db07565e94f10d13d11a8574
plugin(function ({ addBase, theme }) {
function extractColorVars(colorObj, colorGroup = '') {
return Object.keys(colorObj).reduce((vars, colorKey) => {
const value = colorObj[colorKey];
const newVars =
typeof value === 'string'
? { [`--color${colorGroup}-${colorKey}`]: value }
: extractColorVars(value, `-${colorKey}`);
return { ...vars, ...newVars };
}, {});
}
addBase({
':root': extractColorVars(theme('colors')),
});
}),
],
};