question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Addon-docs: Decorators for MDX and DocsPage

See original GitHub issue

Is your feature request related to a problem? Please describe. I would like to be able to add custom widgets at the top of all my MDX pages.

Ideally, I would define those widgets once in some kind of container that would wrap all my MDX pages.

Describe the solution you’d like It could be achieve by a decorator with the same behavior as the story decorator but for MDX and DocsPage.

addDocsDecorator((page, context) => <DocsContainer page={page} ... />)

Describe alternatives you’ve considered

  • Manually add the widgets in all my MDX pages.
  • Support tool addon in MDX pages

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:5
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
shilmancommented, Nov 22, 2019

I think you can do this already, though with a slightly less flexible mechanism. Let’s suppose I want to wrap every docs page with a red border. It should be possible using something like this:

import { addParameters } from '@storybook/client-api';
import { DocsContainer } from '@storybook/addon-docs/blocks';

addParameters({
  docs: {
    container: ({ children, context }) => (
      <DocsContainer context={context}>
        <div style={{border: '5px solid red'}}>
          {children}
        <div>
      </DocsContainer>
    ),
  },
});
1reaction
atanasstercommented, Nov 22, 2019

Just for documentation completeness purposes, the following is also an equivalent:

import { DocsPage } from '@storybook/addon-docs/blocks';

addParameters({
    docs: {
      page: props => (
        <div style={{ border: '5px solid red'}}>
          <DocsPage {...props} />
        </div>
      ),
    },
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

Compare DocsPage and MDX syntax in Storybook with example
This post compares the DocsPage and MDX syntax to write story of your UI components using Storybook. We will continue with the Card...
Read more >
MDX - Storybook
Storybook is a frontend workshop for building UI components and pages in isolation. Thousands of teams use it for UI development, testing, and...
Read more >
storybook/addon-docs - npm
DocsPage is a zero-config aggregation of your component stories, text descriptions, docgen comments, props tables, and code examples into clean, ...
Read more >
Storybook Docs with mdx support and addon knobs - Medium
page: DocsPage } });function loadStories() { ... Badge.mdximport { Story } from '@storybook/addon-docs/blocks'; import Badge from '../../.
Read more >
Documenting design systems with Storybook Docs
Released in Storybook v5.3, MDX aims to provide full control over ... import { Canvas, Meta, Story } from '@storybook/addon-docs/blocks' ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found