-
-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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: Make Preview work for arbitrary jsx #7844
Comments
<Preview>
work for arbitrary jsx
I'm just making guesses here, so Shilman, you can ignore me if I'm way off. I assume that the source code is coming from the storysource addon behind the scenes, so only stories have access to the sourcecode. Would it make more sense/be easier to have a new Doc Block for arbitrary code, and keep |
hi, it seems the What do you think of the following solutions, all of which will load the full storiesHash, but will limit the visibility of the story in the navigation (tree view, prev, next):
|
I don't like the idea of creating dummy stories (although I'm doing it for Docs-only MDX #7719, and you could refactor that to handle this use case too if you wanted). The story store has a lot of stuff hanging off it, and I'm worried about adding more unnecessarily. Meanwhile, I handle source differently between CSF stories and MDX stories. CSF stories use Here's my counter-proposal:
2a would mean the user could use either Story or freeform JSX. 2b would mean the user could use both, but the results would be weird if the user used Story refs. The only part I haven't done is modify the MDX AST in the compiler, but I'm sure it's possible. And the
|
Cool ill give it a try, if i cant figure it out the mdx compiler will post here so someone else can takea stab. |
@shilman can you please check if this is what you had in mind for the mdx compiler: currently it does a double pass - exporting the strings in addition to updating the props, but we can optimize this. also I am currently displaying the full code with the Preview element as more formatting was lost when just iterating through the children. Also if @matthewmatician has multiple of those embedded previews to give it an early test? |
Looks great @atanasster 🙆♂ |
Thanks, i ll clean it up, write some tests hopefully to submit a PR tomorrow. I get panic attacks when i have to merge :) |
Cool! To be clear, we won't be able to merge this until 5.2 is shipped, which should be next week (knock wood) and once it's merged it'll be "early alpha 5.3" so it's fine if there are some corner case bugs. |
Ah yes, of course. Also when you have some time to review it please let me know if you want to move some of the string exports into props. |
@shilman - how can I run tests/update snapshots for the addons, or specifically addons/docs? |
@atanasster To update snapshot tests:
|
thanks, I didn't realize --core worked for the addons |
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! |
Hurrah!! I just released https://github.com/storybookjs/storybook/releases/tag/v5.3.0-alpha.20 containing PR #7966 that references this issue. Upgrade today to try it out! You can find this prerelease on the Closing this issue. Please re-open if you think there's still more to do. |
Is your feature request related to a problem? Please describe.
Sometimes I we want to use arbitrary jsx in our mdx files, but we'd love to use a
<Preview>
component to wrap that jsx and allow people to easily see the source.Describe the solution you'd like
When I use the
<Preview>
component in an mdx file like this...I can see/copy the source code of this story. I'd also like to see the source code when I do this:
Describe alternatives you've considered
We tried just making a story for every example needed in our mdx files, but then our list of stories gets really long. Also, it's a little painful to have to go find the identifier for all of those stories that were created.
Are you able to assist bring the feature to reality?
I'd love to help if I can. Might need some direction.
The text was updated successfully, but these errors were encountered: