fix: restore consensus series SVG animations - #74
Open
vatsalpatel wants to merge 1 commit into
Open
Conversation
The Fumadocs migration removed the GSAP animation layer and rewrote each <AnimatedSVG onAnimate={...} /> into a plain markdown image, so all 16 animations in the consensus series now render every state at once.
Restore svg-animator.ts, AnimatedSVG.tsx, the 14 per-figure timelines and the gsap dependency from ac5d0a5^, and reconnect them by overriding the MDX img component.
Each figure is matched by its caption, so no content changes are needed and both the blog and docs copies are fixed.
AnimatedSVG's wrappers become spans: markdown images are paragraph-wrapped, and a div inside a p closes the paragraph early and breaks hydration.
Signed-off-by: vatsalpatel <vatsalpatel.me@gmail.com>
|
@vatsalpatel is attempting to deploy a commit to the Supabase Team on Vercel. A member of the Team first needs to authorize it. |
Author
|
@SaxonF / @pamelachia Can you please review? |
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.
Fixes #73
Restores the 16 step-through SVG animations in the Generalized Consensus series, which have rendered as static images since the Fumadocs migration (
ac5d0a5).The problem
The consensus figures are single SVGs holding every state of a sequence, each state given an id —
part07-fig3.svgcarries 70 of them. A GSAP timeline fetched the SVG, inlined it, hid everything not yet reached, and revealed one step at a time. Several figures deliberately share one SVG and differ only in the timeline.ac5d0a5deleted the animation layer (17 files, includingsvg-animator.tsand 14 per-figure timelines) and droppedgsap.scripts/migrate-from-docusaurus.mjs:93-100rewrote each<AnimatedSVG src={…} onAnimate={…} />into a plain markdown image, capturing onlysrcandalt—onAnimatewas discarded. With no timeline to hide anything, the browser now paints all 70 elements at once, so figures 3–8 on part 7 render as the same unreadable image.The fix
Restore the deleted code, then reconnect it in the renderer rather than in content:
src/lib/svg-animator.ts, and the 14 timeline scripts — restored byte-for-byte fromac5d0a5^gsap@^3.13.0— restored at its original versionsrc/components/consensus-animations.ts(new) — maps each figure to its timeline and the props it was authored withsrc/components/animated-figure.tsx(new) — renders markdown images normally, except the 16 animated onessrc/components/mdx.tsx—img: AnimatedFigureNo content changes. The migration discarded
onAnimatebut preservedalt, and all 16(alt, svg)pairs are unique, so the caption is enough to recover which timeline belongs to which figure. Every prop in the registry —autoPlay,showControls,showRestartButton,width,height,style— was extracted mechanically from the pre-migration<AnimatedSVG>blocks and diffed field-by-field against them, so the figures render exactly as authored. That includes two deliberate one-offs: part 6's "Figure 1: Revocation methods" autoplays with a replay button rather than stepping, andpart06-fig3is shiftedtranslateX(-450px)because it is 2000px wide.This fixes all five posts and both the blog and docs copies at once.
Notes for review
Three things that aren't obvious:
AnimatedSVG.tsxis not a pure revert. Markdown images are wrapped in a paragraph, and a<div>anywhere inside a<p>makes the browser close the paragraph early — desyncing the parsed DOM from React's tree and breaking hydration. All four wrappers are now<span>s with explicitdisplay. The original never hit this because block-level JSX in MDX isn't paragraph-wrapped. This is the only behavioural change to restored code (22 lines).Matching the SVG can't strip the build hash lexically. Dev serves
/img/consensus/part07-fig3.svg; a build emits/assets/part07-fig3-DEk2p0Pr.svg. Vite hashes may themselves contain-and_(Bexfl0_P,DDkSJ-hG,Dj4zJxj-), so the name is matched as a prefix instead. Worth testing againstpnpm build, not justpnpm dev— a stripping approach passes in dev and silently falls back to static images in a build.Only the 16 known figures are swapped. Everything else falls through to
defaultMdxComponents.imguntouched, including the genuinely-static figures on the same pages (part07-fig1/2/6,part08-fig1,genpolicy).Testing
Verified against a production build (
pnpm build+vite preview), not just dev:<p><div>All 10 routes return 200 and all 6 hashed SVG assets resolve at runtime. Registry props diff clean against the originals for all 16 figures across every field.
pnpm types:checkreports the same 4 pre-existing errors (blog-index-sections.tsx,__root.tsx,blog/$slug.tsx) and no new ones.