Raft 设计系统

组件 · 消息

MessageForwardedBundle

A card under a message that holds one or more messages forwarded from another conversation, with their authors, times and attachments, folded when it runs long.

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

A card with the messages someone forwarded: a Forwarded header with the count and where they came from, then each message with its author, time, text and attachments. It is built on MessageEmbed and sits in MessageItemEmbedded, under the body of the message that forwarded it (MessageItem). Long bundles fold on their own.

message-forwarded-bundle/compositions/forwarded-bundle

When to use

SituationUse
One or more messages passed on from another conversationMessageForwardedBundle
A link to one message, shown as an excerptMessageQuotedPreview
A link to a message or a channel, inline in the textA reference chip (MessageItem)
A quote typed into the messageA Markdown blockquote (MessageItem)

Anatomy

  • MessageForwardedBundle: the card. Required.
  • MessageForwardedBundleHeader: the top row; it wraps on a narrow column. Required.
    • MessageForwardedBundleHeaderContent, with MessageForwardedBundleHeaderLabel (an icon and Forwarded) and MessageForwardedBundleHeaderCount (in Space Mono, foreground-hint).
    • The source, at the end of the row: MessageForwardedBundleSource when it can be opened, MessageForwardedBundleSourceLabel when it can't. Optional.
  • MessageForwardedBundleItems: the list of messages, and the part that folds. Required.
  • MessageForwardedBundleItem: one forwarded message. At least 1.
    • MessageForwardedBundleItemMeta: MessageForwardedBundleItemAuthor, then the time in Space Mono.
    • MessageForwardedBundleItemContent: the text. Required: the fold measures only this part.
    • MessageForwardedBundleAttachments: MessageForwardedBundleAttachment chips (MessageForwardedBundleAttachmentName, MessageForwardedBundleAttachmentMeta), and MessageForwardedBundleGallery with a MessageForwardedBundleGalleryTile per image. Optional.
  • MessageForwardedBundleFooter with MessageForwardedBundleFooterAction: the action that unfolds the list. Optional.

Variants

VariantUse for
A few short messagesThe common case: shown in full, with no footer
Long contentText beyond the fold limit: the list folds and the footer appears
Source that opens (MessageForwardedBundleSource)A source the person can open, such as a public channel or a thread in one
Static source (MessageForwardedBundleSourceLabel)A source that can't be opened, such as a preview in the composer or a message that no longer exists
fullWidthA place where the card fills the column instead of keeping its maximum width
message-forwarded-bundle/compositions/forwarded-bundle-compact
message-forwarded-bundle/compositions/forwarded-bundle-long-content
message-forwarded-bundle/compositions/forwarded-bundle-thread
message-forwarded-bundle/compositions/forwarded-bundle-static-source

Behavior

  • The card is at most 544px wide, and narrower when the column is.
  • By default the bundle folds itself: when the text of all items together runs past foldLineLimit lines (8), the list is cut at that height and fades out at the bottom into layer-card.
  • The footer shows only while the list is folded. Its action unfolds the list and folds it again; expandedContent is its label while unfolded.
  • The bundle measures again when content arrives or the width changes. Once the person has folded or unfolded it, it stays as they left it, unless the content no longer needs folding.
  • Pass collapsed to MessageForwardedBundleItems to control the fold yourself, as a detail view that shows everything does. The footer then always renders, and you label it.
  • To make the footer action open a detail view instead of unfolding, call preventDefault in its onClick.
  • MessageForwardedBundleGallery lays images in rows of 3, and 4 images as 2 rows of 2, at the sizes of a message's own gallery (MessageAttachment).

Content

  • Label the header Forwarded, and give the count in Space Mono: "3 messages".
  • Write the source as "from #launch-week", with "· thread" when it is a thread.
  • Show a source only when the person may see it; leave it out for a direct message, a private channel or a missing source.
  • Name each author by their display name, not a handle (Writing).
  • Label the footer action with what it does, in Title Case: Show All 6 Messages, then Collapse.
  • Give each attachment chip its file name and type: "release-notes.md · markdown".
  • An attachment chip takes 5.5px before its icon and 6.5px after its text, 12px in all as before: a file icon is drawn 1.75px inside its box, so its ink and the last letter both sit about 7.2px from the edges (Alignment).

Accessibility

  • The parts are plain elements built with Base UI useRender; each MessageForwardedBundleItem is an <article>.
  • MessageForwardedBundleSource is a <button>. When it navigates, render it as an <a> with an aria-label that names the place: "Open source thread in #launch-week".
  • While the bundle owns the fold, MessageForwardedBundleFooterAction sets aria-expanded. With collapsed, set it yourself.
  • Put each item's time in a <time> element with its dateTime.
  • interactive on MessageForwardedBundleAttachment only adds the hover and focus look. Render the chip as a <button> or <a> that opens the file, with an aria-label such as "Open release-notes.md".
  • Give gallery images an alt as in MessageAttachment.

Rules

  • Wrap each item's text in MessageForwardedBundleItemContent: text outside it isn't measured, and the bundle won't fold.
  • Don't render a bundle with no items.

API

MessageForwardedBundle

Prop类型默认值
fullWidthbooleanfalse
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.

MessageForwardedBundleAttachment

Prop类型默认值
interactiveMarks the attachment as actionable (the consumer wires the open action on `render`). Adds the pointer/hover/focus affordance to the chip.booleanfalse
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.

MessageForwardedBundleAttachmentMeta, MessageForwardedBundleAttachmentName, MessageForwardedBundleAttachments, MessageForwardedBundleFooter, MessageForwardedBundleGallery, MessageForwardedBundleGalleryTile, MessageForwardedBundleHeader, MessageForwardedBundleHeaderContent, MessageForwardedBundleHeaderCount, MessageForwardedBundleHeaderLabel, MessageForwardedBundleItem, MessageForwardedBundleItemAuthor, MessageForwardedBundleItemContent, MessageForwardedBundleItemMeta

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.

MessageForwardedBundleItems

The items surface. Without a `collapsed` prop the fold is component-owned: the surface measures its item-content slots and collapses itself to `foldLineLimit` lines when the text renders beyond that many lines in total (eight by default). Passing `collapsed` switches to the controlled mode (the detail view pins everything open) and skips the measurement.
Prop类型默认值
collapsedboolean
foldLineLimitHow many rendered text lines the default fold allows before folding. Only used in the component-owned mode (`collapsed` omitted).numberFOLD_LINE_LIMIT
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.

MessageForwardedBundleSource, MessageForwardedBundleSourceLabel

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.

MessageForwardedBundleFooterAction

Prop类型默认值
expandedContentWhat the action shows while the component-owned fold is expanded (`children` render while it is folded). Ignored in the controlled mode, where the consumer drives and labels the fold itself.ReactNode
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.3.0 · Breaking ChangesRenamed MessageForwardedBundleToggle to MessageForwardedBundleFooterAction, including its props type and data-slot.