feat: animated control for mount-once elements with enter animations#39
Merged
Conversation
New control function 'animated' for wrapping a single element with an enter animation. Renders once and never removes — designed for hand-authored intro sequences where each/when/match don't quite fit. Type surface is enter-only via a new EnterOnlyAnimationOptions type (Pick of AnimationOptions) — no exit fields, since the element is never removed. Group and intro flags work the same as on the other controls: group lives inside the animate config (consistent with each/when/match), intro triggers SSR enterFrom emission and hydration re-animation. Tests cover: mount, client-side enter animation, group sequencing, SSR enterFrom emission, SSR opt-out when intro is omitted. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Deploying effex with
|
| Latest commit: |
d95a27a
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://05d537ca.effex.pages.dev |
| Branch Preview URL: | https://feat-animated.effex.pages.dev |
Deploying effex-api with
|
| Latest commit: |
d95a27a
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://498fd690.effex-api.pages.dev |
| Branch Preview URL: | https://feat-animated.effex-api.pages.dev |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
New `animated` control function for wrapping a single element with an enter animation. Fills the gap between the existing controls: `each` reconciles a signal against a keyed list, `when`/`match` toggle between branches based on state — none of them naturally handle "just mount this one element and animate it in."
The hand-authored intro sequence is the primary use case. Instead of shoehorning static content into `each` or faking a boolean signal for `when`, a headline of sibling `animated` blocks reads directly:
```ts$.span({}, $ .of("Hello,"))),$.span({ class: "wobble" }, $ .of("world!"))),$.span({}, $ .of("Welcome."))),
const App = () =>
Effect.gen(function* () {
const [g0, g1, g2] = yield* Animation.sequence(3);
return $.h1({}, collect(
animated({ animate: { enterFrom: "opacity-0", enter: "opacity-100 transition duration-300", group: g0 }, intro: true },
() =>
animated({ animate: { group: g1 } }, // no visual anim — the span has its own CSS keyframes
() =>
animated({ animate: { enterFrom: "opacity-0", enter: "opacity-100 transition duration-500", group: g2 }, intro: true },
() =>
));
});
```
API
Design choices
Implementation
Direct — bypasses `reconcile` (no signal to reconcile against) and just does `ctx.fork() → getContainer → addSlot("_", …) → finalizeContainer`. That leverages all the existing slot machinery, so `intro` (SSR enterFrom emission + hydration re-animation), `group` (registration + gating + completion), and enter animations work identically to how they do inside `each` / `when` / `match`.
Test plan
🤖 Generated with Claude Code