The diff of one file in a review: a header with the path, the lines added and removed and a "viewed" checkbox,
and the unified diff as a table with the old and the new line numbers, a gutter with the button that adds a
comment, and tinted rows for the added and the removed lines. line_thread/1 is the conversation that hangs
from a line.
The diff comes as data, never as text to parse: hunks is a list of %{header: "@@ -12,6 +12,9 @@", lines: [...]} (the header is optional) and each line is %{old: 15, new: nil, kind: :del, text: "..."}, where
kind is :context, :add or :del and the number that does not exist is nil. With lang: :elixir the
code is coloured through DevactionUI.Highlight; without it the row's own colour is used. The sign of the
line (a space, + or -) is part of the text, so the difference is not only a colour.
A thread is a :thread slot with the line it hangs from and its side (:new, the default, or :old);
it opens under that line, and the button of that line turns amber. The button of a line sends
comment_event with path, line and side; a removed line has no button unless comment_removed is
set. The checkbox sends viewed_event with path. Events are attributes (a string or a %JS{}) and
target is the phx-target when used inside a LiveComponent. The icons come through slots; the button
falls back to + and the checkbox to ✓.
Summary
Functions
The header and the unified diff of one file.
The conversation attached to a line of the diff.
Types
@type line() :: %{ :kind => :context | :add | :del, :text => String.t(), optional(:old) => pos_integer() | nil, optional(:new) => pos_integer() | nil }
Functions
@spec diff(map()) :: Phoenix.LiveView.Rendered.t()
The header and the unified diff of one file.
Attributes
id(:string) (required)path(:string) (required) - the path of the file, shown in the header.hunks(:list) (required) - the diff as data; see the module documentation.additions(:integer) - the lines added in the header; counted from the hunks when not given. Defaults tonil.deletions(:integer) - the lines removed in the header; counted from the hunks when not given. Defaults tonil.lang(:atom) -:elixircolours the code throughDevactionUI.Highlight. Defaults tonil. Must be one ofnil, or:elixir.viewed(:boolean) - the file is marked as viewed. Defaults tofalse.viewed_label(:string) (required) - the label of the viewed checkbox.viewed_event(:any) - sent withpathwhen the checkbox is pressed. Defaults tonil.comment_label(:string) (required) - names the button of a line, as in"Comment on line %{line}".comment_event(:any) - sent withpath,lineandsidewhen the button of a line is pressed. Defaults tonil.comment_removed(:boolean) - removed lines get the comment button too (on the old side). Defaults tofalse.target(:any) - aphx-target(a@myself) when used inside a LiveComponent. Defaults tonil.class(:any) - Defaults tonil.- Global attributes are accepted.
Slots
thread- a conversation hung from a line; its content is aline_thread/1. Accepts attributes:line(:integer) (required) - the number of the line it hangs from.side(:atom) -:new(the default) or:old.
file_icon- the icon before the path.comment_icon- the content of the comment button; without it,+.check_icon- the mark of the checked viewed checkbox; without it,✓.
@spec line_thread(map()) :: Phoenix.LiveView.Rendered.t()
The conversation attached to a line of the diff.
Attributes
id(:string) (required)label(:string) (required) - the name of the conversation for assistive technology.path(:string) (required) - the file the conversation is about.line(:integer) (required) - the line it hangs from.side(:atom) - Defaults to:new. Must be one of:new, or:old.placeholder(:string) (required) - the placeholder of the reply field.reply_label(:string) (required) - the name of the reply field.note(:string) (required) - the small note under the field, e.g.Markdown supported.resolve_label(:string) (required) - the label of the button that closes the thread.comment_label(:string) (required) - the label of the button that sends the reply.suggestion_label(:string) - the title of a suggested change. Defaults tonil.apply_label(:string) - the label of the button that applies a suggested change. Defaults tonil.resolved(:boolean) - the thread is closed: the:summaryslot shows instead, or nothing without it. Defaults tofalse.resolve_event(:any) - sent withpath,lineandside. Defaults tonil.comment_event(:any) - the form's submit event, withbody,path,lineandside. Defaults tonil.apply_event(:any) - sent withpath,line,sideandmessage. Defaults tonil.target(:any) - aphx-target(a@myself) when used inside a LiveComponent. Defaults tonil.class(:any) - Defaults tonil.- Global attributes are accepted.
Slots
message(required) - one message; its content is the text. Accepts attributes:id(:string) - sent asmessagewhen its suggestion is applied.author(:string) (required)initials(:string) (required) - in the square before the author.time(:string) - when it was written, as text.ai_label(:string) - the tag after the author; given, the author is an AI.suggestion(:map) - a suggested change,%{from: "old line", to: "new line"}.
summary- what shows in place of the thread when it is resolved.