Conversation
Description
Conversation lays out an issue-tracker style discussion: ConversationComment cards joined by a vertical rail, with ConversationEvent rows between them for changes such as a label added or the thread closed. A comment has an avatar, an action and timestamp, role badges, an optional "…" menu, a Markdown body rendered by a MarkdownBlock, attachments and emoji reactions. A ConversationComposer with Write / Preview tabs can be placed at the foot of the thread with .Composer(...). .Compact() switches every item, including ones added later, to a denser layout.
Usage
Create the thread with Conversation() and add comments and events with .Children(...) or .Add(...). The composer's OnSubmit callback receives the Markdown text; the sample adds it to the thread as a new comment.
The same items in compact form, with a Highlighted() comment and events whose rail icon is filled with Tone(...):
API reference
public sealed class Conversation : IComponent, IHasMarginPaddingA discussion thread in the shape of an issue tracker's conversation: a column of ConversationComment cards joined by a vertical rail, with ConversationEvent rows for what happened in between (labels added, someone assigned, the thread closed) and an optional ConversationComposer at the foot. Any other IComponent can be added as an item too, and sits on the rail like the rest.
Remarks
Pair it with a MetadataPanel beside it for the assignees / labels / milestone column.
- Namespace
- Tesserae
- Implements
- IComponent, IHasMarginPadding
Constructors
| Name | Description |
|---|---|
| Conversation | Initializes a new, empty conversation. |
Properties
| Name | Description |
|---|---|
| Margin | |
| Padding | |
| Items | The items in the conversation, in the order they were added. |
| IsCompact | Whether the thread is drawn in its dense form (see Compact). |
public IReadOnlyList<IComponent> ItemsThe items in the conversation, in the order they were added.
Methods
| Name | Description |
|---|---|
| Add | Appends an item - a comment, an event or any other component - to the end of the thread. |
| Children | Appends several items to the end of the thread. |
| Remove | Removes an item from the thread. |
| Clear | Removes every item from the thread. The composer stays. |
| Compact | Draws the thread densely: tighter comment headers and bodies, smaller avatars, reaction chips and rail icons, less space between items and a shorter composer - for a thread in a side panel, or a long one that should fit more on screen. It applies to everything in the thread, including items added later. |
| Composer | Sets what sits under the last item, off the rail: usually a ConversationComposer. Pass null to remove it. |
| Render | Renders the component. |
public Conversation Add(IComponent item)Appends an item - a comment, an event or any other component - to the end of the thread.
public Conversation Children(params IComponent[] items)Appends several items to the end of the thread.
public Conversation Remove(IComponent item)Removes an item from the thread.
public Conversation Clear()Removes every item from the thread. The composer stays.
public Conversation Compact(bool value = true)Draws the thread densely: tighter comment headers and bodies, smaller avatars, reaction chips and rail icons, less space between items and a shorter composer - for a thread in a side panel, or a long one that should fit more on screen. It applies to everything in the thread, including items added later.
public Conversation Composer(IComponent composer)Sets what sits under the last item, off the rail: usually a ConversationComposer. Pass null to remove it.
public sealed class ConversationComment : ComponentBase<ConversationComment, HTMLElement>One comment in a Conversation: a card whose header names the author (with their Avatar), what they did and when, carries their role badges and an overflow menu, and whose body is Markdown (rendered by a MarkdownBlock) or any component. Images or other attachments go under the body, and emoji reactions in a row at the foot.
- Namespace
- Tesserae
- Inheritance
- ComponentBase<ConversationComment, HTMLElement> → ConversationComment
Constructors
| Name | Description |
|---|---|
| ConversationComment | Initializes a new comment. |
public ConversationComment(string author, string markdown = null, string timestamp = null, Avatar avatar = null)Initializes a new comment.
Parameters
- author
- The name shown in bold at the start of the header.
- markdown
- The body, as Markdown. Pass
nullto set a component body later withBody. - timestamp
- When it was posted, as display text (e.g.
"on Jul 22","3 days ago"). - avatar
- The author's avatar. Defaults to one made from the author's initials.
Properties
Methods
| Name | Description |
|---|---|
| SetAuthor | Sets the author's name. |
| SetAvatar | Sets the avatar shown at the start of the header. It is drawn at XSmall. |
| Action | Sets the verb between the author and the time - "commented" by default, "opened" for the first post of an issue, "replied", ... |
| Timestamp | Sets when the comment was posted, as display text, with an optional tooltip (typically the full date and time). |
| Edited | Shows (or hides) the "edited" marker after the time, with an optional tooltip such as who edited it and when. |
| Role | Adds an outlined role badge to the right of the header - "Author", "Member", "Contributor", "Bot", ... |
| ClearRoles | Removes every role badge. |
| Menu | Gives the header an overflow ("…") button that opens a menu with these items - copy link, quote reply, edit, delete, ... |
| Body | Sets the body to Markdown, rendered and sanitized by a MarkdownBlock. |
| Attachment | Adds an attachment under the body - an Image (a screenshot), a file card, anything. Several attachments wrap in a row. |
| Reaction | Adds (or updates) a reaction chip at the foot of the comment. reacted marks the chip as one the current user has added. A chip whose count reaches zero is removed. |
| OnReact | Registers a callback for when the current user adds or removes a reaction, by clicking a chip or picking one from the add-reaction button (which this also shows). The arguments are the comment, the emoji and whether it is now added. The chip has already been updated when it is called. |
| ReactionChoices | Sets the emoji the add-reaction button offers. Defaults to DefaultReactions. |
| GetReaction | The count of a reaction, and whether the current user is one of those who added it. |
| Highlighted | Marks the comment as highlighted - a primary border, as for the comment a link points to, or the one a reader is replying to. |
| Render | Renders the component. |
public ConversationComment SetAuthor(string author)Sets the author's name.
public ConversationComment SetAvatar(Avatar avatar)Sets the avatar shown at the start of the header. It is drawn at XSmall.
public ConversationComment Action(string action)Sets the verb between the author and the time - "commented" by default, "opened" for the first post of an issue, "replied", ...
public ConversationComment Timestamp(string text, string tooltip = null)Sets when the comment was posted, as display text, with an optional tooltip (typically the full date and time).
public ConversationComment Edited(bool edited = true, string tooltip = null)Shows (or hides) the "edited" marker after the time, with an optional tooltip such as who edited it and when.
public ConversationComment Role(string role)Adds an outlined role badge to the right of the header - "Author", "Member", "Contributor", "Bot", ...
public ConversationComment ClearRoles()Removes every role badge.
public ConversationComment Menu(params ContextMenu.Item[] items)Gives the header an overflow ("…") button that opens a menu with these items - copy link, quote reply, edit, delete, ...
| Overload | |
|---|---|
| Body(string, MarkdownSanitization) | Sets the body to Markdown, rendered and sanitized by a MarkdownBlock. |
| Body(IComponent) | Sets the body to any component. |
public ConversationComment Attachment(IComponent attachment)Adds an attachment under the body - an Image (a screenshot), a file card, anything. Several attachments wrap in a row.
public ConversationComment Reaction(string emoji, int count, bool reacted = false)Adds (or updates) a reaction chip at the foot of the comment. reacted marks the chip as one the current user has added. A chip whose count reaches zero is removed.
public ConversationComment OnReact(Action<ConversationComment, string, bool> onReact)Registers a callback for when the current user adds or removes a reaction, by clicking a chip or picking one from the add-reaction button (which this also shows). The arguments are the comment, the emoji and whether it is now added. The chip has already been updated when it is called.
public ConversationComment ReactionChoices(params string[] emojis)Sets the emoji the add-reaction button offers. Defaults to DefaultReactions.
public (int count, bool reacted) GetReaction(string emoji)The count of a reaction, and whether the current user is one of those who added it.
public ConversationComment Highlighted(bool value = true)Marks the comment as highlighted - a primary border, as for the comment a link points to, or the one a reader is replying to.
Fields
| Name | Description |
|---|---|
| DefaultReactions | The reactions offered by the add-reaction picker, unless ReactionChoices changes them. |
public sealed class ConversationEvent : ComponentBase<ConversationEvent, HTMLElement>A one-line event on a Conversation's rail, between comments: an icon on the rail, then who did what and when - "Ana added the bug label 2 days ago". Components such as Tags can be placed inline in the sentence, and a detail line (a commit, a linked pull request) under it.
- Namespace
- Tesserae
- Inheritance
- ComponentBase<ConversationEvent, HTMLElement> → ConversationEvent
Constructors
| Name | Description |
|---|---|
| ConversationEvent | Initializes a new event. |
public ConversationEvent(UIcons icon, string actor, string text, string timestamp = null)Initializes a new event.
Parameters
- icon
- The icon drawn on the rail (a tag for a label change, a check for a close, ...).
- actor
- Who did it, shown in bold. Pass
nullfor an event nobody did. - text
- What they did, e.g.
"added"or"closed this as completed". - timestamp
- When, as display text.
Methods
| Name | Description |
|---|---|
| SetAvatar | Sets the actor's avatar, drawn small before their name. Pass null to show none. |
| Inline | Places components inline in the sentence, after the text - the label Tags that were added, a milestone link, the name of a branch. |
| Timestamp | Sets when it happened, as display text, with an optional tooltip. |
| Detail | Sets a line under the sentence - the commit that referenced the issue, a pull request, a quote. |
| Tone | Fills the icon on the rail with a tone, for the events that change the state of the thread: success when it is reopened, danger when it is closed as not planned, AI or primary when it is completed. Neutral (the default) is the plain outlined icon. |
| Render | Renders the component. |
public ConversationEvent SetAvatar(Avatar avatar)Sets the actor's avatar, drawn small before their name. Pass null to show none.
| Overload | |
|---|---|
| Inline(IComponent[]) | Places components inline in the sentence, after the text - the label Tags that were added, a milestone link, the name of a branch. |
| Inline(string) | Places text inline in the sentence, after anything already there. |
public ConversationEvent Timestamp(string text, string tooltip = null)Sets when it happened, as display text, with an optional tooltip.
public ConversationEvent Detail(IComponent detail)Sets a line under the sentence - the commit that referenced the issue, a pull request, a quote.
public ConversationEvent Tone(BadgeTone tone)Fills the icon on the rail with a tone, for the events that change the state of the thread: success when it is reopened, danger when it is closed as not planned, AI or primary when it is completed. Neutral (the default) is the plain outlined icon.
public sealed class ConversationComposer : ComponentBase<ConversationComposer, HTMLElement>The reply box at the foot of a Conversation: the current user's Avatar beside a card with Write / Preview tabs, a Markdown TextArea, a live MarkdownBlock preview and a submit button (plus any extra actions, such as "Close issue").
- Namespace
- Tesserae
- Inheritance
- ComponentBase<ConversationComposer, HTMLElement> → ConversationComposer
Constructors
| Name | Description |
|---|---|
| ConversationComposer | Initializes a new composer. |
public ConversationComposer(Avatar avatar = null, string placeholder = "Add your comment here...", string submitText = "Comment")Initializes a new composer.
Parameters
- avatar
- The current user's avatar, drawn to the left of the box. Pass
nullfor none. - placeholder
- The placeholder of the text area.
- submitText
- The text of the submit button.
Properties
Methods
| Name | Description |
|---|---|
| SetAvatar | Sets the current user's avatar. Pass null to show none. |
| SetText | Sets the text in the box. |
| OnSubmit | Registers the callback for the submit button (and Ctrl/⌘+Enter). It gets the composer and the Markdown text; the box is cleared and back on the Write tab when it is called. |
| Actions | Adds buttons to the left of the submit button - "Close issue", "Cancel", ... |
| Focus | Moves focus into the text area. |
| Render | Renders the component. |
public ConversationComposer SetAvatar(Avatar avatar)Sets the current user's avatar. Pass null to show none.
public ConversationComposer SetText(string text)Sets the text in the box.
public ConversationComposer OnSubmit(Action<ConversationComposer, string> onSubmit)Registers the callback for the submit button (and Ctrl/⌘+Enter). It gets the composer and the Markdown text; the box is cleared and back on the Write tab when it is called.
public ConversationComposer Actions(params Button[] buttons)Adds buttons to the left of the submit button - "Close issue", "Cancel", ...