Skip to content
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

Closed
wants to merge 6 commits into from

Conversation

fraincs
Copy link

@fraincs fraincs commented Dec 17, 2019

Issue: #8986

What I did

Added a utility function to generate sbdocs escape hatches.

@vercel
Copy link

vercel bot commented Dec 17, 2019

This pull request is being automatically deployed with ZEIT Now (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

@patricklafrance
Copy link
Member

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

@patricklafrance
Copy link
Member

Could you add escape hatches on the props table column (td elements)?

https://github.com/fraincs/storybook/blob/next/lib/components/src/blocks/PropsTable/PropRow.tsx


export function docsEscapeHatch(component: FunctionComponent, additionalClasses?: string): string {
const name = component.displayName || component.name || '';
const cleanName = `sbdocs sbdocs-${caml(name)}${additionalClassesFormatting(additionalClasses)}`;
Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docsEscapeHatch should call docsEscapeHatchFromId

@patricklafrance
Copy link
Member

patricklafrance commented Dec 18, 2019

@fraincs "now" can't deploy a preview because there is TypeScript error. Can you have a look please https://zeit.co/storybook/monorepo/o4k4ufaqa

Copy link
Author

@fraincs fraincs left a 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.

lib/components/src/docsEscapeHatch.ts Outdated Show resolved Hide resolved
@patricklafrance
Copy link
Member

@shilman @ndelangen any idea how @fraincs could fix this? #9177 (review)

@shilman shilman added this to the 6.0.0 milestone Dec 20, 2019
@ndelangen
Copy link
Member

The error is correct, the component doesn't support the className prop:
https://github.com/fraincs/storybook/blob/next/lib/components/src/blocks/Description.tsx#L7

@ndelangen
Copy link
Member

In order for the className to work, it will have to be added to the component to support it.

@GeorgeTaveras1231
Copy link

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 Preview component for example) to be available for components used in the manager app. I've just found myself fighting against storybooks's theme API to get the desired results and in some cases have had little to no success

@GeorgeTaveras1231
Copy link

Also. Is there any concern around the separation of concerns with this patch?

I just find it odd that the components package has awareness of the docs escape hatchet feature. Seems like something that should be scoped to the addon-docs package

@patricklafrance
Copy link
Member

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 ?

@shilman
Copy link
Member

shilman commented Dec 24, 2019

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 lib/components per @ndelangen 's suggestion, in case other SB projects want to use them. Open to suggestions about how this might be better structured, but not super concerned about the current state of things (yet).

@stale stale bot added the inactive label Jan 14, 2020
@storybookjs storybookjs deleted a comment from stale bot Jan 14, 2020
@stale stale bot removed the inactive label Jan 14, 2020
@ndelangen
Copy link
Member

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?

@GeorgeTaveras1231
Copy link

@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 😅

@ndelangen
Copy link
Member

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 😎

@GeorgeTaveras1231
Copy link

@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 👍

@ndelangen ndelangen self-assigned this Jan 30, 2020
# Conflicts:
#	lib/components/src/blocks/PropsTable/PropValue.tsx
#	lib/components/src/index.ts
@stale
Copy link

stale bot commented Feb 20, 2020

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!

@stale stale bot added the inactive label Feb 20, 2020
@stale
Copy link

stale bot commented Mar 21, 2020

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!

@stale stale bot closed this Mar 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants