question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Allow `<Playground>` inside elements

See original GitHub issue

Feature Request

To hide the required context for my element, I’ld like to write the following mdx:

<Provider store={createStore(() => ({}))}>
  <Playground>
    <MyButton />
  </Playground>
</Provider>

But in that case, the Playground component doesn’t work. It forces me to put the context inside playground, which leads to large example code with unrelated elements.

<Playground>
  <Provider store={createStore(() => ({}))}>
    <MyButton />
  </Provider>
</Playground>

I know I can define a wrapper inside doczrc.js, but I’m documenting a large project with several different contexts, so a single wrapper is not an option.

Somehow related to #68.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jonathancopperstonecommented, Jan 14, 2019

hey @huchenme, this is my setup:

I set up a component file which has the wrapper:

export default ({ children }) => (
  <MyComponentOrPlayground prop={ any }>
    { children }
  </MyComponentOrPlayground>
)

and reference this in your doczrc

export default {
  ...,
  wrapper: 'path/to/my/playground/wrapper'
}
0reactions
victorcabeceiracommented, Aug 22, 2019

Hi, in case it helps anyone, that’s how I got around.

doczrc.js configuration

//doczrc.js (on root)

export default {
  src: './src',
  wrapper: 'src/wrapper',
  ...
}

wrapper file

// wrapper.js (on ./src)

import React from 'react';
import { Provider } from 'react-redux';
import { createStore } from 'redux';


export default ({ children }) => (
  <Provider store={createStore()}>
    { children }
  </Provider>
);

Then, just proceed with your docz documentation

// component.mdx

import { Playground, Props } from 'docz';
import Component from './path-to-component';

<Playground>
  <Component />
</Playground>
Read more comments on GitHub >

github_iconTop Results From Across the Web

Playground environment | Support for Elements.cloud
Playground Space allows you to connect a single Salesforce Dev Org and you cannot share the Space, or any content in it, with...
Read more >
Designing an Inclusive Indoor Playground - Soft Play
Inclusive playgrounds should include sensory elements that appeal to kids of all ability levels. Enabling kids to build their motor skills ...
Read more >
Making Playgrounds Inclusive for All - Miracle Recreation
An accessible playground is not necessarily inclusive, and both elements are essential for a playground to benefit everyone. In this post, we'll explore...
Read more >
Elements of a Successful Playspace - Project for Public Spaces
3. Cognitive. Creativity: Play areas need to allow children to create their own environment to allow for adventure and creative play. Adventure playgrounds...
Read more >
Integrating Landscape Design & Playground Elements
Whether your playground is located in a condo community, ... This expands the area where children can play and allows them to spread...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found