Storybook: addDecorator does not decorate MDX stories

Created on 4 Dec 2019  路  2Comments  路  Source: storybookjs/storybook

Describe the bug

When trying to add a ThemeProvider via addDecorator, it is not added to MDX stories.

To Reproduce

I've made a minimal reproduction over at https://github.com/jure/storybook-test.

  1. git clone it,
  2. yarn,
  3. yarn storybook

Observe the difference between the Button in a normal story (styled according to theme) and the Button in the MDX story - no theme applied.

Expected behavior
All stories should be decorated by addDecorator.

Screenshots
image
image

System:

  System:
    OS: macOS Mojave 10.14.6
    CPU: (8) x64 Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz
  Binaries:
    Node: 12.13.0 - ~/.nvm/versions/node/v12.13.0/bin/node
    Yarn: 1.19.1 - /usr/local/bin/yarn
    npm: 6.12.0 - ~/.nvm/versions/node/v12.13.0/bin/npm
  Browsers:
    Chrome: 78.0.3904.108
    Firefox: 70.0.1
    Safari: 13.0.2
  npmPackages:
    @storybook/addon-actions: ^5.3.0-beta.15 => 5.3.0-beta.15 
    @storybook/addon-docs: 5.3.0-beta.15 => 5.3.0-beta.15 
    @storybook/addon-knobs: 5.3.0-beta.15 => 5.3.0-beta.15 
    @storybook/addon-links: ^5.3.0-beta.15 => 5.3.0-beta.15 
    @storybook/addons: ^5.3.0-beta.15 => 5.3.0-beta.15 
    @storybook/react: ^5.3.0-beta.15 => 5.3.0-beta.15 
mdx question / support

Most helpful comment

I knew it had to be something very simple like this! Thanks for the super quick response!

I was expecting that the whole MDX is treated as a story, but I can see how it's merely a container for them.

All 2 comments

Thanks for the repro -- really helps!

The problem is that decorators only get applied to stories, and you're not defining any stories in your MDX. Here's how you'd do that:

import { Meta, Story } from "@storybook/addon-docs/blocks";
import Button from "./Button";

<Meta title="MDX|Test" />

A primary button.

<Story name="primary">
  <Button primary>Save</Button>
</Story>

I knew it had to be something very simple like this! Thanks for the super quick response!

I was expecting that the whole MDX is treated as a story, but I can see how it's merely a container for them.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MrOrz picture MrOrz  路  3Comments

purplecones picture purplecones  路  3Comments

tomitrescak picture tomitrescak  路  3Comments

arunoda picture arunoda  路  3Comments

shilman picture shilman  路  3Comments