组件 · 文件
FilesPanel
The list of files shared in a place, one row per file with its type, name, size and time, which opens a preview and offers Jump to Message and Download.
import { FilesPanel } from "@botiverse/raft-ui";The files panel lists the files shared in a place, such as #launch-week, newest first. Each row shows the file's type, its name, its size and when it was shared; clicking the row opens a preview, and two icon buttons jump to the message it came with and download it. It fills a side panel or a tab of a channel.
When to use
| Situation | Use |
|---|---|
| All the files shared in a channel or conversation | FilesPanel |
| A file attached to one message | The file card (MessageAttachment) |
| A file in the composer, before it is sent | FilePreview, in the Composer |
| An image or video opened from a row | Lightbox |
Where the files of a place sit on a screen (a tab, a side panel or the channel details) is in Navigation and Page structure.
Anatomy
FilesPanel: asectiononlayer-canvasthat fills its column. Required.FilesViewport: the scroll container. Required.FilesList: the column of rows, 8px apart.FileRow: one file, onlayer-cardwith aline-hairlineoutline andradius-container.FileRowOpen: the button that covers the type, name and details and opens the preview.FileThumbnail: a 36px box for the file's FilePreview, or a thumbnail throughFileImage.FileContent:FileName, thenFileMetawith oneFileMetaItemper detail (size, time), intext-mono-metaandforeground-hint.
FileActions: the row'sFileActionicon buttons, ghost by default.
Variants
The file's type changes only its icon: a document, code, an archive or other file, or a thumbnail of an image or video (FilePreview).
States
How empty, loading and failed differ is in Feedback.
- Empty: an EmptyState in the viewport, with a paperclip icon, No files yet, and where files come from.
- Loading: a skeleton of rows, the same size as the rows that replace it.
- Failed: the error at the panel's scope, with Retry, not an empty state.
- More to load: the next page loads as people near the end of the list. A Load More button below the last row covers the case where scrolling can't trigger it.
- Menu open: while a menu opened from one of its
FileActions is up, the row laysfill-subtleover itself, the same subtle tier as its hover, so the file the menu acts on stays marked (Hover and press). - Not available: disable a
FileActionorFileRowOpenwhose action isn't available.
Content
- Show the file name as it was uploaded, with its extension. A long name is cut off at the end of the row.
- Give the size with its unit (184 KB) and the time as people read it elsewhere (Yesterday, 4:18 PM).
Accessibility
FilesPanel adds no Base UI primitive; its parts are a section, buttons and an image.
- Name
FilesPanelwitharia-label: Files. - Give every
FileActionanaria-labeland a tooltip that say what it does: Jump to Original Message, Download File. FileRowOpenis named by the file name inside it. The type drawing is decorative (FilePreview).- Give a thumbnail in
FileImagean emptyalt: the name beside it already says what the file is.
Rules
- Make the whole row the target for the preview, and keep the actions outside
FileRowOpenso each is its own button. - Keep
FileActionat its default, a ghost 32px icon button, so the row stays quiet (Button). - Don't color a row by its file type (FilePreview).
API
FilesPanel, FilesViewport, FilesList, FileRow, FileRowOpen, FileThumbnail
| 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.
FileImage
| Prop | 类型 | 默认值 |
|---|---|---|
| "contain" | "cover" | "cover" | |
| 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.
FileContent, FileName, FileMeta, FileMetaItem, FileActions
| 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.
FileAction
| Prop | 类型 | 默认值 |
|---|---|---|
| boolean | ||
| string | ||
| `md` (32px) and `icon-md` for rows, cards, banners, toolbars and panel headers; `lg` and `icon-lg` (the control height) for dialog footers, forms and beside a field; `xl` for a full-width call to action. The size follows the place: see Button › Size by place. | "md" | "lg" | "xl" | "icon-md" | "icon-lg" | DeprecatedButtonSize | "icon-md" |
| "primary" | "accent" | "warning" | "danger" | "default" | "outline" | "information" | "muted" | "success" | "danger-secondary" | "danger-outline" | "ghost" | "on-frame" | ||
| Whether the button should be focusable when disabled. | boolean | false |
| Whether the component renders a native `<button>` element when replacing it via the `render` prop. Set to `false` if the rendered element is not a button (for example, `<div>`). | boolean | true |
| 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.9.5 · FixedOn a touch screen, a tap no longer leaves a hover highlight on:
TableBodyrows, anInboxItem's pressed toggle action, the Activity inbox sort button and aFileRow(when itsFileRowOpenis hovered) now only show their hover on devices that can hover. With a mouse they look and behave as before.