Skip to content

Commit

Permalink
fix(docz-theme-default): copy html output (#189)
Browse files Browse the repository at this point in the history
* fix(docz-theme-default): copy html output

* fix(docz-theme-default): current -> showing
  • Loading branch information
renatorib authored and pedronauck committed Aug 4, 2018
1 parent c13e3f2 commit 2cb834c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"eslint.enable": false,
"javascript.validate.enable": false
"javascript.validate.enable": false,
"typescript.tsdk": "node_modules/typescript/lib"
}
25 changes: 16 additions & 9 deletions packages/docz-theme-default/src/components/ui/Render/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,19 @@ export class Render extends Component<RenderComponentProps, RenderState> {
hotkeys.unbind('esc')
}

get showingContent(): string {
const { code, component } = this.props
const { showing } = this.state

const content = {
jsx: () => code,
html: () => pretty(renderToStaticMarkup(component)),
}

return content[showing]()
}

get actions(): JSX.Element {
const { code } = this.props
const { showing, fullscreen } = this.state

const showJsx = this.handleShow('jsx')
Expand All @@ -163,7 +174,7 @@ export class Render extends Component<RenderComponentProps, RenderState> {
HTML
</Tab>
</Tabs>
<Clipboard content={code} />
<Clipboard content={this.showingContent} />
<Action
onClick={this.handleToggle}
title={fullscreen ? 'Minimize' : 'Maximize'}
Expand Down Expand Up @@ -213,8 +224,8 @@ export class Render extends Component<RenderComponentProps, RenderState> {
}

public render(): JSX.Element {
const { className, style, component, code } = this.props
const { showing, fullscreen } = this.state
const { className, style, component } = this.props
const { fullscreen } = this.state

return (
<Overlay full={fullscreen}>
Expand All @@ -225,11 +236,7 @@ export class Render extends Component<RenderComponentProps, RenderState> {
{component}
</Playground>
{this.actions}
<Pre actions={<Fragment />}>
{showing === 'jsx'
? code
: pretty(renderToStaticMarkup(component))}
</Pre>
<Pre actions={<Fragment />}>{this.showingContent}</Pre>
</Wrapper>
</Resizable>
</Overlay>
Expand Down

0 comments on commit 2cb834c

Please sign in to comment.