@storybook/csf
Component Story Format (CSF) utilities
Last updated 2 years ago by shilman .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install @storybook/csf 
SYNC missed versions from official npm registry.

Component Story Format (CSF)

Why a standard format?

Components have risen to dominate the UI landscape. There are new component-oriented tools for development, testing, design, and prototyping. These tools engage in the creation and consumption of components and component examples (a.k.a. stories). But each tool has its own proprietary format because a simple, platform-agnostic way to express component examples doesn't yet exist.

The "Story" is the source of truth for a component.

A story is a code snippet that renders an example of a component in a specific state. Think about it like a "user story".

It uses the production code shipped to users, making it the most accurate representation of a component example. What's more, stories are expressed in the view layer you use to build your app.

Component Story Format

The Component Story Format is an open standard for component examples based on JavaScript ES6 modules. This enables interoperation between development, testing, and design tools.

export default { title: 'atoms/Button' };
export const text = () => <Button>Hello</Button>;
export const emoji = () => <Button>😀😎👍💯</Button>;

💎 Simple. Writing component "stories" is as easy as exporting ES6 functions using a clean, widely-used format.

🚚 Non-proprietary. CSF doesn't require any vendor-specific libraries. Component stories are easily consumed anywhere ES6 modules live, including your favourite testing tools like Jest and Cypress.

☝️ Declarative. The declarative syntax is isomorphic to higher-level formats like MDX, enabling clean, verifiable transformations.

🔥 Optimized. Component stories don't need any libraries other than your components. And because they're ES6 modules, they're even tree-shakeable!

Who uses CSF?

Tools: Storybook, WebComponents.dev, Components.studio, RedwoodJS, UXPin

Compatible with: Jest, Enzyme, Testing Library, Cypress, Playwright, Mocha, etc.

CSF utilities

A minimal set of utility functions for dealing with Component Story Format (CSF).

Install

yarn add @componentdriven/csf

API

See package source for function definitions and types:

  • storyNameFromExport(key) - Enhance export name (key) of the story. Currently implemented with startCase.

  • isExportStory(key, { includeStories, excludeStories }) - Does a named export match CSF inclusion/exclusion options?

  • parseKind(kind, { rootSeparator, groupSeparator }) - Parse out the component/kind name from a path, using the given separator config.

  • sanitize(string) - Remove punctuation and illegal characters from a story ID.

  • toId(kind, name) - Generate a storybook ID from a component/kind and story name.

Contributing

If you have any suggestions, please open an issue or a PR.

All contributions are welcome!

run tests:

yarn test

Current Tags

  • 0.1.12--canary.95.1b1fb52.0                                ...           canary (4 months ago)
  • 0.1.11                                ...           latest (4 months ago)
  • 0.1.12-next.0                                ...           next (4 months ago)

155 Versions

  • 0.1.12-next.0                                ...           4 months ago
  • 0.1.12--canary.95.1b1fb52.0                                ...           4 months ago
  • 0.1.11                                ...           4 months ago
  • 0.1.11-next.0                                ...           4 months ago
  • 0.1.10                                ...           4 months ago
  • 0.1.10-next.0                                ...           4 months ago
  • 0.1.10--canary.99.8b81c0b.0                                ...           4 months ago
  • 0.1.10--canary.100.877a297.0                                ...           5 months ago
  • 0.1.10--canary.99.ba76785.0                                ...           5 months ago
  • 0.1.10--canary.99.d6ab1d5.0                                ...           5 months ago
  • 0.1.10--canary.d841bb4.0                                ...           5 months ago
  • 0.1.9                                ...           5 months ago
  • 0.1.9-next.0                                ...           5 months ago
  • 0.1.9--canary.96.2ccc94b.0                                ...           5 months ago
  • 0.1.9--canary.91.b332918.0                                ...           5 months ago
  • 0.1.9--canary.91.9f56778.0                                ...           5 months ago
  • 0.1.9--canary.96.46e1c3c.0                                ...           5 months ago
  • 0.1.9--canary.91.0f3cc7f.0                                ...           5 months ago
  • 0.1.9--canary.91.8b5aaf1.0                                ...           5 months ago
  • 0.1.9--canary.91.42a6edc.0                                ...           5 months ago
  • 0.1.9--canary.91.f96e3a9.0                                ...           5 months ago
  • 0.1.9--canary.91.5f665c5.0                                ...           5 months ago
  • 0.1.9--canary.fee46c1.0                                ...           5 months ago
  • 0.1.9--canary.91.ad22273.0                                ...           5 months ago
  • 0.1.9--canary.91.471c890.0                                ...           5 months ago
  • 0.1.9--canary.91.75a24e6.0                                ...           5 months ago
  • 0.1.9--canary.91.199fdbc.0                                ...           5 months ago
  • 0.1.8                                ...           5 months ago
  • 0.1.8-next.0                                ...           5 months ago
  • 0.1.8--canary.92.6fb63cd.0                                ...           5 months ago
  • 0.1.8--canary.40a5c7a.0                                ...           5 months ago
  • 0.1.8--canary.90.81a58c9.0                                ...           5 months ago
  • 0.1.8--canary.91.381fe2e.0                                ...           5 months ago
  • 0.1.8--canary.91.89e16ed.0                                ...           5 months ago
  • 0.1.8--canary.91.84e764b.0                                ...           5 months ago
  • 0.1.8--canary.91.459d398.0                                ...           6 months ago
  • 0.1.7                                ...           6 months ago
  • 0.1.7-next.0                                ...           6 months ago
  • 0.1.6                                ...           7 months ago
  • 0.1.6--canary.82.7c063db.0                                ...           7 months ago
  • 0.1.5                                ...           7 months ago
  • 0.1.5-next.1                                ...           7 months ago
  • 0.1.5-next.0                                ...           7 months ago
  • 0.1.5--canary.82.2c2dd28.0                                ...           7 months ago
  • 0.1.5--canary.82.5938682.0                                ...           7 months ago
  • 0.1.4                                ...           7 months ago
  • 0.1.4-next.0                                ...           7 months ago
  • 0.1.4--canary.83.ab72fee.0                                ...           7 months ago
  • 0.1.4--canary.82.934057e.0                                ...           7 months ago
  • 0.1.4--canary.82.07bccd8.0                                ...           7 months ago
  • 0.1.4--canary.82.f4adda6.0                                ...           7 months ago
  • 0.1.4--canary.82.1657476.0                                ...           7 months ago
  • 0.1.4--canary.82.004ec21.0                                ...           7 months ago
  • 0.1.4--canary.82.eb42c88.0                                ...           7 months ago
  • 0.1.4--canary.82.2a09ac2.0                                ...           7 months ago
  • 0.1.4--canary.82.beb2113.0                                ...           7 months ago
  • 0.1.4--canary.82.c8a52dd.0                                ...           7 months ago
  • 0.1.4--canary.82.5e73744.0                                ...           7 months ago
  • 0.1.4--canary.82.4a5a941.0                                ...           7 months ago
  • 0.1.4--canary.82.941efd8.0                                ...           7 months ago
  • 0.1.4--canary.80.ba37fd5.0                                ...           7 months ago
  • 0.1.4--canary.80.f469755.0                                ...           8 months ago
  • 0.1.4--canary.80.aedde7f.0                                ...           8 months ago
  • 0.1.4--canary.80.632d12b.0                                ...           8 months ago
  • 0.1.3                                ...           8 months ago
  • 0.1.3-next.0                                ...           8 months ago
  • 0.1.3--canary.78.9722e80.0                                ...           8 months ago
  • 0.1.2                                ...           a year ago
  • 0.1.2-next.0                                ...           a year ago
  • 0.1.2--canary.71.cad875c.0                                ...           a year ago
  • 0.1.2--canary.71.b1f85ff.0                                ...           a year ago
  • 0.1.2--canary.71.a3cacc5.0                                ...           a year ago
  • 0.1.1                                ...           a year ago
  • 0.1.1-next.0                                ...           a year ago
  • 0.1.1--canary.f0d3083.0                                ...           2 years ago
  • 0.1.0                                ...           2 years ago
  • 0.0.2-next.11                                ...           2 years ago
  • 0.0.2--canary.65.ef100c4.0                                ...           2 years ago
  • 0.0.2-next.10                                ...           2 years ago
  • 0.0.2--canary.64.1cdb44b.0                                ...           2 years ago
  • 0.0.2--canary.bdd5424.0                                ...           2 years ago
  • 0.0.2-next.9                                ...           2 years ago
  • 0.0.2--canary.62.4a3b146.0                                ...           2 years ago
  • 0.0.2--canary.62.bf5823f.0                                ...           2 years ago
  • 0.0.2--canary.62.5777911.0                                ...           2 years ago
  • 0.0.2--canary.62.f5c59be.0                                ...           2 years ago
  • 0.0.2--canary.62.9cd6451.0                                ...           2 years ago
  • 0.0.2--canary.62.1b51cab.0                                ...           2 years ago
  • 0.0.2--canary.62.d7abc02.0                                ...           2 years ago
  • 0.0.2--canary.7705a54.0                                ...           2 years ago
  • 0.0.2-next.8                                ...           2 years ago
  • 0.0.2--canary.60.011a95e.0                                ...           2 years ago
  • 0.0.2-next.7                                ...           2 years ago
  • 0.0.2--canary.58.7052fb8.0                                ...           2 years ago
  • 0.0.2-next.6                                ...           2 years ago
  • 0.0.2--canary.57.a8fc7a0.0                                ...           2 years ago
  • 0.0.2-next.5                                ...           2 years ago
  • 0.0.2--canary.fed52be.0                                ...           2 years ago
  • 0.0.2-next.4                                ...           2 years ago
  • 0.0.2--canary.55.8133684.0                                ...           2 years ago
  • 0.0.2--canary.3094f05.0                                ...           2 years ago
  • 0.0.2-next.3                                ...           2 years ago
  • 0.0.2--canary.54.75c3237.0                                ...           2 years ago
  • 0.0.2--canary.5f921f0.0                                ...           2 years ago
  • 0.0.2-next.2                                ...           2 years ago
  • 0.0.2--canary.53.4879818.0                                ...           2 years ago
  • 0.0.2--canary.795e486.0                                ...           2 years ago
  • 0.0.2-next.1                                ...           2 years ago
  • 0.0.2--canary.52.d2acbe4.0                                ...           2 years ago
  • 0.0.2--canary.5b59926.0                                ...           2 years ago
  • 0.0.2-next.0                                ...           2 years ago
  • 0.0.2--canary.29.77954d8.0                                ...           2 years ago
  • 0.0.2--canary.29.e31af55.0                                ...           2 years ago
  • 0.0.2--canary.43.5edcaf6.0                                ...           2 years ago
  • 0.0.2--canary.48.47fcdb1.0                                ...           2 years ago
  • 0.0.2--canary.49.65292c2.0                                ...           2 years ago
  • 0.0.2--canary.51.084d9eb.0                                ...           2 years ago
  • 0.0.2--canary.51.26e6539.0                                ...           2 years ago
  • 0.0.2--canary.51.23af5af.0                                ...           2 years ago
  • 0.0.2--canary.51.768ca23.0                                ...           2 years ago
  • 0.0.2--canary.49.258942b.0                                ...           2 years ago
  • 0.0.2--canary.49.b089ae5.0                                ...           2 years ago
  • 0.0.2--canary.49.9d84710.0                                ...           2 years ago
  • 0.0.2--canary.48.3bd2bd7.0                                ...           2 years ago
  • 0.0.2--canary.43.a3d8c69.0                                ...           2 years ago
  • 0.0.2--canary.36.ecfc79e.0                                ...           2 years ago
  • 0.0.2--canary.50.794a0bf.0                                ...           2 years ago
  • 0.0.2--canary.50.45981a0.0                                ...           2 years ago
  • 0.0.2--canary.0899bb7.0                                ...           2 years ago
  • 0.0.2--canary.4566f4d.1                                ...           3 years ago
  • 0.0.2--canary.4566f4d.0                                ...           3 years ago
  • 0.0.2--canary.7c6c115.0                                ...           3 years ago
  • 0.0.2--canary.92ac0db.0                                ...           3 years ago
  • 0.0.2--canary.d38f8f1.0                                ...           3 years ago
  • 0.0.2--canary.507502b.0                                ...           3 years ago
  • 0.0.2--canary.789b78e.0                                ...           3 years ago
  • 0.0.2--canary.835a408.0                                ...           3 years ago
  • 0.0.2--canary.87bc651.0                                ...           3 years ago
  • 0.0.2--canary.6aca495.0                                ...           3 years ago
  • 0.0.2--canary.68887a1.0                                ...           3 years ago
  • 0.0.2--canary.062665d.0                                ...           3 years ago
  • 0.0.2--canary.b1d5348.0                                ...           3 years ago
  • 0.0.2--canary.5459c65.0                                ...           3 years ago
  • 0.0.2--canary.a925d24.0                                ...           3 years ago
  • 0.0.2--canary.d61cd6c.0                                ...           3 years ago
  • 0.0.2--canary.a1972cb.0                                ...           3 years ago
  • 0.0.2--canary.29b0df7.0                                ...           3 years ago
  • 0.0.2--canary.c10361d.0                                ...           3 years ago
  • 0.0.2--canary.cc8c2b0.0                                ...           3 years ago
  • 0.0.2--canary.9c0fda0.0                                ...           3 years ago
  • 0.0.2--canary.856a16c.0                                ...           3 years ago
  • 0.0.2--canary.3b9fb86.0                                ...           3 years ago
  • 0.0.2--canary.4d00998.0                                ...           3 years ago
  • 0.0.2-alpha.0                                ...           5 years ago
  • 0.0.1                                ...           5 years ago

© 2010 - cnpmjs.org x YWFE | Home | YWFE