Security News
ESLint is Now Language-Agnostic: Linting JSON, Markdown, and Beyond
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
@storybook/client-api
Advanced tools
The @storybook/client-api package is part of the Storybook ecosystem, which is a tool for developing UI components in isolation for React, Vue, Angular, and more. This package provides APIs to configure and manage stories in the Storybook environment programmatically. It allows developers to add stories, decorators, and parameters, and to interact with Storybook's client-side application.
Add stories
This feature allows developers to add stories to Storybook. Each story represents a single visual state of a component. The 'storiesOf' function is used to define a new set of stories.
import { storiesOf } from '@storybook/client-api';
storiesOf('Button', module)
.add('with text', () => '<button>Click me</button>')
.add('with emoji', () => '<button>😀 😎 👍 💯</button>');
Add decorators
Decorators are a way to provide custom rendering and add functionality to stories. The 'addDecorator' function is used to globally add decorators to all stories.
import { addDecorator } from '@storybook/client-api';
import { withKnobs } from '@storybook/addon-knobs';
addDecorator(withKnobs);
Set global parameters
Parameters are a set of static, named metadata about a story, typically used to control the behavior of Storybook's addons. The 'addParameters' function is used to set global parameters for all stories.
import { addParameters } from '@storybook/client-api';
addParameters({
backgrounds: [
{ name: 'light', value: '#eeeeee', default: true },
{ name: 'dark', value: '#222222' }
]
});
React Cosmos is a development tool for creating reusable React components. It provides a similar environment to Storybook for developing and testing components in isolation. While it shares the concept of component playgrounds with Storybook, it has a different API and focuses more on the component's state rather than the story format.
Docz leverages MDX to allow developers to write documentation alongside their code. It is similar to Storybook in that it provides a way to showcase components, but it emphasizes ease of writing documentation and reduces the need for configuration. Unlike Storybook, Docz is optimized for documentation and less for interactive component development.
@storybook/client-api
-- Deprecated Story APIs (storiesOf
)NOTE This API is deprecated, and the CSF format is preferred for all stories.
storiesOf
APIThe @storybook/client
API provides the storiesOf()
API, which is proxied through to the CSF API.
In order to appear to the store like the CSF API, a call to storiesOf().add()
does the following:
StoryIndex
data structuremoduleExports
object that is equivalent to the exports from a CSF file that produced the same stories.In order to achieve the old storySort
functionality, the client API also needs access to the project annotations.
FAQs
Storybook Client API
The npm package @storybook/client-api receives a total of 1,598,847 weekly downloads. As such, @storybook/client-api popularity was classified as popular.
We found that @storybook/client-api demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 8 open source maintainers collaborating on the project.
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.
Security News
ESLint has added JSON and Markdown linting support with new officially-supported plugins, expanding its versatility beyond JavaScript.
Security News
Members Hub is conducting large-scale campaigns to artificially boost Discord server metrics, undermining community trust and platform integrity.
Security News
NIST has failed to meet its self-imposed deadline of clearing the NVD's backlog by the end of the fiscal year. Meanwhile, CVE's awaiting analysis have increased by 33% since June.