组件 · 任务
Tasks
The parts every task view shares — the status badge and task chip that show where a task is, the status pixels, and the shell of a task panel.
import { Tasks } from "@botiverse/raft-ui";These are the parts every task view shares. TaskStatusBadge writes a task's status as a status chip: the status's soft tint, its pixel and its name. TaskChip is the same chip carrying a task instead: the task marker under a message, or a task mentioned in running text. TasksPanelRoot and its parts are the shell of a page of tasks. The five statuses and how tasks are shown are in Tasks; their colors are in Color.
When to use
| Situation | Use |
|---|---|
| A task's status: on a card, in properties, in details | TaskStatusBadge |
| A task under a message | TaskChip in the message footer (MessageItem) |
| A task mentioned in running text | TaskChip with variant="inline" |
| A task's status as a pixel beside a word | TaskStatusIcon |
| A page or a tab of tasks | TasksPanelRoot with its toolbar and viewport |
| A task as a row on a board or in a list | TaskCard |
| How an agent is | An agent state chip (Status) |
Anatomy
TaskStatusBadge: aTaskChipwith the status pixel and the status name, which the caller supplies.TaskChip: the chip.statussets its tint. Its children are a status icon, then the task number, then the assignee.TaskStatusIcon, andTaskTodoIcon,TaskInProgressIcon,TaskInReviewIcon,TaskDoneIcon,TaskClosedIcon: the status pixel.TasksPanelRoot: the column of a task page.TasksPanelToolbar: the bar on top, with a seam under it. It holdsTasksPanelToolbarNewTask,TasksPanelToolbarFiltersandTasksPanelToolbarView(Board / List), and lays them out for narrow screens.TasksPanelToolbarGroupandTasksPanelToolbarLabelare for anything else in it.TasksPanelViewport: the scrolling content: a TaskBoard or a TaskList.TasksPanelEmpty: holds an EmptyState when there are no tasks.
TaskLoadingList,TaskLoadingRow: placeholder rows while tasks load.taskStatusSoft,taskStatusStrongandTASK_STATUS_IDS: the recipes for building another status surface from the sametask-status-*tokens.
Variants
| Variant | Use for |
|---|---|
variant="default" | A chip on its own: under a message, on a card, in a details row |
variant="inline" | A chip in running text; it follows the size of the text around it |
size="sm" | A default chip in one row with small badges, such as the metadata row of an Activity item |
States
- Loading:
loadingdims aTaskChipand ignores the pointer while the task is resolved. - The panel is loading:
TaskLoadingList, the same size as the cards it stands for (Feedback). - No tasks:
TasksPanelEmpty, with one empty state when there are no tasks and another when the filters match none. - Failed to load: an error at the panel's scope, with Retry.
Behavior
- Make a status chip on a task card a button that opens the list of statuses, with a down arrow after the name (TaskCard). The other ways to change a status are in Tasks.
- Make the task marker under a message open the task.
Content
- Spell the statuses Todo, In Progress, In Review, Done and Closed.
TaskStatusBadgehas no built-in label: the caller passes it, and translates it. - Set the task number in Space Mono:
#25(Typography). - In a task marker, write the number, then the assignee:
#25@Bugen.
Accessibility
None of these parts wraps a Base UI primitive; TaskChip renders a <span> unless render makes it a link or a button.
- The status pixel is hidden from assistive technology. Always pass the status name, or keep the task number next to it.
- Render a task marker that opens the task as an
<a>or a<button>, and give it anaria-labelthat says what it opens ("Open task #25") when its text doesn't. Atitleis not an accessible name.
Rules
- Build any new surface that shows a task status from
taskStatusSoftandtaskStatusStrong, so a status has one color everywhere. - Don't give a chip a border: the tint is a highlight, not a sticker (Status).
- A chip splits its padding evenly between its two ends: 7px each, 5px when
sm, 4.5px inline, the same total as before. The status pixel is drawn to its edges, so the space before it is all padding; with 2px less on that end, the pixel sat 6px from the edge and the last letter 8.5px (Alignment).
API
TasksPanelEmpty, TasksPanelRoot, TasksPanelToolbar, TasksPanelToolbarFilters, TasksPanelToolbarGroup, TasksPanelToolbarLabel, TasksPanelToolbarNewTask, TasksPanelToolbarView, TasksPanelViewport, TaskLoadingList, TaskLoadingRow
| 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.
TaskChip
| Prop | 类型 | 默认值 |
|---|---|---|
| boolean | false | |
| `sm` lines the chip up with an `sm` Badge in the same row. | TaskChipSize | "default" |
| TaskStatusId | ||
| TaskChipVariant | "default" | |
| 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.
TaskClosedIcon, TaskDoneIcon, TaskInProgressIcon, TaskInReviewIcon
接受其元素的全部属性。
TaskStatusIcon
| Prop | 类型 | 默认值 |
|---|---|---|
| TaskStatusId |
Also takes the attributes of its element.
TaskTodoIcon
接受其元素的全部属性。
TaskStatusBadge
| Prop | 类型 | 默认值 |
|---|---|---|
| Badge text. The caller owns the copy (and its localization); Raft never hardcodes a status label here. | ReactNode | |
| Same as `TaskChip`'s `size`: `sm` lines up with an `sm` Badge. | TaskChipSize | "default" |
| TaskStatusId | ||
| 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.5.58 · Fixed
TaskChip/TaskStatusBadgesize="sm"take thesmBadge's own box (padding, border, line height), so it no longer drifts from the Badge beside it. - 0.5.55 · Fixed
TaskChip/TaskStatusBadgesize="sm"now also match thesmBadge's font weight and letter spacing (Elegant 500 / 0.22px, Brutal 700), so the chip no longer reads as a different font beside the Badges in slock's Activity card row. The default size and the inline variant are unchanged. - 0.5.54 · Added
TaskChipandTaskStatusBadgetakesize="sm", which gives the chip thesmBadge's text size and height (Elegant 11px / 18px, Brutal 10px / 20px; icon 10px) for a chip that shares a row with Badges, such as slock's Activity card metadata row. The default size and the inline variant are unchanged. - 0.5.41 · Changed
TaskStatusBadgenow renders throughTaskChipand has no look of its own: a status badge in a task panel and the task chip under a message share one shape, size, border and colour and differ only in content (status icon + the caller's label). Visible change: in Elegant the badge goes from 12px to the chip's 13px with a hairline border and a 19px height; in Brutal from bold 12px at 20px tall to the chip's medium 13px at about 18px tall, so rows that carry it are about 2px shorter.data-slot="task-status-badge"anddata-statusare kept; no API change. - 0.5.39 · FixedBrutal
TaskStatusBadgedraws a 1px black keyline instead of 2px, matchingTaskChipandBadge;py-pxkeeps it exactly 20px tall, so surrounding layout does not move (Elegant unchanged). - 0.5.38 · Fixed
TaskChip'sinlinevariant no longer paints its own neutral fill and transparent border over the status styling: task references inside message bodies take the same per-status fill, border, text and icon colours as the task chip under a message (Elegant; Brutal unchanged; font size and baseline rules untouched). - 0.5.33 · Changed
Stepsmarkers take the task-status colours shared withTaskChip(--task-status-*), so each status has its own colour: finished = Done (green), in progress = In Progress (blue), failed = danger (red), and waiting is neutral grey (the Closed ink). Brutal: solid status fill, ink outline and ink text, as the BrutalTaskChip. Elegant: the status's soft wash, strong ink and a 35% hairline, as the ElegantTaskChip; waiting steps follow naive-ui with no fill and the ring, number and title in the disabled grey. - 0.5.31 · Fixed
TaskStatusBadgein Brutal is a square, hard-edged tag again (no radius, 2px black border, bold, 20px tall), matching the BrutalTaskChipandBadge. 0.5.30 rendered it as a rounded pill. Elegant is unchanged.