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

Feat: Do not put component into global namespace #1116

Merged
merged 2 commits into from Sep 3, 2018
Merged

Conversation

sapegin
Copy link
Member

@sapegin sapegin commented Aug 30, 2018

BREAKING CHANGE:

Style guide componets are no longer accessible on window. Only current component is accessible in the example context (not on window). You need to explicitly import any other component.

BREAKING CHANGE:

Style guide componets are no longer accessible on window. Only current component is accessible in the example context (not on window). You need to explicitly import any other component.
@sapegin sapegin added this to the 8.0.0: New editor milestone Aug 30, 2018
@@ -44,6 +44,22 @@ Fenced blocks with other languages are rendered as highlighted code:
<h1>Hello world</h1>
```

Current component (like `Button` in this example) is always accessible by its name in the example code. If you want to use other component, you need to explicitly import them:
Copy link
Collaborator

Choose a reason for hiding this comment

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

grammar, either:

If you want to use another component, you need to explicitly import it

or

If you want to use other components, you need to explicitly import them

@tizmagik
Copy link
Collaborator

tizmagik commented Sep 1, 2018

I really like this change! Will help a lot with large styleguides. 👍

@sapegin sapegin merged commit a895dc4 into next Sep 3, 2018
@sapegin sapegin deleted the no-globalize branch September 3, 2018 11:46
@phpnode
Copy link
Contributor

phpnode commented Sep 3, 2018

This change is bittersweet to me, I understand the reasoning but it does take away some convenience, especially when experimenting with examples in the code editor. To be honest it's making me reconsider using markdown at all - normal .js files obviously have tooling advantages.

Would you accept a PR which:

  • Injects components into the function scope rather than polluting window?
  • Makes the above an opt-in configuration option.

I've got a project with 283 markdown files here and not enjoying the prospect of converting them by hand!

@sapegin
Copy link
Member Author

sapegin commented Sep 4, 2018

Keep in mind that the current component is still available, and in my experience it's the majority of the use cases.

You can use context option to list components you want to access in your examples — that should be more reliable than autoloading everything on Styleguidist side, which will have similar issues with duplicated component names, that we have now.

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.

None yet

3 participants