用法
import { LandingHero } from './LandingHero.jsx'
// Your product in the phone: items with their own picture, reading and action, and the phone's words in one object.
// Or pass media={<img src="/app.png" alt="" />} to show your own picture instead of the phone.
<LandingHero
locale="en"
product="Bloom"
labels={{ eyebrow: 'New: brew timer', headline: ['Every cup dialled in,', 'brew after brew.'], lede: 'Bloom logs each brew and tells you what to change next.', note: 'Free for 30 brews a month.' }}
screen={{ needCare: (n) => n + ' brews to log', allHappy: 'All brews logged', streakIcon: 'cup', tabs: [{ icon: 'home', label: 'Today' }, { icon: 'cup', label: 'Brews' }, { icon: 'note', label: 'Notes' }, { icon: 'user', label: 'Me' }] }}
items={[
{ id: 'guji', name: 'Ethiopia Guji', detail: 'V60 · 15 g', icon: 'cup', reading: 'Extraction', level: 18, after: 21, max: 24, unit: '%',
action: { label: 'Log', icon: 'check', ask: 'Untasted', remind: 'Guji is waiting', done: 'Guji logged', after: 'Brew again tomorrow' } },
{ id: 'house', name: 'House espresso', detail: '18 g · 36 g out', image: '/beans/house.jpg', reading: 'Score', level: 86, status: 'Dialled in' },
]}
streak={12}
onSignUp={async (email) => (await fetch('/api/waitlist', { method: 'POST', body: email })).ok}
onAction={(id) => track('demo-action', { id })}
/>属性
| 属性 | 类型 | 默认值 | 作用 |
|---|---|---|---|
locale | 'en' | 'zh-CN' | 'es' | 'ja' | 'en' | 内置文字和示例植物的语言。 |
product | string | by locale | 产品名称,显示在手机旁的通知里,读屏时也会读出。 |
items | Array<{ id, name, detail?, image? | icon? | art?, reading?, level?, after?, max?, unit?, status?, action?: { label, icon?, ask?, remind?, done?, after? } }> | sample plants | 手机里列出的条目。用 `image`(图片地址)、`icon`(kit 图标名或元素)或 `art` 画出它;`level` 填充圆环(满值 `max`,单位 `unit`)。带 `action` 的条目显示该按钮,按下后圆环变到 `after`;`remind`、`done`、`after` 是手机旁通知的文字,`ask` 显示在圆环下。 |
screen | { today?, needCare?(n), allHappy?, fine?, streakIcon?, streakLabel?(n), allNote?(n), allSaid?(n), tabs?: Array<string | { icon, label }> } | — | 手机界面自己的文字和图标,集中在一个对象里,覆盖内置的(键名见 copy.js)。 |
media | ReactNode | ({ product, locale }) => ReactNode | — | 替代手机画面显示:截图、视频或你自己的组件。 |
plants | Array<{ id, name, room, art: 'monstera' | 'fern' | 'snake', measure: 'moisture' | 'humidity', level, after?, need?: 'water' | 'mist', next? }> | — | 已弃用:示例数据的旧条目格式,未传 `items` 时仍然可用。 |
streak | number | 12 | 连续照顾的天数;所有植物都照顾好后会加一。 |
status | 'idle' | 'sending' | 'done' | 'error' | 'idle' | 让登记表单以指定状态打开,例如你自己的请求正在进行时。 |
onSignUp | (email) => Promise<boolean | void> | — | 登记邮箱。返回 false 或抛出错误会显示出错提示,其余情况显示登记成功。 |
onAction | (id, item) => void | — | 访客试用了产品:在手机里按下某个条目的操作按钮时调用。 |
onCare | (id, need) => void | — | 已弃用:同 onAction,参数是示例里的需求(浇水或喷雾)。 |
labels | object | — | 替换任意内置文字(键名见 copy.js)。 |
className | string | — | 加在根元素 section 上。 |
装进你的项目
把指令粘贴给 Codex 或 Claude Code。Agent 会读取公开的源码,先告诉你要写入哪些文件,再把区块连同它用到的组件一起加进项目。
LandingHero.jsxlanding-hero.csscopy.jskit.jsxkit.cssui/base-button/ui/rolling-number/ui/success-check/ui/text-input/ui/progress-ring/tokens.cssREADME.md
区块本身、样式和文案、共用的 kit、用到的组件和 tokens.css 会一起装进同一个文件夹。