Norbert de Langen 77c0f3ab81
Merge commit '13b40e371555122513d307be94da2f0705df34ef' into future/modern-frameworks
# Conflicts:
#	addons/a11y/package.json
#	addons/actions/package.json
#	addons/backgrounds/package.json
#	addons/controls/package.json
#	addons/docs/package.json
#	addons/essentials/package.json
#	addons/interactions/package.json
#	addons/jest/package.json
#	addons/links/package.json
#	addons/measure/package.json
#	addons/outline/package.json
#	addons/storyshots/storyshots-core/package.json
#	addons/storysource/package.json
#	addons/toolbars/package.json
#	addons/viewport/package.json
#	docs/faq.md
#	examples/angular-cli/.storybook/main.js
#	examples/angular-cli/package.json
#	examples/cra-kitchen-sink/.storybook/main.js
#	examples/cra-kitchen-sink/package.json
#	examples/cra-react15/.storybook/main.js
#	examples/cra-react15/package.json
#	examples/cra-ts-essentials/.storybook/main.ts
#	examples/cra-ts-essentials/package.json
#	examples/cra-ts-kitchen-sink/.storybook/main.ts
#	examples/cra-ts-kitchen-sink/package.json
#	examples/ember-cli/.storybook/main.js
#	examples/ember-cli/package.json
#	examples/external-docs/package.json
#	examples/html-kitchen-sink/.storybook/main.js
#	examples/html-kitchen-sink/package.json
#	examples/official-storybook/main.ts
#	examples/official-storybook/package.json
#	examples/preact-kitchen-sink/.storybook/main.js
#	examples/preact-kitchen-sink/package.json
#	examples/react-ts-webpack4/package.json
#	examples/react-ts/package.json
#	examples/server-kitchen-sink/package.json
#	examples/standalone-preview/package.json
#	examples/svelte-kitchen-sink/.storybook/main.js
#	examples/svelte-kitchen-sink/package.json
#	examples/vue-3-cli/.storybook/main.js
#	examples/vue-3-cli/package.json
#	examples/vue-cli/.storybook/main.js
#	examples/vue-cli/package.json
#	examples/vue-kitchen-sink/.storybook/main.js
#	examples/vue-kitchen-sink/package.json
#	examples/web-components-kitchen-sink/.storybook/main.js
#	frameworks/angular/package.json
#	frameworks/ember/package.json
#	frameworks/preact-webpack5/package.json
#	frameworks/vue-webpack5/package.json
#	frameworks/vue3-webpack5/package.json
#	lib/addons/package.json
#	lib/api/package.json
#	lib/builder-webpack4/package.json
#	lib/builder-webpack5/package.json
#	lib/channel-postmessage/package.json
#	lib/channel-websocket/package.json
#	lib/channels/package.json
#	lib/cli/package.json
#	lib/cli/src/automigrate/fixes/angular12.test.ts
#	lib/cli/src/automigrate/index.ts
#	lib/cli/src/versions.ts
#	lib/client-api/package.json
#	lib/client-logger/package.json
#	lib/codemod/package.json
#	lib/components/package.json
#	lib/core-client/package.json
#	lib/core-common/package.json
#	lib/core-events/package.json
#	lib/core-server/package.json
#	lib/core-server/src/__snapshots__/vue-3-cli_preview-dev-posix
#	lib/core-server/src/__snapshots__/vue-3-cli_preview-prod-posix
#	lib/core-vite/package.json
#	lib/csf-tools/package.json
#	lib/docs-tools/package.json
#	lib/instrumenter/package.json
#	lib/manager-webpack4/package.json
#	lib/manager-webpack5/package.json
#	lib/node-logger/package.json
#	lib/postinstall/package.json
#	lib/preview-web/package.json
#	lib/router/package.json
#	lib/source-loader/package.json
#	lib/store/package.json
#	lib/telemetry/package.json
#	lib/theming/package.json
#	lib/ui/package.json
#	presets/server-webpack/package.json
#	renderers/html/package.json
#	renderers/react/package.json
#	renderers/svelte/package.json
#	renderers/web-components/package.json
#	scripts/build-package.js
#	scripts/bundle-package.ts
#	yarn.lock
2022-05-26 14:46:04 +02:00
..
2020-05-12 16:07:17 +00:00
2022-03-18 10:27:04 +01:00
2022-03-18 10:27:04 +01:00
wip
2022-05-25 14:15:10 +02:00

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:

module.exports = {
  addons: ['@storybook/addon-storysource'],
};

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

module.exports = {
  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:

module.exports = {
  addons: [
    {
      name: '@storybook/addon-docs',
      options: {
        sourceLoaderOptions: {
          injectStoryParameters: false,
        },
      },
    },
  ],
};

If not:

module.exports = {
  addons: [
    {
      name: '@storybook/addon-storysource',
      options: {
        loaderOptions: {
          injectStoryParameters: false,
        },
      },
    },
  ],
};

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