feat: Add optional block animation support#292
Closed
coderpr0grammer wants to merge 5 commits intovercel:mainfrom
Closed
feat: Add optional block animation support#292coderpr0grammer wants to merge 5 commits intovercel:mainfrom
coderpr0grammer wants to merge 5 commits intovercel:mainfrom
Conversation
Merged animation feature with main branch updates: - Keep caret feature from main (cursor indicator during streaming) - Add animation feature from feat/animate-blocks-v3 - Both features work together: animation fades in blocks, caret shows cursor Resolved conflicts: - StreamdownProps: Added both caret and animate/animationDuration props - useEffect: Kept both caret style logic and animation CSS injection - Container divs: Merged margin classes, caret classes, and animation classes - Style prop: Combined caret CSS variables with animation duration
Contributor
|
Added animations in #371 |
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.
Description
Add optional
animateandanimationDurationprops to enable progressive fade-in animation on streaming blocks. Uses pure CSS with staggerednth-childdelays - no DOM structure changes, Block component stays untouched.Type of Change
Related Issues
Related to streaming UX improvements
Changes Made
animate?: booleanprop to StreamdownProps (default:false)animationDuration?: numberprop to StreamdownProps (default:300ms)animate=true.streamdown-animateclass to container with staggered nth-child animation delaysprefers-reduced-motionmedia query support for accessibilityCode Changes
Animation CSS and injection (added after imports):
Props added to StreamdownProps:
useEffect to inject styles:
Container div with conditional class and style:
Testing
Test Coverage
Manually tested with:
Screenshots/Demos
Checklist
pnpm changeset)Changeset
Additional Notes
Usage
Design Decisions
Pure CSS approach: Animation is handled entirely via CSS keyframes and classes, avoiding any JavaScript animation libraries or DOM manipulation.
Style injection: CSS is injected into the document head only when
animate=true, keeping the default bundle size unchanged for users who don't use animation.Staggered delays: First 4 blocks get progressively longer delays (0ms, 60ms, 120ms, 180ms), then all subsequent blocks use 240ms to prevent excessive delays on long content.
Accessibility: Includes
prefers-reduced-motionmedia query to respect user preferences and disable animations for users who have motion sensitivity.No breaking changes: All existing functionality remains unchanged. Animation is opt-in via the
animateprop (default:false).Compatibility
caretprop for cursor indicatorstreamingandstaticmodes