-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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 subcomponents support for sub element components #9444
Comments
@shilman It is but for exported regular Components and not for sub-components.
|
@blind76 this doesn't work? import Component from '../Component';
export default {
component: Component,
subcomponents: { SubComponent: Component.SubComponent },
};
export const someStory = () => (
<Component>
<Component.SubComponent>Content of subcomponent</Component.SubComponent>
</Component>
); |
@shilman no it's not. Primary component (tab Undefined) has correct props table but other tabs just say "No props found for this component" |
Ah, add a As for the prop support for subcomponents, can you share the source of |
something like this: https://github.com/koldy/ui/blob/master/src/components/Table/Table.js |
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! |
@shilman I am so psyched this is a feature! However, I don't think the main component's tab (the first one) actually keys off the title. For me, it seems to be keying off the functional component name or the // MainComponent/index.js
// MainComponentContainer.displayName = 'MainComponentContainer'
import MainComponentContainer from './MainComponentContainer';
import SubComponent from './SubComponent';
// ...other subcomponents...
const MainComponent = MainComponentContainer;
MainComponent.SubComponent = SubComponent;
// ...
export {
MainComponent,
}; And then my story file: export default {
title: 'Components|MainComponent',
component: MainComponent,
subcomponents: {
'MainComponent.SubComponent': MainComponent.SubComponent,
// ...
}; The subcomponent tab renders according to the key I set as expected, but the first tab ends up being "MainComponentContainer." Is the EDIT: Just confirmed the tab name is coming from Also, is there any way to get a subcomponent's description to show up above the props table when its tab is selected? Would be a nice-to-have... |
@Smolations Yeah this looks like a bug. I'd rather not introduce another parameter for naming the component tab -- if the bug was fixed would that be sufficient for your use case? |
@Smolations do you have props table for subcomponents or it says: "No props found for this component |
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! |
@shilman Should this also work when writing stories in MDX? I've tried this but it's not working
|
@Pete-Robelou should work with:
Note the extra pair of braces. what version are you on? possibly broken in 6.0-alpha since it was massively rewritten. |
The extra pair of braces didn't work. I'm on 5.3.18. I assume this is correct for the props table?
|
Yes or tabs with:
|
👍 That works. I've removed |
Hi, it seems https://github.com/storybookjs/storybook/blob/next/addons/docs/src/blocks/Meta.tsx |
This is fixed in 6.0, closing. Either:
|
Easy way to do this is to define the child's display Name const SubComponent = ({children}) => {
return (<div>{children}</div>)
}
export default SubComponent; Component.jsx import SubComponent from './SubComponent';
const Component = ({children}) => {
return (<div>{children}</div>)
}
SubComponent.displayName = "Component.SubComponent"; {/* This now changes the displayname from SubComponent to Component.SubComponent */}
Component.SubComponent = SubComponent;
export default Component; Component.stories.jsx import Component from './Component';
export default {
title: 'Example/Component',
component: Component,
subcomponents: { 'Component.SubComponent' : Component.SubComponent },
};
const Template = (args) => (
<Component {...args}>
<Component.SubComponent>shit</Component.SubComponent>
</Component>
);
export const SomeStory = Template.bind({});
SomeStory.args = {
collapsed: false,
}; |
@bnannierI love the innerText of the SubComponent.. I am using this code:
and this renders (I think) correctly, or at least it is showing what I wanted: The Accordion.doc.json file just contains the definition fo the argTypes:
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. |
Hi, I think is a better approach set the display name in the subcomponent because you don't need to extract it in the parent component: const SubComponent = ({children}) => {
return (<div>{children}</div>)
}
SubComponent.displayName = "Component.SubComponent"; {/* This now changes the displayname from
export default SubComponent; |
@norcino thanks for the guide! did u manage to load descriptions for the subcomponents ?
I loaded the subcomponents, but could not find a way to fill in the descriptions of the subcomponents table. |
@clukhei sorry I didn't get the notification or I missed it. |
Hey man, 404 page! Was it moved somewhere? |
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...
The text was updated successfully, but these errors were encountered: