Skip to content

Commit 23f6cc0

Browse files
author
Adam Plesnik
committed
Add plugin script
1 parent da90fc5 commit 23f6cc0

File tree

1 file changed

+91
-0
lines changed

1 file changed

+91
-0
lines changed

src/index.js

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
import plugin from 'tailwindcss/plugin'
2+
3+
module.exports = plugin(
4+
function ({ matchUtilities, theme }) {
5+
matchUtilities(
6+
{
7+
timeline: (value, { modifier }) => ({
8+
animationTimeline: modifier ? `--${modifier}` : value,
9+
}),
10+
},
11+
{
12+
values: {
13+
DEFAULT: 'scroll(y)',
14+
auto: 'auto',
15+
none: 'none',
16+
'scroll-x': 'scroll(x)',
17+
view: 'view()',
18+
},
19+
modifiers: 'any',
20+
}
21+
)
22+
23+
matchUtilities(
24+
{
25+
'scroll-timeline': (value, { modifier }) => ({
26+
scrollTimeline: (modifier ? `--${modifier} ` : 'none ') + value,
27+
}),
28+
},
29+
{
30+
values: theme('timelineValues'),
31+
modifiers: 'any',
32+
}
33+
)
34+
35+
matchUtilities(
36+
{
37+
'view-timeline': (value, { modifier }) => ({
38+
viewTimeline: (modifier ? `--${modifier} ` : 'none ') + value,
39+
}),
40+
},
41+
{
42+
values: theme('timelineValues'),
43+
modifiers: 'any',
44+
}
45+
)
46+
47+
matchUtilities(
48+
{
49+
scope: (value, { modifier }) => ({
50+
timelineScope: `--${modifier}`,
51+
}),
52+
},
53+
{ values: { DEFAULT: '' }, modifiers: 'any' }
54+
)
55+
56+
matchUtilities(
57+
{
58+
'range-start': (value) => ({
59+
animationRangeStart: value,
60+
}),
61+
},
62+
{ values: { DEFAULT: 'entry', exit: 'exit', ...theme('rangeValues') } }
63+
)
64+
65+
matchUtilities(
66+
{
67+
'range-end': (value) => ({
68+
animationRangeEnd: value,
69+
}),
70+
},
71+
{ values: { DEFAULT: 'exit', entry: 'entry', ...theme('rangeValues') } }
72+
)
73+
},
74+
75+
{
76+
theme: {
77+
timelineValues: {
78+
DEFAULT: 'y',
79+
block: 'block',
80+
x: 'x',
81+
},
82+
rangeValues: {
83+
normal: 'normal',
84+
contain: 'contain',
85+
cover: 'cover',
86+
'entry-crossing': 'entry-crossing',
87+
'exit-crossing': 'exit-crossing',
88+
},
89+
},
90+
}
91+
)

0 commit comments

Comments
 (0)