diff --git a/components/CodeImage.js b/components/CodeImage.js index f5a251c..89912a2 100644 --- a/components/CodeImage.js +++ b/components/CodeImage.js @@ -3,6 +3,7 @@ import React from 'react' import domtoimage from 'dom-to-image' import CodeMirror from 'react-codemirror' import WindowControls from '../components/svg/Controls' +import Spinner from 'react-spinner' // hack to only call modes on browser if (typeof window !== 'undefined' && typeof window.navigator !== 'undefined') { @@ -19,40 +20,74 @@ const DEFAULT_SETTINGS = { language: 'javascript' } -const CodeImage = (props) => { - const config = Object.assign(DEFAULT_SETTINGS, props.config) + class CodeImage extends React.Component { - const options = { - lineNumbers: false, - mode: config.language, - theme: config.theme, - scrollBarStyle: null, - viewportMargin: Infinity, - lineWrapping: true + constructor (props) { + super(props) + + this.state = { + loading: true + } } - // create styles - const containerStyle = { - background: config.background, - padding: `${config.paddingVertical} ${config.paddingHorizontal}` + componentDidMount() { + this.setState({ + loading: false + }) } - return ( -