https://fuma-nama.vercel.app/blog/svg-art
MeProjects
Playground
Blog
#SVG
More about SVG. Note that the example code is written in JSX (or
React), not ordinary HTML.
#Animated Wires
Make the line, using line or path.
Make it a mask.
Add animation.
@keyframes to-down {
0% {
transform: translateY(-10px);
}
100% {
transform: translateY(50px);
}
}
Make styles.
@keyframes to-down-2 {
0% {
transform: translateY(calc(var(--height) * -1));
}
100% {
transform: translateY(100%);
}
}
Most of these similar things are using the same technique. Mask out
an animated block, putting some animations and probably designed some
parts in Figma or other SVG editors.
Unkey's landing page is a nice example.
#Clerk TOC
I made a clerk-like style Table Of Contents (TOC) on Fumadocs, you
can try it out and play with the nice TOC.
preview
To implement it, we have to render the TOC outline on server, without
client-side JavaScript to make it compatible with SSR.
Since we're on server, we don't know the exact positions of elements.
My approach is to use absolute positions, render the outline as
different "components", and snitch them together.
toc
This isn't hard, but we also want to render a highlighted part of
outline where the items are active, or their corresponding heading is
visible in the viewport.
Like:
example
I'll call it the thumb. It has to be animated, so we can't just
change the color of these outline components.
toc
We cannot animate the thumb with simple CSS solutions, lucky we have
the exact rendered positions of TOC items, since the thumb is meant
to be interactive, it is rendered on client!
Using the information from our browser, we can construct a "mask map"
on client, look like this:
The method to construct this map is SVG - yes, our old friend.
The d property of SVG