Socket
Socket
Sign inDemoInstall

@storybook/csf

Package Overview
Dependencies
1
Maintainers
13
Versions
112
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @storybook/csf

Storybook Component Story Format (CSF) utilities


Version published
Weekly downloads
11M
increased by2.65%
Maintainers
13
Install size
1.36 MB
Created
Weekly downloads
 

Package description

What is @storybook/csf?

The @storybook/csf (Component Story Format) package is a set of tools and utilities for defining component examples in Storybook. It provides a standardized format for writing stories and allows developers to take advantage of features like auto-generated documentation, controls for live editing of component props, and more.

What are @storybook/csf's main functionalities?

Defining stories

This feature allows developers to define stories for their components. A story is a single state of a component, and with CSF, stories are written as ES6 modules that export a default object with component metadata and named exports for each story.

import { Meta, Story } from '@storybook/csf';

export default {
  title: 'Button',
  component: Button,
} as Meta;

const Template: Story<ButtonProps> = (args) => <Button {...args} />;

export const Primary = Template.bind({});
Primary.args = {
  primary: true,
  label: 'Button',
};

Args

Args are the dynamic values that a story accepts. They are used to change the state of the component in the story. In the code sample, 'Secondary' is a story that uses the 'Template' but with different args to create a variation of the Button component.

export const Secondary = Template.bind({});
Secondary.args = {
  label: 'Button',
};

Parameters

Parameters are Storybook's mechanism for providing static, named metadata about a story. In this example, the 'Primary' story is given a custom background parameter to change the background color in the Storybook UI.

Primary.parameters = {
  backgrounds: {
    values: [{ name: 'red', value: '#f00' }],
  },
};

Other packages similar to @storybook/csf

Readme

Source

Storybook Component Story Format (CSF)

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

Install

yarn add @storybook/csf

API

See package source for function definitions and types:

  • 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

Keywords

FAQs

Last updated on 09 Dec 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc