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

Per-file wrapper components #319

Closed
wldcordeiro opened this issue Sep 10, 2018 · 3 comments
Closed

Per-file wrapper components #319

wldcordeiro opened this issue Sep 10, 2018 · 3 comments

Comments

@wldcordeiro
Copy link

It'd be awesome if aside from the root wrapper I could create one at a file level. I have a mono-repo where I may have one file that I want to wrap in a Provider with one store and another where I wish to use another store and it'd be convenient to be able to make a project level wrapper that sets up anything I know all the packages need and then be able to point to a wrapper for that file by adding to the top-matter like this?

// Option A
import Wrapper from './path/to/wrapper';
---
name: Page
menu: Some Menu
route: /page
wrapper: Wrapper
---

// Option B
---
name: Page
menu: Some Menu
route: /page
wrapper: './path/to/wrapper'
---
@pedronauck
Copy link
Member

You can wrap your document by exporting a default component like that:

---
name: Page
menu: Some Menu
route: /page
---

import Wrapper from './path/to/wrapper'

export default (props) => (
  <Wrapper {...props} />
)

@wldcordeiro
Copy link
Author

That isn't what I want to do though because then if I use the playground it shows up as part of my example code. You just close the issue and answer like I don't know common JS imports.

@pedronauck
Copy link
Member

pedronauck commented Sep 11, 2018

But this wrapper won't be shown as part of your playground @wldcordeiro, this wrapper will be wrapped in the <div> around your document. In docz we have 3 ways to wrap things:

  1. Using wrapper property on doczrc, that will wrap your entire application.
  2. By exporting default some component, that will wrap your document.
  3. By wrapping children of playground, that will wrap the code of your playground.

Just the last one will show the code on your playground!

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

2 participants