import type { Meta, StoryFn } from '@storybook/react'
import React from 'react'
import {
StoryGrid,
StoryHeading,
StoryPage,
StoryRow,
} from '../stories/StoryTable'
import type { FileItem } from '../types'
import FileAttachment from '.'
const FILE_SRC = 'https://www.w3.org/WAI/WCAG21/wcag21.pdf'
const STACK_FILES: FileItem[] = [
{
src: FILE_SRC,
filename: 'workout-plan.zip',
mimeType: 'application/zip',
fileSize: 2_457_600,
},
{
src: FILE_SRC,
filename: 'Q4-revenue.xlsx',
mimeType:
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
fileSize: 146_432,
},
{
src: FILE_SRC,
filename: 'brand-guidelines-2026.zip',
mimeType: 'application/zip',
fileSize: 11_500_000,
},
{
src: FILE_SRC,
filename: 'meeting-notes.docx',
mimeType:
'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
fileSize: 28_672,
},
]
const meta: Meta = {
title: 'MessageAttachment/File',
parameters: { layout: 'fullscreen' },
}
export default meta
const handleDismiss = () => {
console.log('Dismissed file attachment')
}
/**
* Compact file row inside a chat bubble — typed icon + filename +
* `EXT · SIZE` — with a download icon in the trailing slot. Clicking
* any state (Composer / Sent / Received) downloads the asset.
*/
export const Single: StoryFn = () => (
}
sent={
}
received={
}
/>
}
sent={
}
received={
}
/>
}
sent={
}
received={
}
/>
)
export const SingleWithText: StoryFn = () => (
}
sent={
}
received={
}
/>
)
/**
* Stacked file attachments — multiple files inside one bubble. Each
* row has its own download trigger, and rows are separated by an 8px
* gap to match stacked PDF / Audio.
*
* Sent + Received only — the composer surface accepts a single
* attachment at a time.
*/
export const Stacked: StoryFn = () => (
}
sent={}
received={}
/>
}
sent={}
received={}
/>
}
sent={}
received={}
/>
)
/**
* Bubble grouping — mirrors the corner-flattening stream-chat-react
* applies to text bubbles in a same-author run. The four positions
* (`single` / `first` / `middle` / `end`) flatten the corners that
* face the previous / next bubble in the cluster, so a `MessageAttachment`
* sitting inside a thread visually merges with the surrounding text
* bubbles instead of floating as its own ungrouped pill.
*
* Stack the four positions vertically with `gap-[2px]` to see them
* snap into a single visual run — the same gap stream uses between
* grouped messages.
*/
export const Grouping: StoryFn = () => (
}
received={
}
/>
}
received={
}
/>
)
/** Stacked files with an accompanying caption.
* Sent + Received only — see `Stacked` for the rationale. */
export const StackedWithText: StoryFn = () => (
}
received={
}
/>
}
received={
}
/>
)