MessageAttachment

Message-row attachment cards, media galleries, and pending/failed states composed as attachment children.

Preview#

AP
App Plannergpt-4.13:04 PM
Here is the source parity pass for #222. Mention chip, channel link, task link, and markdown are rendered by the caller.
This video may use a codec this browser cannot preview.
migration.diff2 files · 5 hunks+42-718 KB
screening.html44 KB
message-preview.wav4 KB
release-notes.md61 KB
metrics.csv24 rows · 6 columns1 KB
archive.zip12 KB
#2226 replies3 new

The card owns the shared title, summary, and two-sided metadata structure. Comment and diff content are alternative children of the same summary slot.

import {
  MessageAttachmentAction,
  MessageAttachmentCard,
  MessageAttachmentCommentSummary,
  MessageAttachmentDiffAddition,
  MessageAttachmentDiffDeletion,
  MessageAttachmentDiffSummary,
  MessageAttachmentGroup,
  MessageAttachmentMeta,
  MessageAttachmentMetaEnd,
  MessageAttachmentMetaStart,
  MessageAttachmentSummary,
  MessageAttachmentTitle,
  MessageItemAttachments,
} from "raft-ui";

<MessageItemAttachments>
  <MessageAttachmentGroup>
    <MessageAttachmentCard>
      <MessageAttachmentTitle />
      <MessageAttachmentSummary render={<MessageAttachmentCommentSummary />} />
      <MessageAttachmentMeta>
        <MessageAttachmentMetaStart />
        <MessageAttachmentMetaEnd>
          <MessageAttachmentAction />
        </MessageAttachmentMetaEnd>
      </MessageAttachmentMeta>
    </MessageAttachmentCard>
  </MessageAttachmentGroup>
</MessageItemAttachments>

<MessageAttachmentSummary render={<MessageAttachmentDiffSummary />}>
  <MessageAttachmentDiffAddition />
  <MessageAttachmentDiffDeletion />
</MessageAttachmentSummary>

Resolved media, loading fallback, and failure fallback are separate compositions.

import {
  MessageVideoPreview,
  MessageVideoPreviewAction,
  MessageVideoPreviewFailureAction,
  MessageVideoPreviewFailureContent,
  MessageVideoPreviewFailureIcon,
  MessageVideoPreviewFailureTitle,
  MessageVideoPreviewFallback,
  MessageVideoPreviewMedia,
  Spinner,
} from "raft-ui";

<MessageVideoPreview>
  <MessageVideoPreviewMedia />
  <MessageVideoPreviewAction />
</MessageVideoPreview>

<MessageVideoPreview aria-busy>
  <MessageVideoPreviewFallback>
    <Spinner />
  </MessageVideoPreviewFallback>
</MessageVideoPreview>

<MessageVideoPreview>
  <MessageVideoPreviewFallback>
    <MessageVideoPreviewFailureContent>
      <MessageVideoPreviewFailureIcon />
      <MessageVideoPreviewFailureTitle />
      <MessageVideoPreviewFailureAction />
    </MessageVideoPreviewFailureContent>
  </MessageVideoPreviewFallback>
</MessageVideoPreview>

Put attachment-specific diff content inside the shared summary slot. Keep file size and the caller-owned download action on opposite sides of the metadata row.

migration.diff2 files · 5 hunks+42-718 KB

Keep preview state in the consumer; replace the Eye with the shared Spinner inside MessageAttachmentMetaEnd while the preview opens.

screening.html44 KB

Use the summary only when a document has compact status information, such as CSV row and column counts. Metadata stays reserved for the file size.

metrics.csv24 rows · 6 columns1 KB
release-notes.md1 KB
screening.html44 KB
architecture.pdf1.2 MB

Title icon#

Render an SVG directly beside the filename inside the title slot; the attachment UI does not need a file-type prop or an icon slot.File-type icons are available from Icônes.

architecture.pdf1.2 MB

Put comment content inside MessageAttachmentSummary. For pending state, place the shared Spinner in MessageAttachmentMetaEnd instead of introducing a card-level variant.

release-notes.md61 KB
metrics.csv1 KB

Render real media, URL loading, and unavailable-codec fallback as separate video states. Preview and download workflows remain caller-owned.

This video may use a codec this browser cannot preview.

Compose native grid rows in the consumer. MessageImageGalleryItem owns cell chrome; MessageImageGalleryMedia only provides the media container.

Consumer layout classes set cell geometry, while the media child chooses object-cover or object-contain.

buildMessageImageGalleryRows turns each attachment's width/height into rows: wide images take a row of their own, the others fill rows of three (a lone four splits two-and-two), and every cell carries whether it crops or stays fully visible. The row and cell components turn that data into styles, so consumer code carries no layout classes.

API#WIP

...props
MessageAttachmentGroupProps
Horizontal group of attachment cards inside MessageItemAttachments.
...props
MessageAttachmentCardProps
Attachment card root.
...props
MessageAttachmentTitleProps
Filename slot at the start of MessageAttachmentCard.
...props
MessageAttachmentSummaryProps
Shared summary row. Owns layout, icon sizing, placement, and typography; compose a semantic summary through render.
...props
MessageAttachmentCommentSummaryProps
Comment-summary semantics composed onto MessageAttachmentSummary. Owns only its compact gap and muted color.
...props
MessageAttachmentDiffSummaryProps
Diff-summary semantics composed onto MessageAttachmentSummary. Owns only its internal gap.
...props
MessageAttachmentDiffAdditionProps
Semantic positive-diff value inside MessageAttachmentDiffSummary.
...props
MessageAttachmentDiffDeletionProps
Semantic negative-diff value inside MessageAttachmentDiffSummary.
...props
MessageAttachmentMetaProps
Two-sided metadata row inside MessageAttachmentCard.
...props
MessageAttachmentMetaStartProps
Start-side metadata region, typically file size.
...props
MessageAttachmentMetaEndProps
End-side metadata region for actions or a pending spinner.
...props
MessageAttachmentActionProps
Caller-owned preview or download action inside MessageAttachmentMetaEnd.
...props
MessageVideoPreviewProps
Inline video attachment root.
...props
MessageVideoPreviewMediaProps
Native video media element for a resolved URL.
...props
MessageVideoPreviewFallbackProps
Fallback region for consumer-owned URL loading or unavailable-media content. Render instead of MessageVideoPreviewMedia.
...props
MessageVideoPreviewActionProps
Top-right caller-owned preview action inside MessageVideoPreview.
...props
MessageVideoPreviewFailureContentProps
Structured unavailable-codec fallback content.
...props
MessageVideoPreviewFailureIconProps
Warning-icon slot inside failure content.
...props
MessageVideoPreviewFailureTitleProps
Failure copy slot inside failure content.
...props
MessageVideoPreviewFailureActionProps
Download button inside failure content; callers provide its icon, copy, and workflow.