@storybook/react

2020-01-13

@storybook/react

Storybook for React: Develop React Component in isolation with Hot Reloading.

Storybook

Build bulletproof UI components faster

Build Status on CircleCICodeFactorKnown VulnerabilitiescodecovLicenseStorybook SlackBackers on Open CollectiveSponsors on Open CollectiveOfficial Twitter Handle

Storybook is a development environment for UI components. It allows you to browse a component library, view the different states of each component, and interactively develop and test components.

View README for: latestnext

Intro

Storybook runs outside of your app. This allows you to develop UI components in isolation, which can improve component reuse, testability, and development speed. You can build quickly without having to worry about application-specific dependencies.

Here are some featured examples that you can reference to see how Storybook works: https://storybook.js.org/examples/

Storybook comes with a lot of addonsfor component design, documentation, testing, interactivity, and so on. Storybook's API makes it possible to configure and extend in various ways. It has even been extended to support React Native development for mobile.

Table of contents

  • <g-emoji class="g-emoji" alias="rocket" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f680.png">🚀</g-emoji>Getting Started
  • <g-emoji class="g-emoji" alias="ledger" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f4d2.png">📒</g-emoji>Projects
    • <g-emoji class="g-emoji" alias="hammer_and_wrench" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f6e0.png">🛠</g-emoji>Supported Frameworks & Examples
    • <g-emoji class="g-emoji" alias="metro" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f687.png">🚇</g-emoji>Sub Projects
    • <g-emoji class="g-emoji" alias="link" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f517.png">🔗</g-emoji>Addons
  • <g-emoji class="g-emoji" alias="medal_sports" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f3c5.png">🏅</g-emoji>Badges & Presentation materials
  • <g-emoji class="g-emoji" alias="busts_in_silhouette" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f465.png">👥</g-emoji>Community
  • <g-emoji class="g-emoji" alias="clap" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f44f.png">👏</g-emoji>Contributing
    • <g-emoji class="g-emoji" alias="man_technologist" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f468-1f4bb.png">👨‍💻</g-emoji>Development scripts
    • <g-emoji class="g-emoji" alias="dollar" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f4b5.png">💵</g-emoji>Backers
    • <g-emoji class="g-emoji" alias="money_with_wings" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f4b8.png">💸</g-emoji>Sponsors
  • <g-emoji class="g-emoji" alias="memo" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f4dd.png">📝</g-emoji>License

Getting Started

First install storybook:

cd my-react-app
npx -p @storybook/cli sb init

If you'd rather set up your project manually, take a look at our Slow Start Guide.

Once it's installed, you can npm run storybookand it will run the development server on your local machine, and give you a URL to browse some sample stories.

Storybook v2.x migration note: If you're using Storybook v2.x and want to shift to 4.x version the easiest way is:

cd my-storybook-v2-app
npx -p @storybook/cli sb init

It runs a codemod to update all package names. Read all migration details in our Migration Guide

For full documentation on using Storybook visit: storybook.js.org

For additional help, join us in our Discordor Slack

Projects

Supported Frameworks

FrameworkDemo
Reactv5.1.0React
React Native-React Native
Vuev5.1.0Vue
Angularv5.1.0Angular
Polymerv5.1.0Polymer
Mithrilv5.1.0Mithril
Markov5.1.0Marko
HTMLv5.1.0HTML
Sveltev5.1.0Svelte
Riotv5.1.0Riot
Emberv5.1.0Ember
Preactv5.1.0Preact

Sub Projects

  • CLI- Streamlined installation for a variety of app types
  • examples- Code examples to illustrate different Storybook use cases

Addons

Addons
a11yTest components for user accessibility in Storybook
actionsLog actions as users interact with components in the Storybook UI
backgroundsLet users choose backgrounds in the Storybook UI
centeredCenter the alignment of your components within the Storybook UI
contextsInteractively inject component contexts for stories in the Storybook UI
cssresourcesDynamically add/remove css resources to the component iframe
design assetsView images, videos, weblinks alongside your story
eventsInteractively fire events to components that respond to EventEmitter
graphqlQuery a GraphQL server within Storybook stories
google-analyticsReports google analytics on stories
infoAnnotate stories with extra component usage information
jestView the results of components' unit tests in Storybook
knobsInteractively edit component prop data in the Storybook UI
linksCreate links between stories
notesAnnotate Storybook stories with notes
optionsCustomize the Storybook UI in code
storyshotsSnapshot testing for components in Storybook
storysourceView the code of your stories within the Storybook UI
viewportChange display sizes and layouts for responsive components using Storybook

See Addon / Framework Support Table

Badges & Presentation materials

We have a badge! Link it to your live Storybook example.

Storybook

[![Storybook](https://cdn.jsdelivr.net/gh/storybookjs/brand@master/badge/badge-storybook.svg)](link to site)

If you're looking for material to use in your presentation about storybook, like logo's video material and the colors we use etc, you can find all of that at our brand repo.

Community

Contributing

We welcome contributions to Storybook!

  • <g-emoji class="g-emoji" alias="inbox_tray" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f4e5.png">📥</g-emoji> Pull requests and <g-emoji class="g-emoji" alias="star2" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f31f.png">🌟</g-emoji> Stars are always welcome.
  • Read our contributing guideto get started. or find us on Discord, we're will take the time to guide you

Looking for a first issue to tackle?

  • We tag issues with Good First Issuewhen we think they are well suited for people who are new to the codebase or OSS in general.
  • Talk to us, we'll find something to suits your skills and learning interest.

Development scripts

Storybook is organized as a monorepo using Lerna. Useful scripts include:

yarn bootstrap

Installs package dependencies and links packages together - using lerna

yarn run publish

Push a release to git and npm will ask for version in interactive mode - using lerna.

yarn lint

boolean check if code conforms to linting rules - uses remark & eslint

  • yarn lint:js- will check js

  • yarn lint:md- will check markdown + code samples

  • yarn lint:js --fix- will automatically fix js

yarn test

boolean check if unit tests all pass - uses jest

  • yarn run test --core --watch- will run core tests in watch-mode

Sponsors

Become a sponsor and get your logo on our README on Github with a link to your site. [Become a sponsor]

Backers

Support us with a monthly donation and help us continue our activities. [Become a backer]

License

MIT

-the end-

以上是 @storybook/react 的使用教程帮助文档。


上一篇:聊一聊 Node.js 错误处理
下一篇:@storybook/addons
相关教程
关注微信

扫码加入 JavaScript 社区

相关文章
暂无相关文章

首次访问,需要验证
微信扫码,关注即可
(仅需验证一次)

欢迎加入 JavaScript 社区

号内回复关键字:

回到顶部