@@ -284,4 +284,54 @@ describe('@cssxjs/css-to-rn resolver', () => {
284284 animationPlayState : 'running'
285285 } )
286286 } )
287+
288+ it ( 'resolves variables and interpolation inside animation and transition values' , ( ) => {
289+ const sheet = compileCssTemplate ( `
290+ @keyframes fade {
291+ from { opacity: var(--from-opacity, 0); }
292+ to { opacity: var(--target-opacity, 1); }
293+ }
294+ .button {
295+ animation: var(--animation-name, fade) var(--__cssx_dynamic_0) ease;
296+ transition: opacity var(--transition-duration, 150ms);
297+ }
298+ ` )
299+
300+ const result = resolveCssx ( {
301+ styleName : 'button' ,
302+ layers : {
303+ sheet,
304+ values : [ '300ms' ]
305+ } ,
306+ variables : {
307+ '--from-opacity' : 0.25 ,
308+ '--target-opacity' : 0.75 ,
309+ '--transition-duration' : '250ms'
310+ }
311+ } )
312+
313+ assert . deepEqual ( result . dependencies . vars , [
314+ '--animation-name' ,
315+ '--from-opacity' ,
316+ '--target-opacity' ,
317+ '--transition-duration'
318+ ] )
319+ assert . deepEqual ( result . props . style , {
320+ animationName : {
321+ from : { opacity : 0.25 } ,
322+ to : { opacity : 0.75 }
323+ } ,
324+ animationDuration : '300ms' ,
325+ animationTimingFunction : 'ease' ,
326+ animationDelay : '0s' ,
327+ animationIterationCount : 1 ,
328+ animationDirection : 'normal' ,
329+ animationFillMode : 'none' ,
330+ animationPlayState : 'running' ,
331+ transitionProperty : 'opacity' ,
332+ transitionDuration : '250ms' ,
333+ transitionTimingFunction : 'ease' ,
334+ transitionDelay : '0s'
335+ } )
336+ } )
287337} )
0 commit comments