Storybook
Storybook 是一个前端工作室,用于单独构建 UI 组件和页面。数以千计的团队使用它进行 UI 开发、测试和文档编制。它是开源且免费的。
更快地构建 UI 组件
Storybook 是一个前端工作室,用于单独构建 UI 组件和页面。数以千计的团队使用它进行 UI 开发、测试和文档编制。在https://storybook.js.org了解更多信息。
访问Storybook 的网站以了解有关 Storybook 的更多信息并开始使用。
可以在Storybook 的文档站点上找到文档。
查看Component Encyclopedia,了解领导团队如何使用 Storybook。
Storybook 带有许多用于组件设计、文档、测试、交互性等的插件。Storybook 的 API 使得以各种方式配置和扩展成为可能。它甚至已经扩展到支持 React Native、Android、iOS 和 Flutter 移动开发。
如需更多帮助,请加入我们的Storybook Discord。
Renderer | Demo | |
---|---|---|
? | TODO, the link below will break | |
React | ||
Vue | ||
Angular | ||
Web components | ||
React Native | - | |
HTML | ||
Ember | ||
Svelte | ||
Preact | ||
Marionette.js | - | |
Android, iOS, Flutter |
Addons | |
---|---|
a11y | Test components for user accessibility in Storybook |
actions | Log actions as users interact with components in the Storybook UI |
backgrounds | Let users choose backgrounds in the Storybook UI |
cssresources | Dynamically add/remove CSS resources to the component iframe |
design assets | View images, videos, and weblinks alongside your story |
docs | Add high quality documentation to your components |
events | Interactively fire events to components that respond to EventEmitter |
google-analytics | Reports google analytics on stories |
graphql | Query a GraphQL server within Storybook stories |
jest | View the results of components' unit tests in Storybook |
links | Create links between stories |
measure | Visually inspect the layout and box model within the Storybook UI |
outline | Visually debug the CSS layout and alignment within the Storybook UI |
query params | Mock query params |
storyshots | Snapshot testing for components in Storybook |
storysource | View the code of your stories within the Storybook UI |
viewport | Change display sizes and layouts for responsive components using Storybook |
请参阅插件/框架支持表
插件 | |
---|---|
语境 | 用于在动态上下文中驱动组件的插件 |
信息 | 使用额外的组件使用信息注释故事 |
旋钮 | 在 Storybook UI 中交互式编辑组件道具数据 |
笔记 | 用笔记注释 Storybook 故事 |
选项 | 在代码中自定义 Storybook UI |
为了继续改善您的体验,我们最终必须弃用某些插件以支持新的更好的工具。
如果您使用的是信息/注释,我们强烈建议您改用文档,这里有一份指南可以帮助您。
如果您正在使用上下文,我们强烈建议您迁移到工具栏,这里有一个指南可以帮助您。
我们有徽章!将它链接到您的实时 Storybook 示例。
[](link to site)
如果您正在寻找可在 Storybook 演示中使用的材料,例如徽标、视频材料和我们使用的颜色,您可以在我们的品牌库中找到所有这些材料。
始终欢迎对 Storybook 做出贡献!
寻找要解决的第一个问题?
Storybook 使用Lerna组织成一个单一的仓库。有用的脚本包括:
yarn start
运行带有测试故事的沙盒模板故事书
yarn task
如上所述,但为您提供自定义沙箱的选项(例如选择其他框架)
yarn lint
布尔值检查代码是否符合 linting 规则 - 使用 remark 和 eslint
yarn lint:js
- 将检查 jsyarn lint:md
- 将检查 markdown + 代码示例yarn lint:js --fix
- 会自动修复jsyarn test
布尔值检查单元测试是否全部通过 - 使用 jest
yarn run test --core --watch
- 将在监视模式下运行核心测试