-
Notifications
You must be signed in to change notification settings - Fork 215
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
Convert JS stories to MDX #584
Comments
Stories that still need to be converted:
|
Thanks for adding the checklist @obulat. Very helpful to keep a track! |
Just wanted to point out here what had been mentioned in the WP Make Slack (needs an account, which you can create here). Basically MDX does not currently have TypeScript support. If it ever did, because of it's nature as a React based extension on Markdown, it will necessarily require the The JS stories, on the other hand, could be converted to TypeScript and included into the TypeScript project (potentially with similar issues around getting type resolution, but at least then we can try other dependency resolution or TypeScript tricks to remove the If we go the MDX route, then we probably have to accept that the stories will not be able to be type checked any time in the foreseeable future, not until some compatibility shim is created to make React JSX types and Vue JSX types live happily together (seems unlikely to me given the communities have basically no overlap outside of Storybook). |
It seems that we have to choose between having the ability to document the components in prose using MDX and the ability to type-check components in Storybook. I really like how we can write about the components in the Docs tab. I think we should use this even more than we are using now. We could add more details about when to use which component or which variant of the component. The example that comes to mind is the buttons, which have some variants that currently seem to overlap. Can we say that we can rely on the app code and the unit tests for the correct typing in the component, and leave the Storybook components without the check? The types are usually shown correctly in the args table. If you rely on the Storybook for examples of how to use a component in the app, it will check your types there and warn you if necessary. |
We can still write stories as prose, of course, just not as Markdown. Or we even could use Markdown if we wanted, using, for example, something like this component (but maybe not it exactly, I haven't evaluated it closely as an acceptable dependency or not). Stories could be written fully as a Vue component in the
// components/VMagic/meta/VMagic.DefaultStory.vue
<template>
<div>
<VMarkdown>
## VMagic
`VMagic` is a component with magical super powers.
<!-- etc ... -->
</VMarkdown>
<VMagic v-bind="$attrs">
<!-- etc ... ->
</VMagic>
</div>
</template>
It's not as straightforward as MDX (if you consider MDX to be straightforward) but considering the stories are the place where we're meant to exercise the components to the fullest, it does seem wise to me for them to also by type checked. |
Hi, I would like to contribute on this matter. Could you please assign it to me? |
@sepehrrezaei Apologies, but I think this issue might need some additional ticket work to decide how the project best wants to solve it. @dhruvkb and @obulat do y'all have any objection to the approach I shared above? I do think it's important that the stories are type checked. |
@sarayourfriend I still prefer MDX because of the following reasons.
To summarise, personally, I favour MDX and am willing to lose type safety in the stories to use it. However, if you could make a PR, we can all see how the end result looks (from the PR preview) and make a final call on what works. |
Ahhh, I did not realise exactly what this meant before, but now I do. I agree then that my suggestion is not an adequate solution to the issue. |
@sarayourfriend & @dhruvkb So after your discussions, Can I work on it ? |
@sepehrrezaei Yup! I've assigned the issue to you 👍 Thanks for hopping in. |
Problem
JS stories have many shortcomings compared to MDX. While MDX stories can be cumbersome, they really shine when it comes to being able to write long-form documentation, including helpful tips about the props, functionality and expected use-cases of components. In a sense, they're almost equivalent to having a
README.md
for every component.This has been spun-off from this discussion.
Description
The goal is to convert the existing JS stories to their MDX counterparts. To keep PRs reviewable, please do only one or two components at a time.
Alternatives
We can continue to use a mix of JS and MDX stories as currently done. This is bad because why would you mix two ways of doing one thing in one project.
The other alternative is to go the other route (aka backwards) and convert all MDX stories to the less flexible JS format. This would add consistency but at a huge price.
Additional context
There are a lot of MDX stories in the repo to refer to. Just pick the longest, more comprehensive one as a reference.
Implementation
The text was updated successfully, but these errors were encountered: