Skip to content

Commit

Permalink
Replaced refractPreview component with the stateless JsonFormatter
Browse files Browse the repository at this point in the history
  • Loading branch information
XVincentX committed Sep 9, 2015
1 parent 329c1bb commit d67c821
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 52 deletions.
17 changes: 14 additions & 3 deletions playground/components/JsonFormatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,24 @@ class JsonFormatterComponent extends React.Component {

}

attachJsonFormatter() {
if (this.nodeComponent !== undefined) {
const formatter = new JSONFormatter(this.props.data, 3, { hoverPreviewEnabled: true });
if (this.nodeComponent.hasChildNodes()) {
this.nodeComponent.removeChild(this.nodeComponent.firstChild);
}

this.nodeComponent.appendChild(formatter.render());
}
}

componentDidMount() {
const formatter = new JSONFormatter(this.props.data, 3, {hoverPreviewEnabled: true});
const nodeComponent = React.findDOMNode(this.refs.jsonFormatterContainer);
nodeComponent.appendChild(formatter.render());
this.nodeComponent = React.findDOMNode(this.refs.jsonFormatterContainer);
this.attachJsonFormatter();
}

render() {
this.attachJsonFormatter();
return (
<div ref="jsonFormatterContainer">
</div>
Expand Down
4 changes: 2 additions & 2 deletions playground/components/playground.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';

import EditorComponent from './editor';
import RefractPreviewComponent from './refractPreview';
import JsonFormatterComponent from './JsonFormatter';
import {AttributesComponent} from '../../src';
import actionTypes from '../actions/types';
import dispatcher from '../dispatcher';
Expand Down Expand Up @@ -39,7 +39,7 @@ class PlaygroundApp extends React.Component {
</div>

<div className="column">
<RefractPreviewComponent />
<JsonFormatterComponent data={this.state.attributes} />
</div>

<div className="column">
Expand Down
45 changes: 0 additions & 45 deletions playground/components/refractPreview.js

This file was deleted.

3 changes: 1 addition & 2 deletions playground/components/visual-testing.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import React from 'react';
import request from 'superagent';
import JSONFormatterComponent from './JSONFormatter';

import RefractPreviewComponent from './refractPreview';
import JsonFormatterComponent from './JsonFormatter';
import {AttributesComponent} from '../../src';


Expand Down

0 comments on commit d67c821

Please sign in to comment.