Skip to content

Commit 041e5b2

Browse files
committed
🔨 Fix invalid source, update docs
1 parent d0dee4c commit 041e5b2

File tree

2 files changed

+24
-14
lines changed

2 files changed

+24
-14
lines changed

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,18 @@ module.exports = {
2828
require("tailwindcss-text-fill"),
2929
// Other plugins.
3030
],
31+
variants: {
32+
extend: {
33+
textFill: ["dark"], // Enable variants.
34+
},
35+
},
3136
};
3237
```
3338

3439
Style your components `text-fill-{color}`, e.g. `text-fill-gray-100`, `text-fill-gray-200`, `text-fill-red-500`, etc.
3540

3641
```jsx
37-
<input className="text-fill-gray-100" />
42+
<input className="text-fill-gray-900 dark:text-fill-gray-100" />
3843
```
3944

4045
## Requirements

index.js

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,21 @@
11
const plugin = require("tailwindcss/plugin");
2+
const flatten = require("flatten-tailwindcss-theme");
23

3-
const autofill = plugin(({ addVariant, e }) => {
4-
addVariant("autofill", ({ modifySelectors, separator }) => {
5-
modifySelectors(({ className }) => {
6-
const newClass = e(`autofill${separator}${className}`);
7-
return [
8-
`.${newClass}:-webkit-autofill`,
9-
`.${newClass}:-webkit-autofill:hover`,
10-
`.${newClass}:-webkit-autofill:focus`,
11-
].join(",");
12-
});
13-
});
14-
});
4+
const textFill = plugin(
5+
({ addUtilities, variants, theme, e }) => {
6+
const colors = flatten(theme("colors"));
7+
const utils = Object.entries(colors).reduce(
8+
(res, [key, value]) =>
9+
Object.assign(res, {
10+
[`.${e(`text-fill-${key}`)}`]: {
11+
"-webkit-text-fill-color": value,
12+
},
13+
}),
14+
{}
15+
);
16+
addUtilities(utils, variants("textFill"));
17+
},
18+
{ variants: { textFill: [] } }
19+
);
1520

16-
module.exports = autofill;
21+
module.exports = textFill;

0 commit comments

Comments
 (0)