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

Addon-docs: Multiple Tab #8951

Closed
tounsoo opened this issue Nov 26, 2019 · 23 comments
Closed

Addon-docs: Multiple Tab #8951

tounsoo opened this issue Nov 26, 2019 · 23 comments

Comments

@tounsoo
Copy link

tounsoo commented Nov 26, 2019

Is your feature request related to a problem? Please describe.
For design system documentation, we have a lot of content per component that is hard to be viewed in a single page format. In a high level, our doc is made up of 3 parts: Component Documentation, Component Guidelines, Pattern Guidelines(optional).

Describe the solution you'd like
With the newest addon/doc that supports MDX, it would be perfect if I can make multiple tabs of mdx with custom title - each tab with its mdx.

Describe alternatives you've considered
Without adding a new feature, alternate solution can be to create 3 stories for each component with each MDX attached.

Are you able to assist bring the feature to reality?
yes and no, I'm a designer who can use but not create code in efficient manner. But I would definitely want to contribute with whatever I can.

@tounsoo tounsoo changed the title Addon/Doc Multiple Tab Addon-docs, Multiple Tab Nov 26, 2019
@tounsoo tounsoo changed the title Addon-docs, Multiple Tab Addon-docs: Multiple Tab Nov 26, 2019
@patricklafrance
Copy link
Member

@stale
Copy link

stale bot commented Dec 17, 2019

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

@stale stale bot added the inactive label Dec 17, 2019
@just-andy
Copy link

We have a similar request for this feature and trying to look through the addon guides and existing docs block to see how this could be put into practice.

@stale stale bot removed the inactive label Jan 7, 2020
@domyen
Copy link
Member

domyen commented Jan 13, 2020

This seems possible via MDX (5.3) if you code up your own tab component. iirc I saw an implementation for this somewhere.

@stale
Copy link

stale bot commented Feb 3, 2020

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

@stale stale bot added the inactive label Feb 3, 2020
@adeelibr
Copy link

This seems possible via MDX (5.3) if you code up your own tab component. iirc I saw an implementation for this somewhere.

Can you kindly share the implementation details if possible

@LucasLeandro1204
Copy link

I'm waiting for this one too!

@AndreasLoukakis
Copy link

I'm using storybook/angular and wanted to implement something similar so I was looking around for other examples. I have a setup that works in a similar way and might be helpful to share, although I'm pretty much sure it's not the best way to do it.

In my docs tab, I need to have let's say Overview - API - Examples - Changelog tabs.
I created a separate .mdx for each tab (which is much easier to work on) and on the story mdx, I used @reach/tabs (some other react tab components didn't work well for me) to setup the content. So my main story looks something like this:

import MyTabMDX from './somefile.mdx'

<Tabs >
      <TabList>
        <Tab>My tab</Tab>
      </TabList>
      <TabPanels>
        <TabPanel>
          <MyTabMDX />
        </TabPanel>
      </TabPanels>
</Tabs>

<Meta title="Tabs" decorators={...} />
<Story name="SimpleTabs">...</Story>

Have in mind you obviously can't use mdx syntax if you write the content inline in-between the TabPanel tags, but external mdx works great.

@shilman
Copy link
Member

shilman commented Feb 18, 2020

Nice one @AndreasLoukakis !!!

@stale
Copy link

stale bot commented Mar 11, 2020

Hi everyone! Seems like there hasn't been much going on in this issue lately. If there are still questions, comments, or bugs, please feel free to continue the discussion. Unfortunately, we don't have time to get to every issue. We are always open to contributions so please send us a pull request if you would like to help. Inactive issues will be closed after 30 days. Thanks!

@stale stale bot added the inactive label Mar 11, 2020
@stale
Copy link

stale bot commented Apr 10, 2020

Hey there, it's me again! I am going close this issue to help our maintainers focus on the current development roadmap instead. If the issue mentioned is still a concern, please open a new ticket and mention this old one. Cheers and thanks for using Storybook!

@stale stale bot closed this as completed Apr 10, 2020
@andywd7
Copy link

andywd7 commented Sep 8, 2020

I know this is closed but I would like o know how to do this in Vue using Storybook 6? Both the tabs and importing nested mdx files as content.

@cliedelt
Copy link

@AndreasLoukakis did u get it working with canvas+stories in the mdx file?

I get an error...

@AndreasLoukakis
Copy link

Yes, it was and still is working but many updates on many libraries happened since then. Is there something in specific that would help you figure it out? what's the error?

@cliedelt
Copy link

I have a simple Story:

import { Story, Meta, ArgsTable, Preview, Canvas } from "@storybook/addon-docs";
import Rest from "./1-Rest.stories.mdx";

<Meta title="Components/Neues Template"

<Rest />

And the 1-Rest.stories.mdx with an angular story:

import { Story, Meta, ArgsTable, Preview, Canvas } from "@storybook/addon-docs";
import { moduleMetadata } from "@storybook/angular";
import { TabsComponent } from "../../../projects/ui-components-library/src/lib/modules/tabs/tabs/tabs.component.ts";

<Meta
    title="Components/Neues Template 2"
    decorators={[
        moduleMetadata({
            declarations: [TabsComponent],
        }),
    ]}
    parameters={{ test: "TEST" }}
/>

<Canvas>
    <Story
        id="components-neues-template-2--tabs"
        name="Tabs"
        args={{
            listOfTabs: ["tab1", "tab2", "..."],
            active: "tab1",
        }}
        parameters={{
            docs: { source: { code: `<libri-tabs></libri-tabs>` } },
            options: {
                showPanel: true,
            },
        }}
        height="75px"
    >
        {(args, { argTypes }) => ({
            component: TabsComponent,
            props: args,
        })}
    </Story>
</Canvas>

I get the following error: Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: object. The Element seems to be a storybook element definition?

When I rename the 1-Rest.stories.mdx to 1-Rest.mdx I get a different error. I think its because storybook adds a wrapper to mdx files. See here #9598 (comment)

@AndreasLoukakis : Do you use Stories in the mdx file? Do you use another react component to render the mdx file?

@AndreasLoukakis
Copy link

My bad, seems we have moved to a different format for the stories template since then so I can't confirm. But we did use an external React lib @reach/tabs for the tabs at the time, some others had some issues but can't remember exactly.

@sir-captainmorgan21
Copy link

@AndreasLoukakis is this still working with up to date packages? Did you have to set up any presets or anything to use the react components?

@cliedelt
Copy link

I gave up and wrote an addon... https://github.com/cliedelt/storybook-addon-docs-tabs

@sir-captainmorgan21
Copy link

@cliedelt I am using your addon. Works well. Thanks!

@sir-captainmorgan21
Copy link

@shilman could possibly use your help with @cliedelt 's tabs add-on. He is being forced to use iframes to display the tab content which is causing some overflow issues. We were wondering if you could provide any guidance with using an imported mdx stories file as a component in another mdx file. @cliedelt can provide more info too if needed.

@elpddev
Copy link

elpddev commented Aug 21, 2022

Could this be opened? Its a desired feature for us.

@vinodkola1337
Copy link

I would like to have this feature.

@Michael2109
Copy link

Michael2109 commented Feb 4, 2024

A lot of component libraries tend to split their pages into examples, properties, and styling.

How do we do this in Storybook 7?

I can't see how this is done using <x>.mdx files as it doesn't look like a component can be directly loaded into it.

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

No branches or pull requests