|
| 1 | +const plugin = require("tailwindcss/plugin"); |
| 2 | + |
| 3 | +module.exports = plugin(function ({ addUtilities, addComponents }) { |
| 4 | + addUtilities({ |
| 5 | + '@keyframes text-shimmer': { |
| 6 | + '0%': { 'background-position': '150% 0' }, |
| 7 | + '100%': { 'background-position': '-250% 0' }, |
| 8 | + }, |
| 9 | + }); |
| 10 | + |
| 11 | + const shimmerBefore = { |
| 12 | + content: 'attr(text-shimmer-data)', |
| 13 | + position: 'absolute', |
| 14 | + inset: '0', |
| 15 | + 'pointer-events': 'none', |
| 16 | + color: 'transparent', |
| 17 | + 'background-clip': 'text', |
| 18 | + 'background-image': |
| 19 | + 'linear-gradient(90deg, #0000, #0000, #0000, #fff, #0000, #0000, #0000)', |
| 20 | + 'background-size': '200% 100%', |
| 21 | + 'background-position': '150% 0', |
| 22 | + filter: |
| 23 | + 'drop-shadow(0 0 1px #ffffff) drop-shadow(0 0 2px rgba(255,255,255,0.5))', |
| 24 | + }; |
| 25 | + |
| 26 | + addComponents({ |
| 27 | + '.text-shimmer': { |
| 28 | + position: 'relative', |
| 29 | + display: 'inline-block', |
| 30 | + }, |
| 31 | + '.text-shimmer::before': { |
| 32 | + ...shimmerBefore, |
| 33 | + animation: 'text-shimmer 5s linear infinite', |
| 34 | + }, |
| 35 | + '.hover-text-shimmer': { |
| 36 | + position: 'relative', |
| 37 | + display: 'inline-block', |
| 38 | + }, |
| 39 | + '.hover-text-shimmer::before': { |
| 40 | + ...shimmerBefore, |
| 41 | + opacity: '0', |
| 42 | + }, |
| 43 | + '.hover-text-shimmer:hover::before': { |
| 44 | + animation: 'text-shimmer 5s linear infinite', |
| 45 | + opacity: '1', |
| 46 | + }, |
| 47 | + '.group-hover-text-shimmer': { |
| 48 | + position: 'relative', |
| 49 | + display: 'inline-block', |
| 50 | + }, |
| 51 | + '.group-hover-text-shimmer::before': { |
| 52 | + ...shimmerBefore, |
| 53 | + opacity: '0', |
| 54 | + }, |
| 55 | + '.group:hover .group-hover-text-shimmer::before': { |
| 56 | + animation: 'text-shimmer 5s linear infinite', |
| 57 | + opacity: '1', |
| 58 | + }, |
| 59 | + }); |
| 60 | +}); |
0 commit comments