57

Storybook 4.0 is here

 5 years ago
source link: https://www.tuicool.com/articles/hit/YvMrqaB
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Storybook 4.0 is here!

Major updates to support new build tools and frameworks

ZNRfeqM.png!web

W elcome to the latest iteration of Storybook, the world’s favorite UI component workshop.

Storybook improves component development, testing, and documentation for React/React Native/Vue/Angular and more. It’s used by engineering powerhouses like Airbnb, Slack, Squarespace, and Lyft.

Storybook 4.0 (SB4) supports six new view layers and introduces improvements at every level:

  • View layers: Ember, MarkoJS, Mithril, HTML, Svelte, Riot
  • Build: Webpack 4, Babel 7
  • :iphone: Mobile: React Native, Mobile device view
  • :art: UI: Theming
  • ⚙️ Core: Story parameters

Our goal is to help every developer build bulletproof UI components. Regardless of framework or stack. Today we’re one step closer to that goal.

Read on for all the ways that SB4 will supercharge your component development experience.

Storybook supports six new view layers

yUR3euY.png!web

We’re thrilled to introduce six new view layers to Storybook’s ecosystem of UI component tools and best practices:

Storybook and its addons are view layer agnostic. This means every time someone adds a feature or fixes a bug it benefits every user no matter which framework they choose.

For example, Storybook for Angular dramatically improved Typescript support. React Native improvements will benefit the next-gen web UI. New view layers are great for everyone.

Faster builds with Webpack4 and Babel7

VRFFvi7.png!web

Storybook 4 gets significant performance improvements with upgrades to Webpack 4 and Babel 7 thanks toFilipp Riabchun. Storybook is now compatible with popular frontend tools like create-react-app 2 , Gatsby 2 , and Next 7 .

Webpack 4 and Babel 7 also contain hundreds of other improvements including WebAssembly support in Webpack 4; JS configuration, Typescript, JSX fragments in Babel 7.

If you’re upgrading from an old version, we walk you through step by step with our Storybook 4.0 migration guide .

“Yay the migration is done and everything is working great! Also noticed some crazy perf wins with this, tell everyone I said this is amazing!“ — Josh Callendar, Lyft

First-class support for React Native

nIbUzmA.gif
⚛️The new React Native device view

Storybook for React Native also gets a complete overhaul in 4.0.

Now it’s dead simple to distribute Storybook to your team’s mobile devices. It has everything you need to run Storybook as an app without needing to connect to a Storybook server.

New updates to @storybook/react-native improve how it integrates with your app. In addition, Storybook now has on-device UI for popular addons like knobs, notes, and backgrounds.

Gytis Vinclovas led the effort on React Native for Storybook 4.0. He documents the changes in detail in his post .

Theme Storybook to your liking

rI3uEv6.png!web
Dark theme for Storybook, available in 4.0

Developers now have precise control of Storybook’s appearance.Norbert de Langen introduced theming, which allows you to tweak styling to match your brand.

Storybook 4.0 includes a the “dark” theme to show off the possibilities. For theming instructions check out the docs .

Develop mobile webapps easier

yQzi63I.png!web
Storybook mobile view

Storybook 4 includes a dedicated mobile view thanks to Denzenin .

When a mobile device user agent is detected, Storybook shows its catalog of stories, the main component preview, and the addons panel in three separate tabs.

Check out a demo by browsing our official Storybook example on your phone, or setting a mobile user agent in your web browser’s dev tools and reloading the page.

Story parameters API

Users and addon authors now have a standard format to configure a story thanks to the new parameters API byTom Coleman.

For example, instead of using the clumsy withNotes decorator for each story:

storiesOf('My component', module)
  .add('story1', withNotes('some notes')(() => <Component ... />))
  .add('story2', withNotes('other notes')(() => <Component .../>))

You can annotate stories by passing an extra argument when you add a story:

// .storyook/config.js (global decorator, local also supported)
addDecorator(withNotes)
// Component.stories.js
storiesOf('My component', module)
  .add('story1', () => <Component />, { notes: 'some notes' })
  .add('story2', () => <Component />, { notes: 'other notes' })

All official Storybook addons were converted to use story parameters. For more information on how the new API works, please see the docs .

Upgrade to Storybook 4.0

Upgrade to Storybook 4.0 today — it only takes a minute.

If you’re new to Storybook, now’s the best time to get started. Storybook supports the most popular view layers and frontend technologies to help you create durable UI components. Check out the Storybook Tutorial for a step-by-step walkthrough of React/Angular/Vue. Or if you’d rather just jump in:

cd my-project
npx -p @storybook/cli sb init
yarn storybook

Get involved

Have questions or kudos? Say hi on Twitter , Discord , Github , Slack , or in the comments below. Please :clap: applaud this post and share to help more people discover it.

Stay up to date with Storybook news by signing up for the official mailing list:

Thanks to the community and sponsors

Storybook continues to be the most popular UI component explorer in the world. We recently passed 30k stars on Github, 1M monthly downloads on NPM, and 500 contributors.

Storybook’s Open Collective is gaining momentum. It receives monthly sponsorship from Facebook, Chromatic , Percy, Tipe, and Applitools. Algolia and Airbnb recently gave significant one-time contributions. Many invaluable backers from the community have also stepped up to help the project. The contributions go to hosting, swag for contributors, documentation, and promotion.

–With :heart: from the Storybook team

Thank you! <a href="https://github.com/a-tokyo" data-href="https://github.com/a-tokyo" rel="nofollow noopener" target="_blank">@a-tokyo</a> <a href="https://github.com/adekbadek" data-href="https://github.com/adekbadek" rel="nofollow noopener" target="_blank">@adekbadek</a> <a href="https://github.com/ailrun" data-href="https://github.com/ailrun" rel="nofollow noopener" target="_blank">@ailrun</a> <a href="https://github.com/alanhogan" data-href="https://github.com/alanhogan" rel="nofollow noopener" target="_blank">@alanhogan</a> <a href="https://github.com/andyo729" data-href="https://github.com/andyo729" rel="nofollow noopener" target="_blank">@andyo729</a> <a href="https://github.com/astrotim" data-href="https://github.com/astrotim" rel="nofollow noopener" target="_blank">@astrotim</a> <a href="https://github.com/bastienfp" data-href="https://github.com/bastienfp" rel="nofollow noopener" target="_blank">@bastienfp</a> <a href="https://github.com/bmson" data-href="https://github.com/bmson" rel="nofollow noopener" target="_blank">@bmson</a> <a href="https://github.com/br0ken-" data-href="https://github.com/br0ken-" rel="nofollow noopener" target="_blank">@br0ken-</a> <a href="https://github.com/brian-mcbride" data-href="https://github.com/brian-mcbride" rel="nofollow noopener" target="_blank">@brian-mcbride</a> <a href="https://github.com/brycemhammond" data-href="https://github.com/brycemhammond" rel="nofollow noopener" target="_blank">@brycemhammond</a> <a href="https://github.com/camel-floss" data-href="https://github.com/camel-floss" rel="nofollow noopener" target="_blank">@camel-floss</a> <a href="https://github.com/choznerol" data-href="https://github.com/choznerol" rel="nofollow noopener" target="_blank">@choznerol</a> <a href="https://github.com/clehnert-psl" data-href="https://github.com/clehnert-psl" rel="nofollow noopener" target="_blank">@clehnert-psl</a> <a href="https://github.com/cliedeman" data-href="https://github.com/cliedeman" rel="nofollow noopener" target="_blank">@cliedeman</a> <a href="https://github.com/connorholyday" data-href="https://github.com/connorholyday" rel="nofollow noopener" target="_blank">@connorholyday</a> <a href="https://github.com/cortopy" data-href="https://github.com/cortopy" rel="nofollow noopener" target="_blank">@cortopy</a> <a href="https://github.com/danielduan" data-href="https://github.com/danielduan" rel="nofollow noopener" target="_blank">@danielduan</a> <a href="https://github.com/denzenin" data-href="https://github.com/denzenin" rel="nofollow noopener" target="_blank">@denzenin</a> <a href="https://github.com/desfero" data-href="https://github.com/desfero" rel="nofollow noopener" target="_blank">@desfero</a> <a href="https://github.com/dimitrijemanic" data-href="https://github.com/dimitrijemanic" rel="nofollow noopener" target="_blank">@dimitrijemanic</a> <a href="https://github.com/dioxmio" data-href="https://github.com/dioxmio" rel="nofollow noopener" target="_blank">@dioxmio</a> <a href="https://github.com/do7be" data-href="https://github.com/do7be" rel="nofollow noopener" target="_blank">@do7be</a> <a href="https://github.com/domyen" data-href="https://github.com/domyen" rel="nofollow noopener" target="_blank">@domyen</a> <a href="https://github.com/donaldpipowitch" data-href="https://github.com/donaldpipowitch" rel="nofollow noopener" target="_blank">@donaldpipowitch</a> <a href="https://github.com/edward1224" data-href="https://github.com/edward1224" rel="nofollow noopener" target="_blank">@edward1224</a> <a href="https://github.com/ekhaled" data-href="https://github.com/ekhaled" rel="nofollow noopener" target="_blank">@ekhaled</a> <a href="https://github.com/elob" data-href="https://github.com/elob" rel="nofollow noopener" target="_blank">@elob</a> <a href="https://github.com/ewolfe" data-href="https://github.com/ewolfe" rel="nofollow noopener" target="_blank">@ewolfe</a> <a href="https://github.com/expe-lbenychou" data-href="https://github.com/expe-lbenychou" rel="nofollow noopener" target="_blank">@expe-lbenychou</a> <a href="https://github.com/faun" data-href="https://github.com/faun" rel="nofollow noopener" target="_blank">@faun</a> <a href="https://github.com/fibo" data-href="https://github.com/fibo" rel="nofollow noopener" target="_blank">@fibo</a> <a href="https://github.com/fran-worley" data-href="https://github.com/fran-worley" rel="nofollow noopener" target="_blank">@fran-worley</a> <a href="https://github.com/fvilers" data-href="https://github.com/fvilers" rel="nofollow noopener" target="_blank">@fvilers</a> <a href="https://github.com/gabrielcsapo" data-href="https://github.com/gabrielcsapo" rel="nofollow noopener" target="_blank">@gabrielcsapo</a> <a href="https://github.com/georgewl" data-href="https://github.com/georgewl" rel="nofollow noopener" target="_blank">@georgewl</a> <a href="https://github.com/glazy" data-href="https://github.com/glazy" rel="nofollow noopener" target="_blank">@glazy</a> <a href="https://github.com/gongreg" data-href="https://github.com/gongreg" rel="nofollow noopener" target="_blank">@gongreg</a> <a href="https://github.com/grimones" data-href="https://github.com/grimones" rel="nofollow noopener" target="_blank">@grimones</a> <a href="https://github.com/gromchen" data-href="https://github.com/gromchen" rel="nofollow noopener" target="_blank">@gromchen</a> <a href="https://github.com/hisapy" data-href="https://github.com/hisapy" rel="nofollow noopener" target="_blank">@hisapy</a> <a href="https://github.com/hypnosphi" data-href="https://github.com/hypnosphi" rel="nofollow noopener" target="_blank">@hypnosphi</a> <a href="https://github.com/ianvs" data-href="https://github.com/ianvs" rel="nofollow noopener" target="_blank">@ianvs</a> <a href="https://github.com/igor-dv" data-href="https://github.com/igor-dv" rel="nofollow noopener" target="_blank">@igor-dv</a> <a href="https://github.com/ikesyo" data-href="https://github.com/ikesyo" rel="nofollow noopener" target="_blank">@ikesyo</a> <a href="https://github.com/isoppp" data-href="https://github.com/isoppp" rel="nofollow noopener" target="_blank">@isoppp</a> <a href="https://github.com/j-kallunki" data-href="https://github.com/j-kallunki" rel="nofollow noopener" target="_blank">@j-kallunki</a> <a href="https://github.com/jalilarfaoui" data-href="https://github.com/jalilarfaoui" rel="nofollow noopener" target="_blank">@jalilarfaoui</a> <a href="https://github.com/jamesgorrie" data-href="https://github.com/jamesgorrie" rel="nofollow noopener" target="_blank">@jamesgorrie</a> <a href="https://github.com/jayphelps" data-href="https://github.com/jayphelps" rel="nofollow noopener" target="_blank">@jayphelps</a> <a href="https://github.com/jbaumgardt" data-href="https://github.com/jbaumgardt" rel="nofollow noopener" target="_blank">@jbaumgardt</a> <a href="https://github.com/jfsiii" data-href="https://github.com/jfsiii" rel="nofollow noopener" target="_blank">@jfsiii</a> <a href="https://github.com/jh3y" data-href="https://github.com/jh3y" rel="nofollow noopener" target="_blank">@jh3y</a> <a href="https://github.com/jhswart" data-href="https://github.com/jhswart" rel="nofollow noopener" target="_blank">@jhswart</a> <a href="https://github.com/jmiazga" data-href="https://github.com/jmiazga" rel="nofollow noopener" target="_blank">@jmiazga</a> <a href="https://github.com/jondot" data-href="https://github.com/jondot" rel="nofollow noopener" target="_blank">@jondot</a> <a href="https://github.com/juhq" data-href="https://github.com/juhq" rel="nofollow noopener" target="_blank">@juhq</a> <a href="https://github.com/keraito" data-href="https://github.com/keraito" rel="nofollow noopener" target="_blank">@keraito</a> <a href="https://github.com/klimentru1986" data-href="https://github.com/klimentru1986" rel="nofollow noopener" target="_blank">@klimentru1986</a> <a href="https://github.com/kroeder" data-href="https://github.com/kroeder" rel="nofollow noopener" target="_blank">@kroeder</a> <a href="https://github.com/kumarharsh" data-href="https://github.com/kumarharsh" rel="nofollow noopener" target="_blank">@kumarharsh</a> <a href="https://github.com/langri-sha" data-href="https://github.com/langri-sha" rel="nofollow noopener" target="_blank">@langri-sha</a> <a href="https://github.com/libetl" data-href="https://github.com/libetl" rel="nofollow noopener" target="_blank">@libetl</a> <a href="https://github.com/ljharb" data-href="https://github.com/ljharb" rel="nofollow noopener" target="_blank">@ljharb</a> <a href="https://github.com/lucidpaper" data-href="https://github.com/lucidpaper" rel="nofollow noopener" target="_blank">@lucidpaper</a> <a href="https://github.com/luisdanielroviracontreras" data-href="https://github.com/luisdanielroviracontreras" rel="nofollow noopener" target="_blank">@luisdanielroviracontreras</a> <a href="https://github.com/lvarayut" data-href="https://github.com/lvarayut" rel="nofollow noopener" target="_blank">@lvarayut</a> <a href="https://github.com/manuel-magnetix" data-href="https://github.com/manuel-magnetix" rel="nofollow noopener" target="_blank">@manuel-magnetix</a> <a href="https://github.com/markelog" data-href="https://github.com/markelog" rel="nofollow noopener" target="_blank">@markelog</a> <a href="https://github.com/marob" data-href="https://github.com/marob" rel="nofollow noopener" target="_blank">@marob</a> <a href="https://github.com/marshallmick007" data-href="https://github.com/marshallmick007" rel="nofollow noopener" target="_blank">@marshallmick007</a> <a href="https://github.com/martinmacko47" data-href="https://github.com/martinmacko47" rel="nofollow noopener" target="_blank">@martinmacko47</a> <a href="https://github.com/meesvandongen" data-href="https://github.com/meesvandongen" rel="nofollow noopener" target="_blank">@meesvandongen</a> <a href="https://github.com/michaelduminy" data-href="https://github.com/michaelduminy" rel="nofollow noopener" target="_blank">@michaelduminy</a> <a href="https://github.com/mizx" data-href="https://github.com/mizx" rel="nofollow noopener" target="_blank">@mizx</a> <a href="https://github.com/mnicole" data-href="https://github.com/mnicole" rel="nofollow noopener" target="_blank">@mnicole</a> <a href="https://github.com/mrmckeb" data-href="https://github.com/mrmckeb" rel="nofollow noopener" target="_blank">@mrmckeb</a> <a href="https://github.com/mshaaban088" data-href="https://github.com/mshaaban088" rel="nofollow noopener" target="_blank">@mshaaban088</a> <a href="https://github.com/mvasin" data-href="https://github.com/mvasin" rel="nofollow noopener" target="_blank">@mvasin</a> <a href="https://github.com/ndelangen" data-href="https://github.com/ndelangen" rel="nofollow noopener" target="_blank">@ndelangen</a> <a href="https://github.com/nemodreamer" data-href="https://github.com/nemodreamer" rel="nofollow noopener" target="_blank">@nemodreamer</a> <a href="https://github.com/nm123github" data-href="https://github.com/nm123github" rel="nofollow noopener" target="_blank">@nm123github</a> <a href="https://github.com/noriste" data-href="https://github.com/noriste" rel="nofollow noopener" target="_blank">@noriste</a> <a href="https://github.com/paradoxxxzero" data-href="https://github.com/paradoxxxzero" rel="nofollow noopener" target="_blank">@paradoxxxzero</a> <a href="https://github.com/pascalduez" data-href="https://github.com/pascalduez" rel="nofollow noopener" target="_blank">@pascalduez</a> <a href="https://github.com/pelotom" data-href="https://github.com/pelotom" rel="nofollow noopener" target="_blank">@pelotom</a> <a href="https://github.com/phillduffy" data-href="https://github.com/phillduffy" rel="nofollow noopener" target="_blank">@phillduffy</a> <a href="https://github.com/pksunkara" data-href="https://github.com/pksunkara" rel="nofollow noopener" target="_blank">@pksunkara</a> <a href="https://github.com/plsr" data-href="https://github.com/plsr" rel="nofollow noopener" target="_blank">@plsr</a> <a href="https://github.com/plumpnation" data-href="https://github.com/plumpnation" rel="nofollow noopener" target="_blank">@plumpnation</a> <a href="https://github.com/primigenus" data-href="https://github.com/primigenus" rel="nofollow noopener" target="_blank">@primigenus</a> <a href="https://github.com/rantelo" data-href="https://github.com/rantelo" rel="nofollow noopener" target="_blank">@rantelo</a> <a href="https://github.com/rhalff" data-href="https://github.com/rhalff" rel="nofollow noopener" target="_blank">@rhalff</a> <a href="https://github.com/rwieruch" data-href="https://github.com/rwieruch" rel="nofollow noopener" target="_blank">@rwieruch</a> <a href="https://github.com/sanpochew" data-href="https://github.com/sanpochew" rel="nofollow noopener" target="_blank">@sanpochew</a> <a href="https://github.com/shilman" data-href="https://github.com/shilman" rel="nofollow noopener" target="_blank">@shilman</a> <a href="https://github.com/silencerweb" data-href="https://github.com/silencerweb" rel="nofollow noopener" target="_blank">@silencerweb</a> <a href="https://github.com/sky-franciscogoncalves" data-href="https://github.com/sky-franciscogoncalves" rel="nofollow noopener" target="_blank">@sky-franciscogoncalves</a> <a href="https://github.com/skywhale" data-href="https://github.com/skywhale" rel="nofollow noopener" target="_blank">@skywhale</a> <a href="https://github.com/stephanemw" data-href="https://github.com/stephanemw" rel="nofollow noopener" target="_blank">@stephanemw</a> <a href="https://github.com/stijnkoopal" data-href="https://github.com/stijnkoopal" rel="nofollow noopener" target="_blank">@stijnkoopal</a> <a href="https://github.com/swernerx" data-href="https://github.com/swernerx" rel="nofollow noopener" target="_blank">@swernerx</a> <a href="https://github.com/swese44" data-href="https://github.com/swese44" rel="nofollow noopener" target="_blank">@swese44</a> <a href="https://github.com/thekashey" data-href="https://github.com/thekashey" rel="nofollow noopener" target="_blank">@thekashey</a> <a href="https://github.com/thomasbertet" data-href="https://github.com/thomasbertet" rel="nofollow noopener" target="_blank">@thomasbertet</a> <a href="https://github.com/timothymclane" data-href="https://github.com/timothymclane" rel="nofollow noopener" target="_blank">@timothymclane</a> <a href="https://github.com/titonobre" data-href="https://github.com/titonobre" rel="nofollow noopener" target="_blank">@titonobre</a> <a href="https://github.com/tkh44" data-href="https://github.com/tkh44" rel="nofollow noopener" target="_blank">@tkh44</a> <a href="https://github.com/tmeasday" data-href="https://github.com/tmeasday" rel="nofollow noopener" target="_blank">@tmeasday</a> <a href="https://github.com/tobilen" data-href="https://github.com/tobilen" rel="nofollow noopener" target="_blank">@tobilen</a> <a href="https://github.com/tombyrer" data-href="https://github.com/tombyrer" rel="nofollow noopener" target="_blank">@tombyrer</a> <a href="https://github.com/tretuna" data-href="https://github.com/tretuna" rel="nofollow noopener" target="_blank">@tretuna</a> <a href="https://github.com/tsiq-swyx" data-href="https://github.com/tsiq-swyx" rel="nofollow noopener" target="_blank">@tsiq-swyx</a> <a href="https://github.com/unional" data-href="https://github.com/unional" rel="nofollow noopener" target="_blank">@unional</a> <a href="https://github.com/urikphytech" data-href="https://github.com/urikphytech" rel="nofollow noopener" target="_blank">@urikphytech</a> <a href="https://github.com/vertexbz" data-href="https://github.com/vertexbz" rel="nofollow noopener" target="_blank">@vertexbz</a> <a href="https://github.com/vidaaudrey" data-href="https://github.com/vidaaudrey" rel="nofollow noopener" target="_blank">@vidaaudrey</a> <a href="https://github.com/wearymonkey" data-href="https://github.com/wearymonkey" rel="nofollow noopener" target="_blank">@wearymonkey</a> <a href="https://github.com/web-devel" data-href="https://github.com/web-devel" rel="nofollow noopener" target="_blank">@web-devel</a> <a href="https://github.com/westandy-dcp" data-href="https://github.com/westandy-dcp" rel="nofollow noopener" target="_blank">@westandy-dcp</a> <a href="https://github.com/wuweiweiwu" data-href="https://github.com/wuweiweiwu" rel="nofollow noopener" target="_blank">@wuweiweiwu</a> <a href="https://github.com/yaodingyd" data-href="https://github.com/yaodingyd" rel="nofollow noopener" target="_blank">@yaodingyd</a> <a href="https://github.com/yi-ge" data-href="https://github.com/yi-ge" rel="nofollow noopener" target="_blank">@yi-ge</a> <a href="https://github.com/yogu" data-href="https://github.com/yogu" rel="nofollow noopener" target="_blank">@yogu</a> <a href="https://github.com/zgreen" data-href="https://github.com/zgreen" rel="nofollow noopener" target="_blank">@zgreen</a>

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK