Skip to content

Commit 0d20d3e

Browse files
committed
fix: transitions (#39)
1 parent 6624fe5 commit 0d20d3e

File tree

4 files changed

+98
-2
lines changed

4 files changed

+98
-2
lines changed

example/global.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@
1111
--text-2xl--line-height: calc(2em / 1.5);
1212
--text-3xl--line-height: calc(2.25em / 1.875);
1313
--text-4xl--line-height: calc(2.5em / 2.25);
14+
--text-5xl--line-height: 1em;
15+
--text-6xl--line-height: 1em;
16+
--text-7xl--line-height: 1em;
17+
--text-8xl--line-height: 1em;
18+
--text-9xl--line-height: 1em;
1419

1520
--leading-tight: 1.25em;
1621
--leading-snug: 1.375em;

src/__tests__/vendor/tailwind.test.tsx

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,90 @@ import { registerCSS, render, screen, testID } from "react-native-css/jest";
88
* For the full Tailwind CSS test suite, see the Nativewind repository.
99
*/
1010

11+
test("transition", () => {
12+
const compiled = registerCSS(`
13+
:root, :host {
14+
--default-transition-duration: 150ms;
15+
--default-transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
16+
}
17+
18+
.transition {
19+
transition-property: color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, --tw-gradient-from, --tw-gradient-via, --tw-gradient-to, opacity, box-shadow, transform, translate, scale, rotate, filter, -webkit-backdrop-filter, backdrop-filter, display, visibility, content-visibility, overlay, pointer-events;
20+
transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));
21+
transition-duration: var(--tw-duration, var(--default-transition-duration));
22+
}
23+
`);
24+
25+
expect(compiled).toStrictEqual({
26+
s: [
27+
[
28+
"transition",
29+
[
30+
{
31+
a: true,
32+
d: [
33+
{
34+
transitionProperty: [
35+
"color",
36+
"backgroundColor",
37+
"borderColor",
38+
"textDecorationColor",
39+
"fill",
40+
"stroke",
41+
"opacity",
42+
"boxShadow",
43+
"transform",
44+
"translate",
45+
"scale",
46+
"rotate",
47+
"filter",
48+
"display",
49+
"pointerEvents",
50+
],
51+
},
52+
[
53+
[
54+
{},
55+
"var",
56+
[
57+
"tw-ease",
58+
[{}, "var", "default-transition-timing-function", 1],
59+
],
60+
1,
61+
],
62+
"transitionTimingFunction",
63+
1,
64+
],
65+
[
66+
[
67+
{},
68+
"var",
69+
[
70+
"tw-duration",
71+
[{}, "var", "default-transition-duration", 1],
72+
],
73+
1,
74+
],
75+
"transitionDuration",
76+
1,
77+
],
78+
],
79+
dv: 1,
80+
s: [2, 1],
81+
},
82+
],
83+
],
84+
],
85+
vr: [
86+
["default-transition-duration", [150]],
87+
[
88+
"default-transition-timing-function",
89+
[[{}, "cubic-bezier", [0.4, 0, 0.2, 1]]],
90+
],
91+
],
92+
});
93+
});
94+
1195
test("box-shadow", () => {
1296
const compiled = registerCSS(`
1397
.shadow-xl {

src/compiler/declarations.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2580,7 +2580,10 @@ export function addTransitionValue(
25802580
case "transition-property": {
25812581
builder.addDescriptor(
25822582
declaration.property,
2583-
declaration.value.map((v) => v.property),
2583+
declaration.value
2584+
.map((v) => v.property)
2585+
.filter((v) => v in parsers || v === "all" || v === "none")
2586+
.map((v) => toRNProperty(v)),
25842587
);
25852588
return;
25862589
}

src/compiler/stylesheet.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,11 @@ export class StylesheetBuilder {
260260
delayed || usesVariables,
261261
);
262262
} else {
263-
if (property.startsWith("animation-")) {
263+
if (
264+
property.startsWith("animation-") ||
265+
property.startsWith("transition-") ||
266+
property === "transition"
267+
) {
264268
rule.a ??= true;
265269
}
266270

0 commit comments

Comments
 (0)