Timeline
イベントを新しい順に並べる一覧。時刻、タイトル、本文、補足を持つ。
tsx
import { Timeline } from "knowidea-ui";カテゴリ: Data display。同じカテゴリ: Avatar、Badge、Chip、Status、Stat、Table、List、Tooltip、Popover、CodeBlock、Kbd、Quote、Display、Jacket、Conversation、CodeEditor、DiffView
Demos
デモの数値はすべてサンプルであり、実際の値ではない。
Basic
tone でマークの色を変える。リンクがある行は、行全体がクリック領域になる。
更新 設定を 3 件変更した
停止 検査を停止した
Show code
tsx
import { Timeline, type TimelineEntry } from "knowidea-ui";const items: TimelineEntry[] = [ { id: "1", time: "10/13 09:28", title: "公開", text: "新しいバージョンを公開した", icon: "broadcast", tone: "success", href: "#1", meta: "公開担当" }, { id: "2", time: "10/13 08:10", title: "更新", text: "設定を 3 件変更した", icon: "edit", meta: "設定担当" }, { id: "3", time: "10/12 18:02", title: "停止", text: "検査を停止した", icon: "stopped", tone: "error" },];function Basic() { return <div style={{ width: "100%" }}><Timeline items={items} /></div>;}States
すべてのコンポーネントが、Empty、Loading、Error、Disabled、Focus の 5 つの状態を備える。Hover と Active は、確認用に固定して表示している。そのコンポーネントにあてはまらない状態は「対象外」とし、理由を添える。
| State | Appearance |
|---|---|
| Empty | まだイベントはない |
| Loading |
|
| Error | イベントを取得できなかった。 |
| Disabled | 対象外。イベントの履歴は書き換えない。無効の行を持たない |
| Focus | リンクのある行では、リンクにフォーカスが移る(リングは 2px)。上のデモを Tab で確認する |
API
| Name | Type | Default | Description |
|---|---|---|---|
items | TimelineEntry[] | - | { id, time, title, text, icon?, tone?, href?, meta? } |
state | "ready" | "loading" | "empty" | "error" | "ready" | 状態 |
emptyText / errorText / loadingText | string | - | 各状態のメッセージ |
CSS
Classes and data attributes
| Name | Description |
|---|---|
.ki-timeline | 一覧 |
.ki-timeline__item | 行。data-tone: success | warn | error | info |
.ki-timeline__icon、__body、__text、__title、__meta | 内部の要素 |
CSS variables
コンポーネントが参照するのは、役割を表す名前の変数だけで、素の値は参照しない。オーバーライドの方法は Overriding を参照。
| Variable | Usage |
|---|---|
| --color-success、--color-warn、--color-error、--color-info | マークの色 |
| --color-text-muted | 時刻と補足の文字色 |
| --font-mono | 時刻のフォント |
Accessibility
- <ul> で描画し、時刻には <time> を使う
- マークの色は意味を補うだけにする。何が起きたかはタイトルの文字で伝える