-
-
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
[Bug]: Unable to use Description without a Story in MDX #19964
Comments
I've got this issue too, after a bit of digging I found that |
Same here, but I'm using Here's another quick reproduction repo: https://github.com/renato-bohler/storybook-repro The "Example" story will load if I remove the Otherwise, the story will go blank and the following message appears on DevTools ( |
Don't know if my issue is related, but I'll add it here too. After upgrading to Storybook 7 I am noticing that my docs-only pages are no longer working if they have Story objects in them. In our application we have 3 basic pages to describe the use of typography, icons and color.
I have tried using the Story and Canvas components from 2 different places, both without success:
Rendering the components without a story (so System specifications:
|
i ran into this same error also using same thing as @HendrikPetertje e.g. the Story with id inside a Canvas. I could also revert to just rendering a component directly but I like to use it in a Canvas cause then it has the "Show code" link on the canvas |
@cmdcolin, shall I make a seperate issue for it? |
In
|
Thanks for the detailed reports here folks! Ok, in all three cases here ( Context:
@JReinhold I think the right way forward on this issue is to create stories in our doc blocks SB for these usages where the docs context has no primary story. Then we'll have an easy reproduction to work from. |
thanks so much for digging in to this and finding the root cause! I don't have the bandwidth (time-wise) to go in and fix this right now today, but you have given a good start point and idea for a fix here! I'll keep an eye on this issue and if it isn't resolved due to all the stuff you folks already do (so amazingly) then I might give this a look in the near future! |
Thanks for the kind words @HendrikPetertje! This is definitely on our radar for 7.0; @JReinhold and I will likely take a look in the new year together. |
Via `relativeCsfPaths: []`. This demonstrates the issue from #19964
@JReinhold I proved the concept on #20362 |
I browsed the docs for 7.0 and got an impression that it's totally possible to use doc blocks in documentation-only mdx pages, but then run into this issue 😢 Would be a really useful feature, looking forward to it! |
Whoopee!! I just released https://github.com/storybookjs/storybook/releases/tag/v7.0.0-beta.25 containing PR #20563 that references this issue. Upgrade today to the
Closing this issue. Please re-open if you think there's still more to do. |
Thanks for the update! I upgraded my project to |
There are @jordanandree! This ticket probably got closed early due to linking of the description PR to it. |
@JReinhold thanks for the quick reply and the explanations.
Yeah, it was a feature documented here : Non-story content (last block on the page if the anchor does not work properly) |
Thanks @mdaoust-sidlee, I've fixed it in #20803, should be released in the next couple of days. |
@JReinhold does that mean you can no longer do multiple stories in one canvas? |
@JReinhold using doc blocks in docs-only mdx files works great, the only caveat that i have run into is that you cannot import stories in Something like this in a import * as ComponentStories from '../../components/src/Component/Component.stories';
<Canvas of={ComponentStories.Default} /> will render correctly, while this: import * as ComponentStories from '@components/Component/Component.stories';
<Canvas of={ComponentStories.Default} /> will fail with A little debug reveals that with the second scenario The aliases itself are resolved because i can Did i run into some known limitation or is it a problem with my setup and you would need a reproduction from me? |
Yes @Alxandr. Its implementation was weird and it had many unexpected behaviours. I'd love to hear which use cases you have for having multiple stories in a single canvas though, maybe we can revisit and find a suitable API for it in a later iteration. We just haven't really seen any good use cases that justifies it yet - but they might be out there. @fmal that sounds like a bug for sure, could you open a new issue with a minimal reproduction? |
The issue here will be that we need to interpret that import in the story indexer (which reads your MDX file statically). I'm not sure it is feasible for it to understand things like aliases. WDYT @shilman? |
Showing all the variants of a small component (e.g. a button) in a summary view at the top of a document. |
@JReinhold it's mostly a visual thing. What we have currently is this: ## Sizes
<Canvas>
<Story name="Large">
<Button>Large button</Button>
</Story>
<Story name="Small">
<Button size="small">Small button</Button>
</Story>
</Canvas> which renders as following: While also producing 2 stories. I use the same pattern multiple places: I mostly just care about the border/look of the The last example I have is this: <Canvas withSource="none">
<Unstyled>
<H1>H1 - Heading - Overskrift</H1>
<H2>H2 - Form title - Skjematittel</H2>
<H3>H3 - Section title - Grupperingstittel</H3>
<H4>H4 - Form elements title - Tittel over skjemafelter</H4>
<P>Txt - Body text - Brødtekst</P>
<Span>Txt - Unstyled text</Span>
</Unstyled>
</Canvas> This more or less shows what I really want. The "look" of a canvas, with no storybook styling inside, and then showing multiple stories in that "box". In this case: |
@JReinhold, Thank you so much for your help on these various problems. A non-story Canvas on the root of the mdx file now work perfectly, but here's an example of an implementation that is still problematic. Wrapping the
|
I'm sorry @mdaoust-sidlee I'm having trouble reproducing this, it works fine when I write the code in your example. Could you create a minimal reproduction, maybe in a separate issue? |
Thanks for the feedback @Alxandr. It sounds like you just want the styling and don't really care for the Canvas functionality. In that case you can easily build a component with that styling yourself, and use everywhere in your MDX files. Either by building a React component: export const StoryContainer = (props) => {
return <div className="sb-unstyled" style={{ nice border and padding...}} {...props} />
} or by defining a CSS class that you can use directly in MDX: <div className="sb-unstyled story-container">
<H1 .../>
<H2 .../>
</div>
|
@JReinhold yes. I looked into doing that first, but I wanted it to look the same as the actual canvases I used. And looking at the code, there's quite a bit involved in getting the same style as the builtin blocks:
I guess what I really would want is a block that has this "preview" view, as just a simple styled component. |
- Closes #35 - Add `useThrottleValue` and `useThrottleFunction` hooks to `too-many-hooks` - Create docs for `useThrottleFunction` and move API story from `useDeepCompareEffect` to `useThrottleFunction` - Create docs and stories for `useThrottleValue` - Add throttled counter story for easy-to-understand visualization of throttling - <img width="1433" alt="image" src="https://user-images.githubusercontent.com/39521214/217443500-8a186884-0132-4e68-820e-2f4a99802a65.png"> - Add searching example for a real-world use case - <img width="1419" alt="image" src="https://user-images.githubusercontent.com/39521214/217443763-ac280496-8723-4b72-8594-57f7743d9494.png"> - Upgrade to storybook 7.0.0-beta.44 to make storyless docs work (storybookjs/storybook#19964) plus other bonuses such as functioning hot-reloading!
I think this is still bugged with import { Meta, ColorPalette, ColorItem } from '@storybook/blocks'; |
For someone still face the problem |
Seems to work fine for
|
Looks like
If someone wants to open a new ticket or even send a PR, I'll take a look.
|
FYI we already have an issue open to update the remaining doc blocks here: #22490 |
The Is there anyway to integrate into MDX third party custom components like https://github.com/rajinwonderland/react-code-blocks ? |
Enable `*.stories.mdx` in Storybook config. Comment out Subtitle from Icons story to avoid error: "Error: No primary story defined for docs entry. Did you forget to use `<Meta>`?" This error seems to be related to: storybookjs/storybook#19964 storybookjs/storybook#22490
Enable `*.stories.mdx` in Storybook config. Comment out Subtitle from Icons story to avoid error: "Error: No primary story defined for docs entry. Did you forget to use `<Meta>`?" This error seems to be related to: storybookjs/storybook#19964 storybookjs/storybook#22490
I'm running into this issue again with I'm just trying to wrap a piece of JSX in a |
I'm having the same issue after upgrading to v8. Should this issue be reopened or should we raise a new one? |
I ran into this issue after auto-migrating to the new MDX+CSF format. In v7, I used docs-only stories like the following: import { ArgsTable, Description, Meta } from '@storybook/addon-docs';
import { MyComponent } from './my.component';
<Meta title="My Component" component={MyComponent} />
<Description />
<ArgsTable /> They were auto-migrated to the following, which produces runtime errors: import { Controls, Description, Meta } from '@storybook/blocks';
import { MyComponent } from './my.component';
<Meta title="My Component" component={MyComponent} />
<Description />
<Controls /> I got it working again by changing from import { ArgTypes, Description, Meta } from '@storybook/blocks';
import { MyComponent } from './my.component';
<Meta title="My Component" />
<Description of={MyComponent} />
<ArgTypes of={MyComponent} /> |
Any updates on this issue? I can't upgrade to Storybook 8 because my project doesn't support node.js 18 yet. |
Describe the bug
An MDX (docs only) story with a
Description
errors with:To Reproduce
Create an MDX story file with
Meta
and aDescription
of a component:Reproduction: https://github.com/will-stone/storybook-description-bug
System
Additional context
This used to work (I last tested on alpha 48 but not sure which alpha between then and now was the one that changed). It is useful to be able to grab the JSDoc description of components/functions without having a Story. For example, we use this as a way to document our hooks and utility functions.
The text was updated successfully, but these errors were encountered: