· 4 min read
Skill windows that collapse, and open as you read
Each skill group on /about is now a window that collapses (SkillWindow.svelte). The title bar is the button, with "expand [+]" or "collapse [-]" on the right.
What we did
- Each skill group on
/aboutis now a window that collapses (SkillWindow.svelte). The title bar is the button, with "expand [+]" or "collapse [-]" on the right. - Collapsed, a window keeps its name, a new one-line description (in
content/skills.yaml), chips for its first five skills with "+N more", and every icon in the title bar, like a dock. One light is on, in Mac colors (new tokens): yellow (minimize) while collapsed, green (zoom) while open. It fades and pops (a spring) when it changes. - Collapsing and expanding animate: the list shrinks while the chips grow, and back. The dock's icons pop in one after another, and when they don't fit the title bar they loop like the logo marquee.
- Windows start collapsed, except the first, and open by themselves as they reach the top two thirds of the screen. Once I open or close one, that's my choice and it stops opening by itself, until I leave or reload. (A first version saved choices in
localStorage; a reload starting fresh felt better.) - Generic (Lucide) icons got colors: a hue from a hash of the skill's name, so each keeps the same color everywhere and on every build.
What I learned
hidden="until-found"hides content but lets find in page (Ctrl+F) search it. On a match, the browser firesbeforematchon it, and the window opens.- A
display: nonewould stop that search, so the CSS never uses it on the list. Before the JS runs, a collapsed list just sits in a row of height zero (below); the attribute only goes on once the JS runs. @media (scripting: enabled)again: collapsed only happens with JS. Without it every window is open and the hint is hidden, because the button wouldn't do anything.- The prerendered page can't know what's on screen, so the server opens the first window, the one you see when the page loads. The rest would have opened after load and shifted the page.
- Opening by itself uses an IntersectionObserver on a region (the top two thirds), not a line: a fast scroll can jump over a line, but where it stops, a window on screen is inside the region.
$state(prop)only takes the prop's first value, and Svelte warns (state_referenced_locally). Here that's the point, so the warning is silenced with a comment saying why.- The button's name for a screen reader is a hidden group name plus the hint ("Languages: collapse"), with
aria-expandedfor the state. The lights, path and icons arearia-hidden. height: autocan't be animated, but a one-row grid can:grid-template-rowsfrom1fr(the content's height) to0fr(nothing). The child needsmin-block-size: 0andoverflow: clip;overflow-clip-marginkeeps the rows' glowing borders from being cut.hidden="until-found"would hide the list at once, before it could shrink, so it's set ontransitionend. Transitions inside the list (a bar's bump) bubble up too, so it checksevent.target === event.currentTargetand the property name. With reduced motion there's no animation to wait for, so it's set straight away.- An animation runs when its element goes from
display: noneto shown, so the dock icons' pop-in replays on every collapse, with--ifor the stagger. - Whether the dock's icons fit is measured with a
ResizeObserveron the dock (a hidden dock is 0 wide, so it's measured again when it appears). Only then is the second copy rendered.
Problems & fixes
- The section nav highlighted the wrong section after a window opened by itself: the page changed height without a scroll event. It now also updates from a
ResizeObserveron the body.
Links
- MDN:
hidden="until-found" - MDN: beforematch
- MDN: aria-expanded
- MDN: ResizeObserver
- CSS-Tricks: animating height with grid
- MDN: overflow-clip-margin
- Svelte: state_referenced_locally
Next
- Review the group descriptions in
content/skills.yaml, then the profile filter and the PR.