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

Commit

Permalink
fix(docz): add wrapper prop on Playground
Browse files Browse the repository at this point in the history
  • Loading branch information
pedronauck committed Jul 24, 2018
1 parent c21929a commit 566aaf8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
6 changes: 5 additions & 1 deletion packages/docz/src/components/DocPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@ export type PageProps = RouteComponentProps<any> & {
doc: Entry
}

const Identity: SFC<any> = ({ children }) => <Fragment>{children}</Fragment>
export const Identity: SFC<any> = ({ children }) => (
<Fragment>{children}</Fragment>
)

const DefaultLoading: SFC = () => <Fragment>Loading</Fragment>

export interface RenderComponentProps {
className?: string
style?: any
wrapper?: ComponentType<any>
components: ComponentsMap
component: JSX.Element
position: number
Expand Down
30 changes: 17 additions & 13 deletions packages/docz/src/components/Playground.tsx
Original file line number Diff line number Diff line change
@@ -1,39 +1,43 @@
import * as React from 'react'
import { SFC } from 'react'
import { ComponentType, SFC } from 'react'
import { withMDXComponents } from '@mdx-js/tag/dist/mdx-provider'

import { isFn } from './Docs'
import { ComponentsMap } from './DocPreview'
import { ComponentsMap, Identity } from './DocPreview'

export interface PlaygroundProps {
components: ComponentsMap
className?: string
style?: any
components: ComponentsMap
wrapper?: ComponentType<any>
children: any
__position: number
__code: (components: ComponentsMap) => any
__rawCode: string
children: any
}

const BasePlayground: SFC<PlaygroundProps> = ({
components,
className,
style,
wrapper: Wrapper = Identity,
children,
__position,
__code,
__rawCode,
}) => {
return components && components.render ? (
<components.render
className={className}
style={style}
components={components}
component={isFn(children) ? children() : children}
position={__position}
code={__code(components)}
rawCode={__rawCode}
/>
<Wrapper>
<components.render
className={className}
style={style}
components={components}
component={isFn(children) ? children() : children}
position={__position}
code={__code(components)}
rawCode={__rawCode}
/>
</Wrapper>
) : null
}

Expand Down

0 comments on commit 566aaf8

Please sign in to comment.