defuss-shadcn / Website / website-comments
Comments
Blocks for a discussion under an article or a product: the header with the count and sort order, the form for a new comment, and the comments with their nested replies. Every block is CSS-only and built from the library's components and tokens.
On this page (3)
§The template
The Comments blocks composed into one discussion - the source is the page. A comment's time is its permalink, a route of defuss-dom-router (#/comments/d-3) that highlights it and names its author above the thread, and the sort order is a query parameter (#/?sort=oldest). The actions work: Like counts, Reply opens the reply form under that comment and adds the reply to its thread line, a new comment joins the top, and Report and the guidelines are native dialogs. The language switch translates the frame with defuss-i18n - the times come from Intl.RelativeTimeFormat, what the script writes from one JSON block in both languages, the comments stay as written.
§A discussion
A time is a permalink route (#/comments/d-2), the sort a query (#/?sort=oldest); the switch translates the frame. Comment Header, Comment Form and a thread of Comment Items with nested replies and a reply form - the Comments blocks composed. Click a timestamp to highlight that comment; Like, Reply, Report and Post comment work.
§The blocks
Comment Header
Introduces a discussion with its comment count and sorting options - a native Select, or sort links in a segmented row.
Comment Item
Displays one comment with its author, timestamp, and reply action - nested replies on a thread line, permalinks that highlight, compact and deleted states.
Comment Form
Collects a new comment or reply - a growing Textarea beside the avatar, guest name and email fields, native validation, a compact reply form.
Comments, ideas or improvements? Edit this page's source on GitHub