Lab

Code review

Slant / Components

One review round of a four-file change: a list of changed files with their totals, the open file's diff, comments under its lines, and Send round, which asks first.

The theme follows the link: share a page with ?theme=moon.

Usage

  • The changed files list each path, its +added −removed totals, any draft comments and a viewed mark; the open one is aria-current, and a Progress counts the files viewed ("1 of 4 reviewed"). Beside the diff once the piece is 640px wide, above it in a narrow column.
  • <DiffView before after language title layoutToggle> shows the open file; the layout is held here, so Split stays on from file to file, and Split passes wrap so both sides fit the piece. Its header is a "Viewed" Checkbox, which marks the file and leaves you on it, so the box you ticked is still the one under focus.
  • renderLineAction puts a ghost icon Button in each line's gutter, "Comment on line 21"; renderLineAfter puts the line's comments under it, and the comment box (a Textarea, Cancel and Add comment) while it is open there. Comments key on the file, the line's number and its side, so they stay put across layouts and folds, and a line with one is never folded away.
  • Added comments wait under their line as drafts, with Delete, and their count rides on Send round. Send round opens an alert Dialog ("Send round 2 with 3 comments?") with the counts; Send turns the drafts into comments marked "Sent in round 2" and opens round 3.

Keyboard

Tabmoves through the files, the Viewed box, the change buttons and the layout toggle, the diff and each line's comment button, then Send round
Enter / Spaceopens the focused file, opens a line's comment box, or ticks Viewed
Alt + ↓ / Alt + ↑in the diff, moves to the next or previous change
⌘ / Ctrl + Enterin a comment box, adds the comment
Escapein a comment box, cancels it; in the dialog, closes it without sending
← / →switches between Unified and Split on the layout toggle

Accessibility

  • Each file is a button whose name carries its path, its totals ("9 added, 3 removed"), its drafts and whether it is reviewed; the progress bar reads "1 of 4 files".
  • Every line's comment button is in the tab order and named after its line ("Comment on line 12", "Comment on removed line 7"). The comment box takes focus when it opens, and focus goes back to the line's button after Add comment, Cancel, Escape or Delete.
  • Until there is a draft or every file is viewed, Send round is aria-disabled and described by the line that says why. In the alert dialog, Cancel takes focus first, and focus returns to Send round when it closes.
  • Each comment added or deleted, file viewed and round sent is read out through a polite status line.

Code review in React and SwiftUI.

Source

The React tab is the component’s real source; the SwiftUI tab is its twin in TUTTNKit.