-
-
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] How to customize order of props table and previews? #8377
Comments
Looking through the source code it seems like there's meant to be a way to do this, but I get an empty props table that says "no component found"
I also think it could be easier to use MDX with examples if the ID wiring were explicit rather than using strings you discover by running the app. For example:
|
Hi @necolas! Let me try to answer with what's already there, and then maybe we can figure out what changes would be useful. For the props table, try:
For customizing/overriding the
Let me know what you think! |
Hi Michael,
Thanks this did the trick! At the moment I manually document types as follows (to avoid cluttering the docs with the shared types):
The automatic storybook props table will inline all the View props. That's understandable and I'm not really sure how it could be any different. But thought I'd share.
Thanks, sorry I missed that, I'll give it a try! |
@necolas Just fixed a bug in that recipe, sorry! https://github.com/storybookjs/storybook/blob/next/addons/docs/docs/recipes.md#csf-stories-with-mdx-docs |
When I do:
The code shown is I'd also like to avoid having the sidebar show the individual stories, and have it behave more like a "doc" type, e.g., the "introduction" MDX example. Is that possible? |
I noticed that |
😭 #8024 |
Is there an Issue created for this? I wasn't able to find a corresponding one in my search. I'd be happy to make one if there isn't. I love the MDX docs for everything else it provides, but the code block not working is unfortunately a dealbreaker for using that format. |
@DigTheDoug @necolas If you just define the stories in MDX, story source works perfectly. MDX files are loadable just like CSF and actually export an identical interface once loaded. But feel free to create an issue to track improving the source for the CSF/MDX mix case. Thanks! 🙇 |
@necolas Thanks, I was aware of that, but I feel that you give up the benefits of using CSF in that case, like having the portable components to use in testing, being able to define shared variables for stories, etc. But I will make an issue and at least see if others have any opinions or suggestions. Thanks! |
@DigTheDoug True, there are advantages to using CSF. You can also document it with DocsPage, which doesn't have this issue. Let me see if I can hack in a solution to the MDX problem tomorrow. Might actually be an easy fix! 😄 |
Thanks @shilman, let me know if I can do anything to help! To be clear, DocsPage is awesome and a huge addition to Storybook and I started testing it out as soon as it was announced to see if we could move our existing docs over to reduce the various things we have to manage. I'm trying to match the parity of our design system docs that currently exist in mdx, but in a separate gatsby context. They have descriptions for each story as well as usage guidelines, best practices, etc. Anyways, thanks again for looking and let me know if I can help. |
Another quirk I've encountered is that the const ChildrenContainer = styled.div<PreviewProps>(({ isColumn, columns }) => ({
display: 'flex',
flexWrap: 'wrap',
flexDirection: isColumn ? 'column' : 'row',
marginTop: -20,
'> *': {
flex: columns ? `1 1 calc(100%/${columns} - 20px)` : `1 1 0%`,
marginRight: 20,
marginTop: 20,
},
})); https://github.com/storybookjs/storybook/blob/next/lib/components/src/blocks/Preview.tsx#L20-L31 Adding |
@necolas would it be possible for you to issue a small PR if you think this a generalizable fix? I'm not sure I get it, but if it's in the PR and there's a repro in |
Do I put the patch up against 'next' branch? What's 'official-storybook'? |
I don't understand how PRs work in this repo but here's a patch to illustrate what I meant #8628 |
Did this change in one of the alphas? I updated to 5.3.0-alpha.43 and all the propTypes tables stopped rendering content |
We're actively iterating the props table now, but I wouldn't have expected anything to break. Try upgrading to alpha.45? cc @patricklafrance |
Hmm upgrading didn't fix the issue. Here's an example: https://necolas.github.io/react-native-web/docs/?path=/docs/components-activityindicator This is how I have to populate the props table: https://github.com/necolas/react-native-web/blob/master/packages/docs/src/components/ActivityIndicator/ActivityIndicator.stories.js (The RNW storybook should also give you an idea of why I'd like to remove the accordion dropdown on each docs page that contains stories, and prevent the page scrolling down past the description and props table) |
Hi @necolas Thanks for the issue. The problem here is that ofProps doesn't have anything related to React. Try to update:
With
@shilman I dont see how this is related to the changes in 5.3. That might the bump to react-docgen 5.0 beta that cause the issue. |
Thanks @patricklafrance -- you rock!!! cc @danielduan on the I think it's reasonable to expect the "props-having object" to be a React component. @necolas WDYT? |
It was working in the 36 (ish) alpha. I only do this because the library itself doesn't use prop types or typescript, and the storybook doesn't use the library source files either. I'll try changing to return an empty div |
w00t!! I just released https://github.com/storybookjs/storybook/releases/tag/v5.3.0-beta.1 containing PR #8628 that references this issue. Upgrade today to try it out! You can find this prerelease on the |
This doesn't seem to make a difference.
The beta throws errors about |
Can you check your version and verify that all |
Hurrah!! I just released https://github.com/storybookjs/storybook/releases/tag/v5.2.8 containing PR #8628 that references this issue. Upgrade today to try it out! |
Any suggestions on how to get the props table showing again? |
Please upgrade all your |
Thanks. I'm using |
@necolas Of course it doesn't require you to use CRA. Just providing that as an example setup that's working. Can you share what's not working and we can take a look at it? |
@necolas Im pretty new to docs and Im struggling to understand how I can override sections on DocsPage using slots. Could you post me a quick example of how to achieve this for eg. the propsSlot? |
@kungfuyou Slots have been removed in 6.0. I recommend this instead. I think it should also work in 5.3: https://github.com/storybookjs/storybook/blob/next/addons/docs/docs/docspage.md#replacing-docspage |
I'm unable to display component props using the |
@coreybruyere when i install your project on my machine it appears to be working for me: There are some base props missing, which can be enabled by customizing the typescript handling: |
Thanks @shilman - missed that in the docs. Was focused on config docs and bypassed TS related docs. Need to learn to start reading the TS subsection in library docs more as a new TS convert! |
This is what I ended up using to filter unneeded props and display third party props I wanted -- In my case props from styled-system.
|
Is your feature request related to a problem? Please describe.
I would like the docs page for a component not to render the first "story" above the prop types table. Also for the preset to load
<name>.mdx
files and not just<name>.stories.mdx
.Describe the solution you'd like
How to customize the page so I can control the order of the blocks and rename titles like "Stories" to "Examples". Or, how to rely entirely on a custom MDX page and insert a props table.
Describe alternatives you've considered
I looked through the available docs for addon-docs but didn't find anything that could help me do this myself.
Are you able to assist bring the feature to reality?
No
The text was updated successfully, but these errors were encountered: