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

Use iframe for Playground #789

Closed
zicodeng opened this issue Apr 12, 2019 · 14 comments
Closed

Use iframe for Playground #789

zicodeng opened this issue Apr 12, 2019 · 14 comments

Comments

@zicodeng
Copy link

zicodeng commented Apr 12, 2019

The default Docz <Playground> is really cool, but it does not serve your components in an isolated browsing context

The disadvantages of shared browsing context are:

  • It makes developers hard to test component responsiveness
  • Possible CSS collisions between Docz default theme style and component style

I have seen multiple requests for this feature in the roadmap: http://feedback.docz.site/roadmap/p/use-iframes-for-each-playground and https://docz.canny.io/roadmap/p/open-playground-in-new-window

What is the current status of this feature? Is it in progress? I didn't see it in v1 release

If people need a temporary solution, I made a simple iframe wrapper: https://github.com/zicodeng/docz-iframe-playground

@martpie
Copy link

martpie commented May 3, 2019

This is actually quite an important feature: every time you use global styles, or absolute styling, things get really messy. Styles also conflict with Docz styles, and responsive cannot be tested properly.

@kempsterrrr
Copy link

+1 on this. I just spent quite a long time trying to work this out before releasing it wasn't supported :(

Everything else about the library is amazing

@Tauka
Copy link

Tauka commented Jun 10, 2019

Very unfortunate that docz doesn't have iframe, major reason why I switched to storybook

@zicodeng
Copy link
Author

Hi, if you are looking for built-in iframe playground solution, check out new Docz theme - Ztopia: http://docz-theme-ztopia.surge.sh :)

@floriangosse
Copy link
Contributor

@zicodeng have you thought about opening a PR for your iframe implementation to get it into docz? I think many of us would be really happy to have this built-in.

@zicodeng
Copy link
Author

@floriangosse Hi, I definitely thought about this. This feature will actually not be part of docz core, it is theme-specific. So I instead create another theme, which has this built in iframe Playground support: http://docz-theme-ztopia.surge.sh/

@martpie
Copy link

martpie commented Jul 16, 2019

Can you elaborate on why it is theme specific? It looks to me like all themes should ship with this feature.

@zicodeng
Copy link
Author

@martpie Hi, happy to explain my thoughts! The reason why I say that is because the iframe logic is handled on the UI component level, e.g. <Playground> component. Docz core logic doesn't care about UI level things as far as I know. I could be wrong :)

@pedronauck
Copy link
Member

This is released in the new v2.

@techniq
Copy link

techniq commented Dec 6, 2019

Seems like this requires #1305 (2.2.0-alpha.8) and use:

  <Playground useScoping>
    ...
  </Playground>

@rakannimer
Copy link
Contributor

Hey all,

Thanks @techniq for providing a fix !

As you said this is solved in 2.2.0.

To scope your playground styles and make them independent of docz theme css you have 2 choices :

  1. add a useScoping prop to your playground
<Playground useScoping> 
{
// blablabla
}
</Playground>
  1. add useScopingInPlayground : true in doczrc.js
export default {
	useScopingInPlayground: true
}

If you're interested in the implementation details check out #1305

@mergebandit
Copy link

@rakannimer - Any thoughts on how this might work with css-modules?

@ghost
Copy link

ghost commented Mar 6, 2020

I know this is in Alpha but just wanted to let you know that this is not solved. Font's still are messed up

@raphaelboukara
Copy link

@bgold0 what is in alpha? css-modules?

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

No branches or pull requests

10 participants