-
-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathtailwind.config.cjs
64 lines (55 loc) · 1.72 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
59
60
61
62
63
64
const toRgba = (hexCode, opacity = 50) => {
let hex = hexCode.replace('#', '');
if (hex.length === 3) {
hex = `${hex[0]}${hex[0]}${hex[1]}${hex[1]}${hex[2]}${hex[2]}`;
}
const r = parseInt(hex.substring(0, 2), 16);
const g = parseInt(hex.substring(2, 4), 16);
const b = parseInt(hex.substring(4, 6), 16);
return `rgba(${r},${g},${b},${opacity / 100})`;
};
const flattenColorPalette = (obj, sep='-') => Object.assign(
{},
...function _flatten(o, p='') {
return [].concat(...Object.keys(o)
.map(k =>
typeof o[k] === 'object' ?
_flatten(o[k],k+sep) :
({[p+k]: o[k]})
)
);
}(obj)
);
module.exports = {
mode: 'jit',
content: ['./resources/**/*{js,vue,blade.php,ts}'],
darkMode: 'class',
important: '.nova-file-manager',
plugins: [
function ({ addUtilities, theme }) {
const utilities = {
'.bg-stripes': {
backgroundImage:
'linear-gradient(135deg, var(--stripes-color) 12.50%, transparent 12.50%, transparent 50%, var(--stripes-color) 50%, var(--stripes-color) 62.50%, transparent 62.50%, transparent 100%)',
backgroundSize: '7.07px 7.07px',
},
}
const addColor = (name, color) =>
(utilities[`.bg-stripes-${name}`] = { '--stripes-color': color })
const colors = flattenColorPalette(theme('backgroundColor'))
for (let name in colors) {
try {
const [r, g, b, a] = toRgba(colors[name])
if (a !== undefined) {
addColor(name, colors[name])
} else {
addColor(name, `rgba(${r}, ${g}, ${b}, 0.4)`)
}
} catch (_) {
addColor(name, colors[name])
}
}
addUtilities(utilities)
},
],
}