-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.ts
53 lines (48 loc) · 1.74 KB
/
index.ts
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
const plugin = require('tailwindcss/plugin');
// Inline SVGs as Base64 encoded strings
const svgMask1x = `data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='150' height='150' viewBox='0 0 150 150'%3E%3Crect width='150' height='150' rx='50' fill='black'/%3E%3C/svg%3E`;
const svgMask2x = `data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300' viewBox='0 0 150 150'%3E%3Crect width='150' height='150' rx='50' fill='black'/%3E%3C/svg%3E`;
const svgMask3x = `data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='450' height='450' viewBox='0 0 150 150'%3E%3Crect width='150' height='150' rx='50' fill='black'/%3E%3C/svg%3E`;
module.exports = plugin(
function ({ addUtilities, theme }) {
const options = theme('cornerSmoothing') || {};
const sizes = options.sizes || {
sm: '25px',
md: '60px',
lg: '75px',
};
const utilities = {};
Object.entries(sizes).forEach(([key, size]) => {
utilities[`.smooth-corners-${key}`] = {
'@supports (mask-border-width: 60px)': {
'mask-border': `url("${
options.maskPath ?? svgMask1x
}") 49% fill / ${size}`,
'@media (min-resolution: 2x)': {
'mask-border': `url("${
options.maskPath ?? svgMask2x
}") 49% fill / ${size}`,
},
'@media (min-resolution: 3x)': {
'mask-border': `url("${
options.maskPath ?? svgMask3x
}") 49% fill / ${size}`,
},
},
};
});
addUtilities(utilities);
},
{
theme: {
cornerSmoothing: {
maskPath: svgMask1x,
sizes: {
sm: '25px',
md: '60px',
lg: '75px',
},
},
},
}
);