Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Target content when used as a global decorator #131

Open
awdyson opened this issue Dec 30, 2020 · 2 comments
Open

[Feature] Target content when used as a global decorator #131

awdyson opened this issue Dec 30, 2020 · 2 comments
Labels

Comments

@awdyson
Copy link

awdyson commented Dec 30, 2020

Describe the bug

It'd be nice to have the option to strip Storybook's wrapper when used as a global decorator.
It does work well when invoked directly by each story.

Steps to reproduce the behavior

preview.ts:

import { addDecorator } from '@storybook/react';
import { jsxDecorator } from 'storybook-addon-jsx';

addDecorator(jsxDecorator);

MyComponent.stories.ts:

import { Meta } from '@storybook/react/types-6-0';
import React, { ReactElement } from 'react';

import { MyComponent, MyComponentProps } from '../../src/components';

const meta: Meta = {
  component: MyComponent,
  title: 'Components/MyComponent',
};

const Story = (args: MyComponentProps): ReactElement => <MyComponent {...args} />;

export { meta as default, Story };

addon-jsx output:

<ReadmeContent
  DocPreview={undefined}
  FooterPreview={undefined}
  HeaderPreview={undefined}
  StoryPreview={undefined}
  codeTheme="github"
  layout={[
    {
      content: <><MyComponent /></>,
      type: 'STORY'
    }
  ]}
  theme={{}}
  types={[
    'MD',
    'STORY',
    'STORY_SOURCE',
    'PROPS',
    'FOOTER_MD',
    'HEADER_MD'
  ]}
/>
@awdyson awdyson added the bug label Dec 30, 2020
@awdyson
Copy link
Author

awdyson commented Jan 1, 2021

Partial solution:

const parameters = {
  jsx: {
    onBeforeRender: (domStr: string) => /content: <>(.*)<\/>/.exec(domStr)?.[1] || domStr,
  },
};

We lose some formatting still though 😞
ie, maxInlineAttributesLineLength isn't respected anymore.

@hipstersmoothie
Copy link
Contributor

Where is ReadmeContent coming from?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants