The demo in "I Don't Read Diffs Anymore", written by Claude for this post
Version 1 · familiar
What you're about to read
This covers the demo in the middle of the post: the markup, the 20 or so lines of JavaScript that drive it, and the CSS that changes when you switch. It's for someone who knows HTML, CSS and JavaScript but hasn't seen this site's code.
We'll follow one click the whole way through: a reader clicks "Walkthrough order", and commands/slowmode.py moves from third place to first.
The big picture
Clickdata-mode="run"The button says which order it wants
↓
MeasuregetBoundingClientRect()Remember where every file sits right now
↓
Reorderlist.append(...sorted)Move the list items into run order in the page
↓
Restyle.order.runStep numbers appear, line counts fade, explanations open
↓
Animateli.animate()Each item glides from its old spot to its new one
Two ideas matter before the code:
The reorder is real. The items move in the page, not just on screen, so the order a screen reader announces matches the order you see.
The animation is a FLIP. The browser jumps the items to their new places, then each one is drawn back where it was and slides home.
91 <li data-run="3"><code>activity.py</code><span class="order-delta">+24 −2</span><span class="order-why"><span>Counts how many messages the channel gets per minute.</span></span></li>
92 <li data-run="2"><code>checks.py</code><span class="order-delta">+9 −0</span><span class="order-why"><span>Makes sure the person running it is allowed to.</span></span></li>
93 <li data-run="1"><code>commands/slowmode.py</code><span class="order-delta">+31 −4</span><span class="order-why"><span>The command arrives here, and this is where everything else gets called from.</span></span></li>3
94 <li data-run="4"><code>db.py</code><span class="order-delta">+12 −1</span><span class="order-why"><span>Saves the new setting for the channel.</span></span></li>
95 <li data-run="5"><code>responses.py</code><span class="order-delta">+7 −0</span><span class="order-why"><span>Builds the reply the user actually sees.</span></span></li>
96 </ol>
97 <figcaption>Same files, same change. A diff shows them alphabetically. A walkthrough shows them in the order they run.</figcaption>
1data-order is what the script looks for, so the same demo could be dropped into any post. 2 Each button carries the order it asks for in data-mode, and aria-pressed says which one is active. 3 Every file has a data-run number: its position in the order the code runs. In the page, the files are written alphabetically, which is the diff order.
6 wires both buttons to show(), passing the button's data-mode. Inside it, 1 records where every item is on screen before anything moves. 2 picks the new order: sorted by data-run for the walkthrough order, or the original alphabetical list. 3 moves the items in the page; append moves an element that's already in the list instead of copying it. 4 adds or removes the run class that the CSS keys off, and 5 updates which button shows as pressed.
1 skips the animation entirely for people who've asked their system for less motion. The items still reorder, they just don't slide. For everyone else, 2 measures where each item ended up, and 3 works out how far it moved. 4 starts it back at its old position and animates it to none, which is its new position.
Where reduceMotion comes from
It's defined once near the top of the file and shared with the zoom and tilt effects.
1 is a CSS counter that numbers each item in the order it currently sits in the page, which is why the numbers come out right after the reorder. In diff order the circle shows a grey M, like git status does for a modified file. 2 swaps that for the step number and fills the circle in, only in run order. 3 fades out the line counts, since those belong to the diff view. The explanation under each file uses the grid rows trick: 4 starts it at 0fr (no height), and 5 opens it to 1fr.
Decisions the AI made
These are choices in the code that the post didn't ask for.
Reordering the page, not just the picture
Web Animations instead of a CSS transition
No step numbers in the HTML
What to check when reviewing
data-run numbers in the markup run 1 to 5 with no gaps or repeats
Clicking the already-pressed button does nothing odd (it re-appends in the same order and animates nothing)
With reduced motion turned on, the list still reorders and the explanations still show
Diff order shows M markers, not step numbers
The toggle fits on a phone without the buttons wrapping awkwardly
Words used here
FLIP
First, Last, Invert, Play. Measure where something is, move it, then animate it from the old spot to the new one.
CSS counter
A number the browser keeps while drawing the page, which goes up by one for each element that asks it to.
Grid rows trick
Animating a grid row from 0fr to 1fr, which lets something open to its natural height smoothly.
What happens next
Nothing is planned. If a future post needs the same comparison, the figure can be reused with different files and a different data-run order.