Skip to content
This repository has been archived by the owner on Jan 24, 2025. It is now read-only.

Commit

Permalink
feat(docz): add classname and style props for Playground
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronauck committed Jul 11, 2018
1 parent 6e2a15d commit 1b64ed3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/docz-theme-default/src/components/ui/Render.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,16 @@ const Code = styled('div')`
}
`

export const Render: RenderComponent = ({ component, code }) => (
export const Render: RenderComponent = ({
component,
code,
className,
style,
}) => (
<Fragment>
<Playground>{component}</Playground>
<Playground className={className} style={style}>
{component}
</Playground>
<Code>{code}</Code>
</Fragment>
)
2 changes: 2 additions & 0 deletions packages/docz/src/components/DocPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ const DefaultLoading: SFC = () => null
export type RenderComponent = ComponentType<{
component: JSX.Element
code: any
className?: string
style?: any
}>

export const DefaultRender: RenderComponent = ({ component, code }) => (
Expand Down
6 changes: 6 additions & 0 deletions packages/docz/src/components/Playground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,21 @@ export interface PlaygroundProps {
__code: (components: ComponentsMap) => any
children: any
components: ComponentsMap
className?: string
style?: any
}

const BasePlayground: SFC<PlaygroundProps> = ({
components,
children,
__code,
className,
style,
}) => {
return components && components.render ? (
<components.render
className={className}
style={style}
component={isFn(children) ? children() : children}
code={__code(components)}
/>
Expand Down

0 comments on commit 1b64ed3

Please sign in to comment.