npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@storybook/csf

v0.1.5

Published

Component Story Format (CSF) utilities

Downloads

44,150,631

Readme

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. Implemented to have parity 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