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 subcomponents support for sub element components

See original GitHub issue

Is your feature request related to a problem? Please describe. I use Component.SubComponent for my components and I want to show prop tables for subcomponents and as far as I can see that is not supported

Describe the solution you’d like I would suggest supporting something like: subcomponents: {'Component.SubComponent': Component.SubComponent}

Are you able to assist bring the feature to reality? I can…

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:24 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
norcinocommented, Nov 2, 2021

@bnannierI love the innerText of the SubComponent…

I am using this code:

import React from "react";
import Accordion from "./Accordion";
import documentation from "./Accordion.docs.json";
import design from "./Accordion.fig.json"; // This just contains { }
import './Accordion.scss';

const docs = {
    title: "Components/Accordion",
    component: Accordion,
    subcomponents: {
      'Accordion.Item': Accordion.Item,
      'Accordion.Header': Accordion.Header,
      'Accordion.Body': Accordion.Body
    },
    parameters: { },
    argTypes: {...documentation, design}
  };
export default docs;

const Template = (args) => {
    return (
      <Accordion  {...args} defaultActiveKey="0">
          <Accordion.Item eventKey="0">
              <Accordion.Header>Accordion Item #1</Accordion.Header>
              <Accordion.Body>
                  Lorem ipsum.
              </Accordion.Body>
          </Accordion.Item>
          <Accordion.Item eventKey="1">
              <Accordion.Header>Accordion Item #2</Accordion.Header>
              <Accordion.Body>
                  Lorem ipsum.
              </Accordion.Body>
          </Accordion.Item>
      </Accordion>
  );
};

export const Default = Template.bind({});

and this renders (I think) correctly, or at least it is showing what I wanted:

image

The Accordion.doc.json file just contains the definition fo the argTypes:

{
    "activeKey": {
        "type": {
            "name": "string"
        },
        "description": "<p>The current active key that corresponds to the currently expanded card</p>"
    },
    "defaultActiveKey": {
        "type": {
            "name": "string"
        },
        "description": "<p>The default active key that is expanded on start</p>"
    },
    "flush": {
        "type": {
            "name": "boolean"
        },
        "defaultValue": false,
        "description": "<p>Renders accordion edge-to-edge with its parent container</p>"
    }
}

What I really fail now to figure out, is where am I supposed to get the argTypes for the sub components to render the controls correctly, can you give me any clue?

Edit: forgot to mention, I did not use the displayName property, I didn’t set anything for the purpose.

1reaction
shilmancommented, Aug 9, 2020

This is fixed in 6.0, closing. Either:

import { Meta, ArgsTable } from '@storybook/addon-docs/blocks';

<Meta component={Foo} subcomponents={{ Bar: Baz }} />

OR:

<ArgsTable components={{ A: Apple, B: Banana, Cherry }} />
Read more comments on GitHub >

github_iconTop Results From Across the Web

Addon Docs subcomponents support for sub ... - Issuehunt
Is your feature request related to a problem? Please describe. I use Component.SubComponent for my components and I want to show prop tables...
Read more >
DocsPage - Storybook - JS.ORG
It aggregates your stories, text descriptions, docgen comments, args tables, and code examples into a single page for each component. The best practice...
Read more >
Storybook Docs with mdx support and addon knobs - Medium
Props for Subcomponents: Sometimes components require sub components to work. You can now indicate these and show the propTypes needed for each ...
Read more >
Support for subcomponents | Jira Server and Data Center
We have a huge list of projects each managed by an individual group. Each group of course is working on more than one...
Read more >
Input Group | Components - BootstrapVue
You can attach addons using either props, named slots and/or sub-components. Using prepend and append props. Values will be internally wrapped by a...
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