irongit
38 lines869 BJavaScript
1import { text } from "stream/consumers";
2import plugin from "tailwindcss/plugin";
3
4function textShadow(value: string) {
5 if (!value || value === "none") {
6 return "none";
7 }
8 return `${value} ${value} 0 #000, -${value} -${value} 0 #000, ${value} -${value} 0 #000, -${value} ${value} 0 #000, ${value} 0 0 #000, -${value} 0 0 #000, 0 ${value} 0 #000, 0 -${value} 0 #000`;
9}
10
11const textShadowPlugin = plugin(
12 function ({ matchUtilities, theme }) {
13 matchUtilities(
14 {
15 "text-shadow": (value: string) => ({
16 textShadow: textShadow(value),
17 }),
18 },
19 {
20 values: theme("textShadow"),
21 }
22 );
23 },
24 {
25 theme: {
26 textShadow: {
27 DEFAULT: "1px",
28 none: "none",
29 sm: "2px",
30 md: "3px",
31 lg: "4px",
32 xl: "5px",
33 },
34 },
35 }
36);
37
38export default textShadowPlugin;