组件 · 消息
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.
When to use
| Situation | Use |
|---|---|
| One or more messages passed on from another conversation | MessageForwardedBundle |
| A link to one message, shown as an excerpt | MessageQuotedPreview |
| A link to a message or a channel, inline in the text | A reference chip (MessageItem) |
| A quote typed into the message | A Markdown blockquote (MessageItem) |
Anatomy
MessageForwardedBundle: the card. Required.MessageForwardedBundleHeader: the top row; it wraps on a narrow column. Required.MessageForwardedBundleHeaderContent, withMessageForwardedBundleHeaderLabel(an icon and Forwarded) andMessageForwardedBundleHeaderCount(in Space Mono,foreground-hint).- The source, at the end of the row:
MessageForwardedBundleSourcewhen it can be opened,MessageForwardedBundleSourceLabelwhen 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:MessageForwardedBundleAttachmentchips (MessageForwardedBundleAttachmentName,MessageForwardedBundleAttachmentMeta), andMessageForwardedBundleGallerywith aMessageForwardedBundleGalleryTileper image. Optional.
MessageForwardedBundleFooterwithMessageForwardedBundleFooterAction: the action that unfolds the list. Optional.
Variants
| Variant | Use for |
|---|---|
| A few short messages | The common case: shown in full, with no footer |
| Long content | Text 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 |
fullWidth | A place where the card fills the column instead of keeping its maximum width |
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
foldLineLimitlines (8), the list is cut at that height and fades out at the bottom intolayer-card. - The footer shows only while the list is folded. Its action unfolds the list and folds it again;
expandedContentis 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
collapsedtoMessageForwardedBundleItemsto 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
preventDefaultin itsonClick. MessageForwardedBundleGallerylays 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; eachMessageForwardedBundleItemis an<article>. MessageForwardedBundleSourceis a<button>. When it navigates, render it as an<a>with anaria-labelthat names the place: "Open source thread in #launch-week".- While the bundle owns the fold,
MessageForwardedBundleFooterActionsetsaria-expanded. Withcollapsed, set it yourself. - Put each item's time in a
<time>element with itsdateTime. interactiveonMessageForwardedBundleAttachmentonly adds the hover and focus look. Render the chip as a<button>or<a>that opens the file, with anaria-labelsuch as "Open release-notes.md".- Give gallery images an
altas 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 | 类型 | 默认值 |
|---|---|---|
| boolean | false | |
| Allows 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 | 类型 | 默认值 |
|---|---|---|
| Marks the attachment as actionable (the consumer wires the open action on `render`). Adds the pointer/hover/focus affordance to the chip. | boolean | false |
| Allows 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 | 类型 | 默认值 |
|---|---|---|
| Allows 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 | 类型 | 默认值 |
|---|---|---|
| boolean | ||
| How many rendered text lines the default fold allows before folding. Only used in the component-owned mode (`collapsed` omitted). | number | FOLD_LINE_LIMIT |
| Allows 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 | 类型 | 默认值 |
|---|---|---|
| Allows 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 | 类型 | 默认值 |
|---|---|---|
| What 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 | |
| Allows 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
MessageForwardedBundleToggletoMessageForwardedBundleFooterAction, including its props type anddata-slot.