2017-01-26 21:07:22 -08:00
|
|
|
import React, { PureComponent, PropTypes } from 'react';
|
2016-05-27 17:11:25 -07:00
|
|
|
import NoSSR from 'react-no-ssr';
|
2016-03-05 21:06:04 -08:00
|
|
|
import Codemirror from 'react-codemirror';
|
|
|
|
|
2017-03-13 16:17:07 -07:00
|
|
|
import ns from './ns.json';
|
|
|
|
import CodeMirrorSkeleton from './Code-Mirror-Skeleton.jsx';
|
2016-12-31 15:45:14 +00:00
|
|
|
|
2016-03-05 21:06:04 -08:00
|
|
|
const defaultOptions = {
|
|
|
|
lineNumbers: false,
|
2017-03-13 16:17:07 -07:00
|
|
|
lineWrapping: true,
|
2016-05-27 17:11:25 -07:00
|
|
|
mode: 'javascript',
|
2016-03-05 21:06:04 -08:00
|
|
|
readOnly: 'nocursor',
|
2017-03-13 16:17:07 -07:00
|
|
|
theme: 'monokai'
|
2016-03-05 21:06:04 -08:00
|
|
|
};
|
|
|
|
|
2017-01-12 06:54:43 +00:00
|
|
|
const propTypes = {
|
|
|
|
defaultOutput: PropTypes.string,
|
|
|
|
output: PropTypes.string
|
|
|
|
};
|
|
|
|
|
2017-01-26 21:07:22 -08:00
|
|
|
export default class Output extends PureComponent {
|
2016-03-05 21:06:04 -08:00
|
|
|
render() {
|
2017-01-26 21:07:22 -08:00
|
|
|
const { output, defaultOutput } = this.props;
|
2016-03-05 21:06:04 -08:00
|
|
|
return (
|
2017-03-13 16:17:07 -07:00
|
|
|
<div className={ `${ns}-log` }>
|
2016-12-31 15:45:14 +00:00
|
|
|
<NoSSR onSSR={ <CodeMirrorSkeleton content={ output } /> }>
|
2016-05-27 17:11:25 -07:00
|
|
|
<Codemirror
|
|
|
|
options={ defaultOptions }
|
2017-01-26 21:07:22 -08:00
|
|
|
value={ output || defaultOutput }
|
2016-06-10 14:01:13 -07:00
|
|
|
/>
|
2016-05-27 17:11:25 -07:00
|
|
|
</NoSSR>
|
2016-03-05 21:06:04 -08:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2017-01-26 21:07:22 -08:00
|
|
|
|
|
|
|
Output.displayName = 'Output';
|
2017-01-12 06:54:43 +00:00
|
|
|
Output.propTypes = propTypes;
|