Files
freeCodeCamp/common/app/routes/challenges/components/Output.jsx

38 lines
878 B
JavaScript
Raw Normal View History

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