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

Custom background for the playground #412

Closed
ghost opened this issue Oct 16, 2018 · 12 comments
Closed

Custom background for the playground #412

ghost opened this issue Oct 16, 2018 · 12 comments
Labels
difficult: medium docz-default-theme Issues related to package docz-default-theme

Comments

@ghost
Copy link

ghost commented Oct 16, 2018

Hi, thanks for your work on Docz, I'm giving it a try and it's fantastic! 🎉

How would one go about changing the background of the preview in the <Playground> for only one component ? It doesn't look like it's possible at the time of writing.

Description

I know you can create a custom theme for the entire Docz site, but in our case it's only a specific subset of components that don't work well on a white background, with the vast majority looking great.

It would be great if we could just pass in a CSS colour as a property of the playground that would only affect that specific instance.

Thanks,
Alvin

@kikorb
Copy link

kikorb commented Oct 16, 2018

Hi @alvinsight

We did run into a similar problem. For now we do:

<Playground>
  <div style={{ backgroundColor: "#eeeeee", margin: '-2em', padding: '2em' }}>
    <Button handleClick={ () => alert('Working') } >
      Accept
    </Button>
  </div>
</Playground>

@kikorb
Copy link

kikorb commented Oct 16, 2018

You can pass style to PlayGround also:

<Playground style={{ backgroundColor: "#eee", margin: '-2em', padding: '2em' }}>
  <Button handleClick={ () => alert('Working') } >
    Accept
  </Button>
</Playground>

But it leaves some paddind on the right. Give it a try and let me know, the div nails it for me

@kikorb
Copy link

kikorb commented Oct 16, 2018

I did recheck and the width is the problem. This works great:

<Playground style={{ backgroundColor: "#eee", margin: '-2em', padding: '2em', width: 'auto' }}>
  <Button handleClick={ () => alert('Working') } >
    Accept
  </Button>
</Playground>

@danielberndt
Copy link

Note that there's a media-query which sets the the padding to 1.5em if the viewport is smaller than 420px.

@pedronauck pedronauck added difficult: medium docz-default-theme Issues related to package docz-default-theme labels Oct 18, 2018
@thebergamo
Copy link

What about having a toggle for some kind of black and white theme in this situations? In some cases you can set what should be the default, but in other you can allow user to select it. @pedronauck what do you think?

@nicholasess
Copy link
Contributor

@thebergamo I liked it, Do you send to roadmap as a feature?

http://feedback.docz.site/

Thanks man

@thebergamo
Copy link

Will do it. Maybe I can open a PR as well sooner.

@nicholasess
Copy link
Contributor

@thebergamo nice man 🚀

@pedronauck
Copy link
Member

Fixed on release v0.12.10

@corysimmons
Copy link

corysimmons commented Jul 9, 2020

style doesn't seem to work on <Playground> anymore, and I can't wrap playground in a <div>. Seems the only way to style is within playground, which means people hitting the clipboard btn will get the wrapping element/styles as well. :(

@sanderdsz
Copy link

style doesn't seem to work on <Playground> anymore, and I can't wrap playground in a <div>. Seems the only way to style is within playground, which means people hitting the clipboard btn will get the wrapping element/styles as well. :(

I can confirm this, my inline styles into Playground component isn't working anymore.

@wenche
Copy link

wenche commented Aug 6, 2020

The <Playground> component uses some colour codes from theme-ui config, as far as I can see for the background and border.

colors: {
    playground: {
        bg: 'white',
        border: 'rgb(220, 220, 220)',
    },
}

Skjermbilde 2020-08-06 kl  10 20 45

But this only affects the upper part of the component, the lower part with the live editor has it's bg style inside the component.
Skjermbilde 2020-08-06 kl  10 22 13

I would love to have a consistent way to change the look of the <Playground>. As it is now, the live editor background color doesn't look good with the rest of our theme and it will also be impossible to add a proper dark theme for our docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficult: medium docz-default-theme Issues related to package docz-default-theme
Projects
None yet
Development

No branches or pull requests

8 participants