components/comment-thread/

votes, sorts, replies

Mark Twain·

The secret of getting ahead is getting started. The secret of getting started is breaking your complex overwhelming tasks into small manageable tasks, and then starting on the first one.

412score 412
Confucius·

It does not matter how slowly you go as long as you do not stop.

77score 77
Benjamin Franklin·

Well done is better than well said.

57score 57
Buzz Aldrin·

Long one, sorry. Every comment system I've used fails the same three ways:

  1. Folding moves things. You collapse a thread and the line you were reading jumps.
  2. Deep threads squeeze. Ten levels in, the text is a column of three words.
  3. Long threads are slow. Four thousand replies, all in the DOM, on a phone.

Here the head stays put when it folds, past a depth the thread continues on its own, and past a page of replies the rest wait behind a button.

Which is the whole list.

230score 230
L
lark·

Number two is the one that gets me.

41score 41
W
wren·

The j and k keys are a nice touch.

22score 22
T
tern·

Folding without the jump is underrated.

17score 17
L
lark·

Collapsed by default past a page is the right call.

8score 8
I
ibis·

Bookmarking this.

5score 5
L
lark·

Does that hold for a comment section too? It feels like the one thing every site rebuilds from scratch.

88score 88
adrian·

It does. The parts are already here, which is the point of composing it:

  • the face is avatar, the time relative-time
  • the words markdown, the standing vote or reactions
  • the reply box editor, the keys key-router

Nothing in it draws its own button.

131score 131
W
wren·

And the tree? Building one from flat rows is where mine always went wrong.

24score 24
adrian·

A lib, no React in it:

ts
const thread = buildThread(posts, { sort: "top" })
thread.roots // sorted, each with its replies and their count

Posts come oldest first, so a parent is always known before its replies.

40score 40
T
tern·

What happens with a cycle?

12score 12
adrian·

It can't be written: a reply that names a parent listed after it is refused, with the reason.

19score 19
K
kite·

Short and sweet.

3score 3
W
wren·