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

fix(addon-docs): support nuxt context in docs canvas #124

Merged
merged 3 commits into from Sep 16, 2020

Conversation

farnabaz
Copy link
Collaborator

@farnabaz farnabaz commented Sep 7, 2020

Types of changes

  • Bug fix (a non-breaking change which fixes an issue)
  • New feature (a non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Description

override prepareForInline in order to render stories inside docs canvas with nuxt context
close #121

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes (if not applicable, please state why)

@eisverticker
Copy link

I found a second issue, which is probably related to this one. It seems like assets (fonts, scss, ...) are not being loaded when you navigate to a components docs section directly

eg. http://localhost:4000/?path=/docs/typography--preview

Currently, you have to open the Canvas section first and then select the Docs section in order for assets to be loaded

@farnabaz
Copy link
Collaborator Author

farnabaz commented Sep 9, 2020

I found a second issue, which is probably related to this one. It seems like assets (fonts, scss, ...) are not being loaded when you navigate to a components docs section directly

It seems that the storybook does not load the entry file on the situation you are explained.

const el = React.useRef(null)
// FIXME: This recreates the Vue instance every time, which should be optimized
React.useEffect(() => {
Copy link

Choose a reason for hiding this comment

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

Is this only way to fix and listen for ? 😕

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is how docs addon work.
I don't see any workaround to refactor the code.

@farnabaz farnabaz merged commit 305c619 into master Sep 16, 2020
@farnabaz farnabaz deleted the prepareForInline branch September 16, 2020 11:14
@mariomka
Copy link

I found a second issue, which is probably related to this one. It seems like assets (fonts, scss, ...) are not being loaded when you navigate to a components docs section directly

eg. http://localhost:4000/?path=/docs/typography--preview

Currently, you have to open the Canvas section first and then select the Docs section in order for assets to be loaded

Is there any workaround about this?

Thank you!

@farnabaz
Copy link
Collaborator Author

@mariomka Do you have a problem using the latest version? If so please provide a reproduction sample for it.

@mariomka
Copy link

@farnabaz Yes, I have a problem using the last version 3.0.0. I found a workaround, import scss file directly into the preview.js file and add fonts manually in preview-head.html, it's not the best solution but it works.

I hope I have time this weekend to provide a reproduction.

@mariomka
Copy link

@farnabaz I found the root of the problem, it happens when you add custom configuration files (main.js, and preview.js).

Reproduction repo: https://github.com/mariomka/nuxt-storybook-docs-assets-issue

Just clone, install yarn dependencies, run storybook, and visit http://localhost:3003/?path=/docs/customtext--text directly, then go to the Canvas tab.

You can checkout the previous commit to seeing how it works well without custom configuration files.

@mariomka
Copy link

@farnabaz have you been able to take a look?

@farnabaz
Copy link
Collaborator Author

@mariomka Sorry for the late response and thank you for the reproduction repo.
This will be fixed by 8b733f4.
I will publish next release ASAP

@mariomka
Copy link

mariomka commented Nov 8, 2020

Thank you @farnabaz! Today I've was updating it and trying it, and now styles load well but fonts still don't load until you open the canvas tab. I've updated the reproduction repo with the new version.

@farnabaz
Copy link
Collaborator Author

@mariomka Sorry for the late response. Could you create an issue for it and a sample reproduction project?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Nuxt-Addons are not being loaded correctly in Docs Canvas
4 participants