「ワークベンチ」は Pro に含まれます。解除するとプレビューが表示されます。
使い方
import { Workbench } from './Workbench.jsx'
<Workbench
locale="en"
name={user.firstName}
hour={new Date().getHours()}
todos={tasks.list} // [{ id, title, when?, late?, done? }]
shortcuts={[{ label: 'New roast', icon: 'plus' }, { label: 'Log a brew', icon: 'cup' }]}
agenda={[{ time: '10:00', title: 'Cupping session', where: 'Lab · 45 min' }]}
numbers={[{ label: 'Bags sold', value: '312', change: '8%', trend: 'up' }]}
recent={[{ kind: 'roast', icon: 'cup', title: 'Ethiopia Guji', meta: 'Roast · 10 min ago', href: '/roasts/guji' }]}
loading={tasks.loading}
error={tasks.error}
onRetry={tasks.reload}
onToggle={(id, done) => tasks.update(id, { done })}
onShortcut={(index) => router.push(['/projects/new', '/invoices/new', '/time', '/files'][index])}
onOpen={(item) => router.push(item.href)}
/>プロパティ
| プロパティ | 型 | 既定値 | 説明 |
|---|---|---|---|
locale | 'en' | 'zh-CN' | 'es' | 'ja' | 'en' | 組み込みの文言とサンプルデータの言語。 |
name / hour | string / number | 'Mia' / 9 | あいさつする相手と、朝・昼・夜を決める時刻(サーバーとブラウザで揃えるために渡します)。 |
todos | Array<{ id, title, when?, late?, done? }> | — | やること。未完了がなければ、すべて完了と、新しいタスクがどこから来るかを伝えます。 |
date | string | by locale | あいさつの上の日付(整形済みの文字列)。 |
shortcuts | Array<string | { label, icon? }> | 4 sample shortcuts | ショートカットのボタン。`onShortcut` には番号が渡ります。アイコンは kit のアイコン名。 |
agenda | Array<{ time, title, where }> | sample agenda | 今日の予定カード。 |
numbers | Array<{ label, value, change, trend: 'up' | 'down' }> | sample numbers | 今週の数字。値は渡した文字のまま表示されます。 |
recent | Array<{ kind, title, meta, icon? }> | sample records | 最近開いたレコード。`onOpen` にはその項目が渡ります。 |
loading / error | boolean | — | 読み込み中はプレースホルダー、失敗時はメッセージと再試行(onRetry)。 |
onToggle / onShortcut / onOpen | (id, done) => void / (index) => void / (item) => void | — | やることのチェックを切り替えたとき/ショートカットを押したとき/最近の項目を開いたとき。 |
labels | object | — | 組み込みの文言を置き換えます(キーは copy.js と同じ)。 |
プロジェクトに追加
Pro にはこのブロックのソース一式が含まれます。指示をコピーしてエージェントに導入を依頼できます。
Workbench.jsxworkbench.csscopy.jskit.jsxkit.cssui/base-button/ui/alert-banner/ui/checkbox/ui/skeleton-shimmer/tokens.cssREADME.md
ブロック本体、スタイルと文言、共通の kit、使っているコンポーネント、tokens.css が 1 つのフォルダにまとめて入ります。
