Raft 设计系统

组件 · 消息

MessageQuotedPreview

A two-line excerpt of the message a link points to, with its author, place and time, shown under the message that links to it.

稳定也叫 Quoted message, Message preview, Permalink preview
import { MessageQuotedPreview } from "@botiverse/raft-ui";
本页尚未翻译
译文完成之前,这里显示英文原文。 阅读英文版

When a message links to another message, the quoted preview shows what that message says: its author, where it was posted, when, and the first 2 lines of its text. It sits in MessageItemEmbedded, under the body that holds the link (MessageItem), and opens the quoted message.

message-quoted-preview/compositions/quoted-preview

When to use

SituationUse
A message links to another messageMessageQuotedPreview, under the reference chip
Several messages passed on in fullMessageForwardedBundle
A link to a page outside RaftA link card (MessageEmbed)
A quote typed into the messageA Markdown blockquote (MessageItem)
The replies to a messageMessageReplies

Anatomy

  • MessageQuotedPreview: the preview: a 2px line-seam bar on the left, no fill, foreground-muted text. Required.
  • MessageQuotedPreviewHeader: one line. Required.
    • MessageQuotedPreviewAuthor: an xs Avatar, MessageQuotedPreviewAuthorName and an optional MessageQuotedPreviewAuthorMeta (a role). MessageQuotedPreviewAuthorDelegatedBy follows the name when an assistant sent the quoted message for its author: "(sent by Friday)". It is experimental, exported from @botiverse/raft-ui/wip.
    • MessageQuotedPreviewChannel: where it was posted.
    • MessageQuotedPreviewThread: a thread marker. Optional.
    • MessageQuotedPreviewTimestamp: at the end of the line, in Space Mono.
  • MessageQuotedPreviewContent: required.
    • MessageQuotedPreviewText: the excerpt, in text-callout, cut at 2 lines.
    • MessageQuotedPreviewAttachments with MessageQuotedPreviewAttachment chips. Optional.
  • MessageQuotedPreviewLoading and MessageQuotedPreviewUnavailable: used in place of the preview while it loads, or when it can't be shown.

The bar is the same mark as a quote in a message (Shape).

Variants

VariantUse for
Channel messageA message in a channel, with MessageQuotedPreviewThread when it is a reply in a thread
Direct messageA message in a direct message, with the thread marker when it is a reply in a thread
Archived channelA message in an archived channel: an Archived Badge after the channel name
With attachmentsA message with files: a chip with the count stays visible under the 2 lines of text
message-quoted-preview/compositions/quoted-preview-message
message-quoted-preview/compositions/quoted-preview-direct-message
message-quoted-preview/compositions/quoted-preview-direct-message-thread
message-quoted-preview/compositions/quoted-preview-archived-channel
message-quoted-preview/compositions/quoted-preview-long-content

States

StateLook
LoadingMessageQuotedPreviewLoading, pulsing, with a Skeleton of the header and 2 lines of text
UnavailableMessageQuotedPreviewUnavailable: the bar and one line in foreground-hint that says why, when the message is deleted or the person can't see it
message-quoted-preview/compositions/quoted-preview-loading
message-quoted-preview/compositions/quoted-preview-unavailable

Behavior

  • The preview fills the width of the message column.
  • Text past 2 lines is cut with an ellipsis; the attachment chips stay below it.
  • "(sent by Friday)" never truncates; the author's name truncates instead. When the author and the label fill the line, as on a phone, the place and the time move to a second line: the words are what says the author didn't write it, so they can't be cut, and the face that says it in the timeline is too small to show on a 19px avatar (Identity and presence).
message-quoted-preview/compositions/quoted-preview-delegated
  • Selecting the preview opens the quoted message.

Content

  • Name a channel with its hash: "#launch-week".
  • Name a direct message by the other person's display name, with DirectMessageIcon in place of the hash.
  • Label the thread marker Thread.
  • Write the time in Space Mono, with the day: "Today · 8:24 AM", "May 4 · 3:16 PM".
  • Give the number of attachments in the chip: "2 files".
  • Say why the message can't be shown: "Message unavailable" (Feedback).

Accessibility

  • The parts are plain elements built with Base UI useRender; MessageQuotedPreview is a div.
  • When the preview opens the message, render it as an <a> with an aria-label that names the message and where it is: "Open quoted message in #launch-week". It shows the focus ring on keyboard focus.
  • Give the author's avatar an empty alt: the name beside it says who it is.
  • Give MessageQuotedPreviewLoading aria-busy and an aria-label, such as "Loading quoted message".
  • Don't render MessageQuotedPreviewUnavailable as a link: there is nothing to open.

Rules

  • Render only the parts the quoted message has data for: leave out the thread marker, the role and the attachments when there are none.
  • Give the loading skeleton the shape of the preview, so nothing jumps when it loads (Feedback).

API

MessageQuotedPreview, MessageQuotedPreviewAttachments, MessageQuotedPreviewAttachment, MessageQuotedPreviewAuthor, MessageQuotedPreviewAuthorMeta, MessageQuotedPreviewAuthorName, MessageQuotedPreviewChannel, MessageQuotedPreviewContent, MessageQuotedPreviewHeader, MessageQuotedPreviewLoading, MessageQuotedPreviewText, MessageQuotedPreviewThread, MessageQuotedPreviewTimestamp, MessageQuotedPreviewUnavailable, MessageQuotedPreviewAuthorDelegatedBy

Prop类型默认值
renderAllows you to replace the component's HTML element with a different tag, or compose it with another component.ReactElement | ((props, state) => ReactElement)

Also takes the attributes of its element.

改动

  • 0.12.0 · AddedA message an assistant sent for its owner, from @botiverse/raft-ui/wip: MessageItemDelegatedBy, MessageItemDelegatedByName, MessageItemDelegatedByButton, MessageItemDelegatedAvatar (with deleted) and MessageQuotedPreviewAuthorDelegatedBy.