-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtailwind.config.js
More file actions
47 lines (43 loc) · 1.18 KB
/
tailwind.config.js
File metadata and controls
47 lines (43 loc) · 1.18 KB
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
const defaultTheme = require("tailwindcss/defaultTheme");
const remRegex = /(\d*\.?\d+)rem$/;
function rem2px(input, fontSize = 16) {
if (input == null) {
return input;
}
switch (typeof input) {
case "object": {
if (Array.isArray(input)) {
return input.map((val) => rem2px(val, fontSize));
}
const ret = {};
for (const key in input) {
if (Object.hasOwn(input, key)) {
ret[key] = rem2px(input[key], fontSize);
}
}
return ret;
}
case "string":
return input.replace(
remRegex,
(_, val) => `${Number.parseFloat(val) * fontSize}px`,
);
default:
return input;
}
}
module.exports = {
content: ["./src/**/*.{ts,tsx}"],
theme: {
borderRadius: rem2px(defaultTheme.borderRadius),
spacing: rem2px(defaultTheme.spacing),
fontSize: rem2px(defaultTheme.fontSize),
padding: rem2px(defaultTheme.padding),
margin: rem2px(defaultTheme.margin),
width: rem2px(defaultTheme.width),
height: rem2px(defaultTheme.height),
maxWidth: rem2px(defaultTheme.maxWidth),
maxHeight: rem2px(defaultTheme.maxHeight),
minWidth: rem2px(defaultTheme.minWidth),
},
};