Open wengsj11 opened 4 years ago
To achieve this you'll need to customize the args for your story by hand: https://storybook.js.org/docs/react/essentials/controls#fully-custom-args
To achieve this you'll need to customize the args for your story by hand: https://storybook.js.org/docs/react/essentials/controls#fully-custom-args
Is there any more specific examples to do that ? I tried but failed😂
I wonder if an API like the below could work to automate this? 🤔
Pretty nice @sami616 😻
@shilman not sure how TS users would type the second argument though, would an intersection type work?
subcomponents: SubOneProps & SubTwoProps
Any update on this? My company uses subcomponents.
Having the same issue. I have Card
component, which I'll use as a wrapper. I have a few other components - CardActions, CardImage, CardText and CardTitle, which I'll use as children. I'd like to be able to use the Controls pannel to change the children's args. The approach from the docs didn't work for me. When I try to use the subcomponents field in the Card's story, I see the Args unsupported. See Args documentation for your framework.
in the Docs panel.
card.stories.jsx (removed business logic for simplicity)
export default {
title: "Components / Card",
component: Card,
subcomponents: {
CardActions,
CardImage,
CardText,
CardTitle
},
argTypes: {
children: {
description: "The content of the component.",
type: "node"
}
}
};
export const Example = (args) => <Card {...args} />;
Example.args = {
children: (
<>
<CardTitle>Lorem Ipsum</CardTitle>
<CardImage src="https://picsum.photos/536/354" alt="lorem ipsum" />
<CardText>
Lorem Ipsum is simply dummy text of the printing and typesetting
industry. Lorem Ipsum has been the industry's standard dummy text
ever since the 1500s, when an unknown printer took a galley of type and
scrambled it to make a type specimen book.
</CardText>
<CardActions>lorem ipsum</CardActions>
</>
)
};
Canvas panel:
Docs panel:
I tried to describe each subcomponent, like this:
export default {
title: "Components / Card",
component: CustomCard,
subcomponents: {
CardActions: {
component: CardActions,
argTypes: {
children: {
description: "The content of the component.",
type: "node"
}
}
}
},
...
}
The result was the same. Any with ideas are welcome
Yeah, would be really nice to get some help on that, the way that @mayyamark show, would be the perfect solution for subcomponent and args :)
Any updates on that ?
+1
Any updates ?
+1
+1
+1
+1
+1
+1, can't get the subcomponents tab to show. Even with the exact same sample code from the docs.
+1, can't get the subcomponents tab to show. Even with the exact same sample code from the docs.
What Storybook version you are using?
Describe the bug subcomponents doesn't show controls column in prop tables.
To Reproduce my component is like this, it has a father component ConditionPanel, and a child component Item which would be passed into ConditionPanel as children props. While the father component is showing the controls column, the subcomponent isn't.
Expected behavior show all the subcomponents controls, and be able to control the main story.
Screenshots
Code snippets my
x.story.js
fileSystem:
Additional context None