Socket
Socket
Sign inDemoInstall

@storybook/preview-api

Package Overview
Dependencies
16
Maintainers
29
Versions
625
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@storybook/preview-api


Version published
Maintainers
29
Created

Package description

What is @storybook/preview-api?

The @storybook/preview-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 interact with the Storybook preview, allowing developers to control the rendering of stories, listen to events, and manipulate the state of the Storybook UI.

What are @storybook/preview-api's main functionalities?

Fetching and rendering stories

This feature allows developers to fetch story data by ID and render it using a custom component or utility.

import { useStorybookApi } from '@storybook/api';

function MyComponent() {
  const api = useStorybookApi();
  const story = api.getData('some-story-id');

  return <StoryRenderer story={story} />;
}

Listening to Storybook events

This feature enables components to listen to Storybook-specific events and react accordingly, as well as emit events to the Storybook environment.

import { useEffect } from 'react';
import { useChannel } from '@storybook/api';

function MyComponent() {
  const emit = useChannel({
    'storybook/my-event': (eventData) => {
      console.log('Event data:', eventData);
    }
  });

  useEffect(() => {
    emit('storybook/my-event', { payload: 'data' });
  }, [emit]);

  return <div>Check the console for event data.</div>;
}

Manipulating the Storybook UI

Developers can use this feature to programmatically control the Storybook UI, such as changing the current story displayed.

import { addons } from '@storybook/addons';

addons.setChannel(new Channel({ transport: new PostmsgTransport({ key: 'iframe-key' }) }));

addons.getChannel().emit('setCurrentStory', { storyId: 'some-story-id' });

Other packages similar to @storybook/preview-api

Changelog

Source

7.0.0-beta.30 (January 18, 2023)

Features
  • UI: Add Sun, Moon, Sidebyside, and stacked icons #20621
  • Angular: Add multi-project setup for ng workspaces #20559
  • Addon-docs: Support @deprecated jsdoc tag #20154
  • Csf-plugin: Support meta description comments #20632
Bug Fixes
  • Core: Fix core preset default value #20646
  • Addon-docs: Fix issue with unattached .mdx files #20661
  • Webpack: aAd error catching when template is not set #20669
  • Addons: Fix Viewport resetting shortcut key not working #20167
  • Core: Show "booting" progress until story is specified or errors #20425
  • Vue: Update events binding in Vue render #19860
  • Addon-actions: Fix webpack hot reload code in manager bundle #20649
  • UI: Fix HMR issue in Manager UI #20654
Maintenance
  • Docs: Refactor props of Story block #20530
  • Vite: TypeScript type cleanup #20642
Build
  • Add required jobs to daily workflow #20263
  • Fix typings files to ensure this the check command succeeds #20598
Dependency Upgrades
  • Svelte: Remove babel/core peer dep #20650

Readme

Source

Preview API

TODO write proper documentation of this package

"Sub packages" README documents

This package used to be multiple packages (they have been combined into this one):

Keywords

FAQs

Last updated on 18 Jan 2023

Did you know?

Socket

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc