-
-
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: Generate escape hatches automatically for blocks #9177
Conversation
This pull request is being automatically deployed with ZEIT Now (learn more). |
Have you done a search for "sbdocs" ? You might have missed a few, please have a look at the file: https://github.com/fraincs/storybook/blob/next/lib/components/src/html.tsx |
Could you add escape hatches on the props table column (td elements)? |
|
||
export function docsEscapeHatch(component: FunctionComponent, additionalClasses?: string): string { | ||
const name = component.displayName || component.name || ''; | ||
const cleanName = `sbdocs sbdocs-${caml(name)}${additionalClassesFormatting(additionalClasses)}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if name is empty?
The whole point of accepting additionalClasses is to output the proper formatting when we can't find a name for the component.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
docsEscapeHatch
should call docsEscapeHatchFromId
@fraincs "now" can't deploy a preview because there is TypeScript error. Can you have a look please https://zeit.co/storybook/monorepo/o4k4ufaqa |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@fraincs "now" can't deploy a preview because there is TypeScript error. Can you have a look please https://zeit.co/storybook/monorepo/o4k4ufaqa
This seem to happen because some component are not aware that they should accept a className especially styled components.
@shilman @ndelangen any idea how @fraincs could fix this? #9177 (review) |
The error is correct, the component doesn't support the |
In order for the className to work, it will have to be added to the component to support it. |
Is there any chance that the "escape hatchets" feature can be extended beyond the docs? I would like to at least be able to customize some of the core components -- some of which the docs blocks use indirectly. (I was personally looking to add support for this to the ActionBar component). And probably a topic for a separate PR/Issue, but I would really like the component injection feature available in docs (ability to override |
Also. Is there any concern around the separation of concerns with this patch? I just find it odd that the |
Hi @GeorgeTaveras1231, thanks for your input. Not much of an explanation but we discusss this issue here #8986 (comment) I am not sure why the docs block are in the components project instead of the docs addon. Any idea @shilman ? |
No good reason. The idea is that the doc blocks are "smart" components that rely on the docs context. The components themselves are "dumb" and simply receive props. I put them in |
These presentational doc blocks components could live in a separate package at some point, so that they become easier to share / re-use outside the context of storybook? |
@ndelangen I can see that. Though I think there is a fine line between preparing for a likely future and premature optimization. As an outsider, it's hard to tell where this decision falls but it certainly confused me at first 😅 |
I see, if it helps speed up the dev iterations for now, I'm fine with packing the components into the addons/docs package. One day, I'll move it though 😎 |
@ndelangen I wouldn't go as far as to say that this change is necessary now. I'll defer to @fraincs who owns this PR. I just had a question about the code structure and you gave me a good answer so 👍 |
# Conflicts: # lib/components/src/blocks/PropsTable/PropValue.tsx # lib/components/src/index.ts
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! |
Hey there, it's me again! I am going close this issue to help our maintainers focus on the current development roadmap instead. If the issue mentioned is still a concern, please open a new ticket and mention this old one. Cheers and thanks for using Storybook! |
Issue: #8986
What I did
Added a utility function to generate sbdocs escape hatches.