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:Custom Props table

See original GitHub issue

Is your feature request related to a problem? Please describe. No

Describe the solution you’d like I can pass a parameter to control the props table,

  • Pass a array to define which item should we display
  • Can use custom item name, like I want to display Chinese th like ['姓名', '类型', '默认值','描述'] but not ['name', 'type', 'default', 'description']

So I want to display name, type, default, description when I pass a parameter

[
  {
    key: 'name',
    label: '姓名',
  },
  {
    key: 'type',
    label: '类型',
  },
  {
    key: 'default',
    label: '默认值',
  },
  {
    key: 'description',
    label: '描述',
  }
]

Are you able to assist bring the feature to reality? image

image

https://github.com/storybookjs/storybook/blob/bf1b95564053aacc8d4b00479485beb655ef21b4/lib/components/src/blocks/PropsTable/PropsTable.tsx

Seems it really a feature need to add -_-, I really want to do contribution

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
fgaleanocommented, Jan 29, 2021

Semi-documented here for 6.0 here: https://github.com/storybookjs/storybook/blob/next/addons/docs/docs/props-tables.md#customizing-argtypes

@shilman How can this customizations be applied to subcomponents used in story?

This works great for the main component’s props table, but when I have multiple subcomponents with their own props table, I can’t figure out how to configure those props tables. I’m talking about this:

export default {
    title: 'Header',
    component: Header,
    subcomponents: { 
        Navigation,
        NavigationItem, 
        SecondaryNav: null, 
        SecondaryNavItem: null, 
    },
    parameters: { docs: { description: { component: readme } } },
    args: {
        useSparkPanel: false,
    },
    argTypes: {
        useSparkPanel: {
            table: {
                disable: true
            }
        },
        children: {
            table: {
                type: { 
                    summary: 'instace of <Header.Nav>', 
                    detail: 'Expects instance of <Header.Nav> with collection of <Header.NavItem>.' 
                },
            },
            control: {
                type: null,
            },
        },
        secondaryNav: {
            table: {
                type: { 
                    summary: 'instace of <SecondaryNav>', 
                    detail: 'Expects instance of <Header.SecondaryNav> with collection of <Header.SecondaryNavItem>' 
                },
            },
            control: {
                type: null,
            },
        }
    }
};

I need to add some custom type values to some of those subcomponents. Can it be done with the current APIs available?

Thanks!

1reaction
shilmancommented, Apr 26, 2020

@Smolations good news. 6.0 props are super configurable, using a completely different mechanism. Will try to get your use case across when I write that part of the documentation.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ArgsTable - Storybook - JS.ORG
Storybook Docs automatically generates component args tables for components in ... { ArgsTable } from '@storybook/addon-docs'; import { MyComponent } from '.
Read more >
storybook/addon-docs
DocsPage is a zero-config aggregation of your component stories, text descriptions, docgen comments, props tables, and code examples into ...
Read more >
Storybook Docs with mdx support and addon knobs
In the component's mdx page, I give examples of the component. Prop Tables. Prop tables on the documentation pages are much improved. These...
Read more >
Storybook: addons/docs/docs/props-tables.md
To use the props table in MDX, use the ArgsTable block: // MyComponent.stories.mdx import { ArgsTable } from '@storybook/addon-docs'; import { MyComponent } ......
Read more >
Compare DocsPage and MDX syntax in Storybook with ...
card.stories.mdx --> import { Meta } from '@storybook/addon-docs/blocks'; ... Although our Card component has default values for its props , on initial ...
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