Conversation
Register a web processor that turns the gradient objects React Native accepts for backgroundImage into CSS gradient functions, so keyframes, transitions and pseudo-selector styles can carry them on react-native-web. The serializer spells out both axes of a partial radial position with React Native's precedence (left over right, top over bottom, 50% for a missing axis), adds the px unit to numeric color stop positions, renders a circle with unequal length radii as max(x, y) and a circle with a percentage radius as the equivalent ellipse, and drops the declaration instead of emitting "[object Object]" for an object color.
📝 WalkthroughWalkthroughThe change adds web processing for Priority: ⬇️ Low Change: Feature Merge Risk: 🟡 Moderate · up to A valid keyframe that clears backgroundImage can throw while CSS is built, preventing the affected web animation from running. Add the null guard before merging. 🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…01/css-background-image-web
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 38a51a50-2993-4371-a42e-6ef6041e46e7
📒 Files selected for processing (8)
apps/common-app/src/apps/css/examples/animations/routes/properties/base.tsdocs/docs-reanimated/docs/guides/supported-properties.mdxpackages/react-native-reanimated/CHANGELOG.mdpackages/react-native-reanimated/src/common/web/style/config.tspackages/react-native-reanimated/src/common/web/style/processors/__tests__/backgroundImage.test.tspackages/react-native-reanimated/src/common/web/style/processors/backgroundImage.tspackages/react-native-reanimated/src/common/web/style/processors/index.tspackages/react-native-reanimated/src/css/web/__tests__/animationParser.test.ts
💤 Files with no reviewable changes (1)
- apps/common-app/src/apps/css/examples/animations/routes/properties/base.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
🟠 Major · Guard null before iterating. · backgroundImage.ts:166-181
packages/react-native-reanimated/src/common/web/style/processors/backgroundImage.ts:166-181
🩺 Stability & Availability | 🟠 Major | ⚡ Quick winGuard null before iterating. A public Reanimated CSS keyframe can contain
backgroundImage: null. Keyframe processing passes it towebPropsBuilder, whosecreatePropsBuilderskips onlyundefined.processBackgroundImageWebthen enters its non-string branch andfor...of valuethrows onnullinstead of omitting the declaration. Addif (value == null) return;before the string check.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: cc6d497d-abef-4abe-ba66-b0d02aec2503
📒 Files selected for processing (2)
packages/react-native-reanimated/src/common/web/style/processors/__tests__/backgroundImage.test.tspackages/react-native-reanimated/src/common/web/style/processors/backgroundImage.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- packages/react-native-reanimated/src/common/web/style/processors/tests/backgroundImage.test.ts
- packages/react-native-reanimated/src/common/web/style/processors/backgroundImage.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 2 remain after this review.
|
Closing: the backgroundImage feature stays in #10193, which will be rebased on the prerequisite fixes; the web serializer fixes from here become commits on that branch. |
Note
This pull request was authored by AI on behalf of @MatiPl01.
Summary
CSS animations and transitions of
backgroundImage(native support in #10590) had no web processor, so gradients in keyframes were dropped. This adds a serializer that turns the React Native gradient object form into CSSlinear-gradient()/radial-gradient()strings, with the same precedence rules react-native-web applies to a static style (two-axis radial position,pxfor numeric positions, a circle with two different radii degrades to an ellipse), and removes theexperimental_backgroundImage: falseexclusion.Browsers decide how the animation looks: current browsers switch
background-imagediscretely even between gradients of the same structure. A transition needs a stringbackgroundImagein the base style because react-native-web does not accept the object form there.Test plan
backgroundImage.test.ts(web processor) andanimationParser.test.ts.web-exampleshows the gradient keyframes switching at the midpoint.Changelog
Entry added to the
Unpublishedsection ofpackages/react-native-reanimated/CHANGELOG.md.