Skip to content

Commit fa775ee

Browse files
committed
Clarify dynamic animation docs
1 parent d817450 commit fa775ee

5 files changed

Lines changed: 60 additions & 20 deletions

File tree

docs/api/babel.md

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ module.exports = {
2121
|--------|------|---------|-------------|
2222
| `platform` | `'web'` \| `'ios'` \| `'android'` | `'web'` | Target platform |
2323
| `reactType` | `'react-native'` \| `'web'` | auto | React target type |
24-
| `cache` | `'teamplay'` | auto | Legacy compatibility alias |
2524
| `transformPug` | `boolean` | `true` | Enable Pug transformation |
2625
| `transformCss` | `boolean` | `true` | Enable CSS transformation |
2726

@@ -32,8 +31,7 @@ module.exports = {
3231
module.exports = {
3332
presets: [
3433
['cssxjs/babel', {
35-
transformPug: false, // Disable pug if not using it
36-
cache: 'teamplay' // Legacy compatibility alias
34+
transformPug: false // Disable pug if not using it
3735
}]
3836
]
3937
}
@@ -61,9 +59,7 @@ You can also set platform-specific variables in your Stylus code:
6159

6260
## Caching
6361

64-
CSSX uses the built-in resolver cache by default. The old `cache: 'teamplay'`
65-
option is still accepted so existing configs do not break, but CSSX no longer
66-
imports Teamplay and components do not need `observer()`.
62+
CSSX uses the built-in resolver cache by default.
6763

6864
See the [Caching guide](/guide/caching) for more details.
6965

docs/guide/animations.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,11 @@ CSSX compiles animations in a way Reanimated v4 expects:
323323

324324
This means you write standard CSS and get native-compatible animations automatically.
325325

326-
Animation and transition values are static-only. Use class changes, CSS
327-
variables, or template interpolation to change the surrounding styles at
328-
runtime; keyframe definitions themselves are compiled from static CSS.
326+
Animation and transition declarations use the same value resolver as other CSSX
327+
styles, so values may use `var()` and local template interpolation wherever CSS
328+
values are supported. Animation names, keyframe names, and the `@keyframes`
329+
block structure must remain statically knowable so CSSX can inline the matching
330+
keyframes for Reanimated.
329331

330332
## Next Steps
331333

docs/guide/caching.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Caching
22

3-
CSSX caches resolved style props by default. There is no `observer()` wrapper and
4-
no Teamplay dependency required.
3+
CSSX caches resolved style props by default and tracks the runtime dependencies
4+
used by each element.
55

66
## How It Works
77

@@ -165,12 +165,6 @@ Most applications only need `styleName`. Use these helpers when CSS arrives as a
165165
runtime string or when building lower-level components that do not use Babel's
166166
`styleName` transform.
167167
168-
## Legacy `cache: 'teamplay'`
169-
170-
The Babel option `cache: 'teamplay'` is still accepted for older configs, but it
171-
is now a compatibility alias. CSSX owns its cache internally and does not import
172-
Teamplay.
173-
174168
## Next Steps
175169
176170
- [CSS Variables](/guide/variables) - Runtime theming

packages/babel-plugin-rn-stylename-to-style/README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,7 @@ so these files shouldn't frequently change.
131131

132132
**Default:** `undefined`
133133

134-
Legacy compatibility option. `"teamplay"` is still accepted for older configs,
135-
but style caching is owned by CSSX internally and does not require Teamplay or
136-
`observer()`.
134+
Legacy compatibility option. New projects should omit it.
137135

138136
#### `platform`
139137

packages/css-to-rn/test/engine/resolve.test.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)