-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwaterReflectionPlugin.js
95 lines (91 loc) · 2.47 KB
/
waterReflectionPlugin.js
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import plugin from 'tailwindcss/plugin';
/* Adapted from: https://web.dev/speedy-css-tip-animated-gradient-text/ */
const waterReflectionPlugin = plugin(function ({ addUtilities, addBase }) {
addUtilities({
'.water-reflection-text': {
'--bg-size': '300%',
'--color-one': '#9ac2bf',
'--color-two': '#406966',
display: 'inline-block',
position: 'relative',
'background-image':
'linear-gradient(90deg, var(--color-one), var(--color-two), var(--color-one))',
'background-size': 'var(--bg-size) 100%',
'background-repeat': 'repeat',
'-webkit-background-clip': 'text',
'background-clip': 'text',
animation: 'move-bg 8s linear infinite',
color: 'transparent',
'& *': {
'background-image': 'inherit',
'background-clip': 'inherit',
'-webkit-background-clip': 'inherit',
'background-size': 'inherit',
animation: 'inherit',
color: 'transparent'
}
},
'.water-reflection-underline': {
'&::after': {
content: '""',
position: 'absolute',
left: '0',
right: '0',
bottom: '0',
height: '2px',
'background-image':
'linear-gradient(90deg, var(--color-one), var(--color-two), var(--color-one))',
'background-size': 'var(--bg-size) 100%',
animation: 'move-bg 8s linear infinite'
}
},
'.water-reflection-border': {
'--bg-size': '300%',
'--color-one': '#9ac2bf',
'--color-two': '#406966',
'--border-width': '2px',
position: 'relative',
'z-index': '0',
'&::before': {
content: '""',
position: 'absolute',
top: 'calc(-1 * var(--border-width))',
left: 'calc(-1 * var(--border-width))',
right: 'calc(-1 * var(--border-width))',
bottom: 'calc(-1 * var(--border-width))',
background: 'linear-gradient(90deg, var(--color-one), var(--color-two), var(--color-one))',
'background-size': 'var(--bg-size) 100%',
'z-index': '-1',
animation: 'move-bg 8s linear infinite',
'border-radius': 'inherit'
},
'&::after': {
content: '""',
position: 'absolute',
top: '0',
left: '0',
right: '0',
bottom: '0',
background: 'inherit',
'z-index': '-1',
'border-radius': 'inherit'
}
}
});
addBase({
'@keyframes move-bg': {
to: {
'background-position': 'var(--bg-size) 0'
}
}
});
addBase({
'@media (prefers-reduced-motion: reduce)': {
'.water-reflection-text, .water-reflection-underline:after, .water-reflection-border::before':
{
animation: 'none'
}
}
});
});
export default waterReflectionPlugin;