Socket
Socket
Sign inDemoInstall

@storybook/addon-storysource

Package Overview
Dependencies
10
Maintainers
5
Versions
1657
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @storybook/addon-storysource

View a story’s source code to see how it works and paste into your app


Version published
Weekly downloads
351K
decreased by-17.54%
Maintainers
5
Install size
43.4 MB
Created
Weekly downloads
 

Changelog

Source

7.0.0 (March 31, 2023)

Storybook 7.0 is here! 🎉

  • ⚡️ First-class Vite

  • 🔼 Zero-config NextJS

  • 🇸 Zero-config SvelteKit

  • 🏗️ Frameworks API

  • 3️⃣ Component Story Format v3

  • 🛡️ Improved type safety

  • 📚 Docs overhaul with MDx2 support

  • ☂️ Code coverage for interaction testing

  • 🖼️ UI design refresh

  • 🏛️ Improved stability

    7.0 contains hundreds more fixes, features, and tweaks. Browse the changelogs matching 7.0.0-alpha.*, 7.0.0-beta.*, and 7.0.0-rc.* for the full list of changes.

See our Migration guide to upgrade from earlier versions of Storybook.

Full announcement and proper release to the latest npm tag coming soon. 😘

Readme

Source

Storybook Storysource Addon

This addon is used to show stories source in the addon panel.

Framework Support

Storysource Demo

Getting Started

First, install the addon

yarn add @storybook/addon-storysource --dev

You can add configuration for this addon by using a preset or by using the addon config with webpack

Install using preset

Add the following to your .storybook/main.js exports:

export default {
  addons: ['@storybook/addon-storysource'],
};

You can pass configurations into the addon-storysource loader in your .storybook/main.js file, e.g.:

export default {
  addons: [
    {
      name: '@storybook/addon-storysource',
      options: {
        rule: {
          // test: [/\.stories\.jsx?$/], This is default
          include: [path.resolve(__dirname, '../src')], // You can specify directories
        },
        loaderOptions: {
          prettierConfig: { printWidth: 80, singleQuote: false },
        },
      },
    },
  ],
};

To customize the source-loader, pass loaderOptions. Valid configurations are documented in the source-loader README.

Theming

Storysource will automatically use the light or dark syntax theme based on your storybook theme. See Theming Storybook for more information.

Storysource Light/Dark Themes

Displaying full source

Storybook 6.0 introduced an unintentional change to source-loader, in which only the source of the selected story is shown in the addon. To restore the old behavior, pass theinjectStoryParameters: false option.

If you're using addon-docs:

export default {
  addons: [
    {
      name: '@storybook/addon-docs',
      options: {
        sourceLoaderOptions: {
          injectStoryParameters: false,
        },
      },
    },
  ],
};

If not:

export default {
  addons: [
    {
      name: '@storybook/addon-storysource',
      options: {
        loaderOptions: {
          injectStoryParameters: false,
        },
      },
    },
  ],
};

This bug will be resolved in a future version of the addon.

Keywords

FAQs

Last updated on 31 Mar 2023

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