Skip to content

Commit c2bfd60

Browse files
committed
add customization options
1 parent 9bb8a28 commit c2bfd60

File tree

1 file changed

+44
-21
lines changed

1 file changed

+44
-21
lines changed

src/index.js

Lines changed: 44 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,45 @@
1-
const plugin = require('tailwindcss/plugin')
1+
const plugin = require("tailwindcss/plugin");
22

3-
module.exports = plugin(function({ addUtilities, e }) {
4-
addUtilities({
5-
[`.${e('?')}`]: {
6-
'outline-style': 'solid',
7-
'animation': `${e('?')}wobble 0.6s ease-in-out alternate infinite`
8-
},
9-
[`@keyframes ${e('?')}wobble`]: {
10-
'0%': {
11-
'outline-width': '4px',
12-
'outline-color': '#f16bc9',
13-
'box-shadow': 'inset 4px 4px #f16bc9, inset -4px -4px #f16bc9'
14-
},
15-
'100%': {
16-
'outline-width': '6px',
17-
'outline-color': '#f71fb6',
18-
'box-shadow': 'inset 6px 6px #f71fb6, inset -6px -6px #f71fb6'
19-
},
20-
}
21-
});
22-
});
3+
module.exports = plugin.withOptions(
4+
({
5+
animationDuration = "0.6s",
6+
animationName = "wobble",
7+
boxShadowInsetStart = "4px",
8+
boxShadowInsetEnd = "6px",
9+
enableAnimation = true,
10+
highlightColor = "#f16bc9",
11+
outlineWidthStart = "4px",
12+
outlineWidthEnd = "6px",
13+
outlineStyle = "solid",
14+
} = {}) => {
15+
return function ({ addUtilities, e }) {
16+
const animation = enableAnimation
17+
? `${e(
18+
"?"
19+
)}${animationName} ${animationDuration} ease-in-out alternate infinite`
20+
: "none";
21+
22+
addUtilities({
23+
[`.${e("?")}`]: {
24+
"outline-style": outlineStyle,
25+
"outline-width": outlineWidthStart,
26+
"outline-color": highlightColor,
27+
"box-shadow": `inset ${boxShadowInsetStart} ${boxShadowInsetStart} ${highlightColor}, inset -${boxShadowInsetStart} -${boxShadowInsetStart} ${highlightColor}`,
28+
animation: animation,
29+
},
30+
[`@keyframes ${e("?")}${animationName}`]: {
31+
"0%": {
32+
"outline-width": outlineWidthStart,
33+
"outline-color": highlightColor,
34+
"box-shadow": `inset ${boxShadowInsetStart} ${boxShadowInsetStart} ${highlightColor}, inset -${boxShadowInsetStart} -${boxShadowInsetStart} ${highlightColor}`,
35+
},
36+
"100%": {
37+
"outline-width": outlineWidthEnd,
38+
"outline-color": highlightColor,
39+
"box-shadow": `inset ${boxShadowInsetEnd} ${boxShadowInsetEnd} ${highlightColor}, inset -${boxShadowInsetEnd} -${boxShadowInsetEnd} ${highlightColor}`,
40+
},
41+
},
42+
});
43+
};
44+
}
45+
);

0 commit comments

Comments
 (0)