diff --git a/src/components/IDE/Editor.tsx b/src/components/IDE/Editor.tsx index c6dd33433b..68f1536ddb 100644 --- a/src/components/IDE/Editor.tsx +++ b/src/components/IDE/Editor.tsx @@ -1,6 +1,5 @@ import * as React from 'react' -import Resizable from 're-resizable' import AceEditor from 'react-ace' import { Button, IconName, Intent } from '@blueprintjs/core' @@ -17,9 +16,7 @@ import 'brace/theme/cobalt' */ export interface IEditorProps { editorValue: string - editorWidth: number handleEditorValueChange: (newCode: string) => void - handleEditorWidthChange: (widthChange: number) => void handleEvalEditor: () => void } @@ -43,24 +40,7 @@ class Editor extends React.Component { ) const runButton = genericButton('', 'play', this.props.handleEvalEditor) return ( - { - this.props.handleEditorWidthChange(d.width) - }} - enable={{ - top: false, - right: true, - bottom: false, - left: false, - topRight: false, - bottomRight: false, - bottomLeft: false, - topLeft: false - }} - > +
{runButton}
@@ -77,7 +57,7 @@ class Editor extends React.Component { highlightActiveLine={false} />
-
+ ) } } diff --git a/src/components/IDE/__tests__/Editor.tsx b/src/components/IDE/__tests__/Editor.tsx index be2146b84f..f62ffa92e2 100644 --- a/src/components/IDE/__tests__/Editor.tsx +++ b/src/components/IDE/__tests__/Editor.tsx @@ -7,8 +7,6 @@ import Editor, { IEditorProps } from '../Editor' test('Editor renders correctly', () => { const props: IEditorProps = { editorValue: '', - editorWidth: 500, - handleEditorWidthChange: widthChange => {}, handleEditorValueChange: newCode => {}, handleEvalEditor: () => {} } diff --git a/src/components/IDE/__tests__/__snapshots__/Editor.tsx.snap b/src/components/IDE/__tests__/__snapshots__/Editor.tsx.snap index d5ddda7b07..472e0c25b6 100644 --- a/src/components/IDE/__tests__/__snapshots__/Editor.tsx.snap +++ b/src/components/IDE/__tests__/__snapshots__/Editor.tsx.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Editor renders correctly 1`] = ` -" +"
@@ -10,5 +10,5 @@ exports[`Editor renders correctly 1`] = `
-" +
" `; diff --git a/src/components/IDE/index.tsx b/src/components/IDE/index.tsx index 452ae24320..7fd4f98fe6 100644 --- a/src/components/IDE/index.tsx +++ b/src/components/IDE/index.tsx @@ -1,19 +1,47 @@ import * as React from 'react' +import Resizable from 're-resizable' + import EditorContainer from '../../containers/IDE/EditorContainer' import ReplContainer from '../../containers/IDE/ReplContainer' -const IDE: React.SFC<{}> = () => ( -
-
-
- -
-
- +export interface IIDEProps { + editorWidth: number + handleEditorWidthChange: (widthChange: number) => void +} + +class IDE extends React.Component { + public render() { + return ( +
+
+ { + this.props.handleEditorWidthChange(d.width) + }} + enable={{ + top: false, + right: true, + bottom: false, + left: false, + topRight: false, + bottomRight: false, + bottomLeft: false, + topLeft: false + }} + > + + +
+ +
+
-
-
-) + ) + } +} export default IDE diff --git a/src/components/Playground.tsx b/src/components/Playground.tsx index c28b75fcbc..9039f03c16 100644 --- a/src/components/Playground.tsx +++ b/src/components/Playground.tsx @@ -1,11 +1,11 @@ import * as React from 'react' -import IDE from './IDE' +import IDEContainer from '../containers/IDE' const Playground: React.SFC<{}> = () => { return (
- +
) } diff --git a/src/components/__tests__/__snapshots__/Playground.tsx.snap b/src/components/__tests__/__snapshots__/Playground.tsx.snap index 47248e71b7..b556242863 100644 --- a/src/components/__tests__/__snapshots__/Playground.tsx.snap +++ b/src/components/__tests__/__snapshots__/Playground.tsx.snap @@ -2,6 +2,6 @@ exports[`Playground renders correctly 1`] = ` "
- +
" `; diff --git a/src/containers/IDE/EditorContainer.ts b/src/containers/IDE/EditorContainer.ts index 10ce79e78a..c191680673 100644 --- a/src/containers/IDE/EditorContainer.ts +++ b/src/containers/IDE/EditorContainer.ts @@ -1,13 +1,12 @@ import { connect, MapDispatchToProps, MapStateToProps } from 'react-redux' import { bindActionCreators, Dispatch } from 'redux' -import { evalEditor, updateEditorValue, updateEditorWidth } from '../../actions/playground' +import { evalEditor, updateEditorValue } from '../../actions/playground' import Editor, { IEditorProps } from '../../components/IDE/Editor' import { IState } from '../../reducers/states' -type StateProps = Pick & Pick +type StateProps = Pick type DispatchProps = Pick & - Pick & Pick /** Provides the editorValue of the `IPlaygroundState` of the `IState` as a @@ -15,8 +14,7 @@ type DispatchProps = Pick & */ const mapStateToProps: MapStateToProps = state => { return { - editorValue: state.playground.editorValue, - editorWidth: state.playground.editorWidth + editorValue: state.playground.editorValue } } @@ -24,7 +22,6 @@ const mapDispatchToProps: MapDispatchToProps = (dispatch: Dis bindActionCreators( { handleEditorValueChange: updateEditorValue, - handleEditorWidthChange: updateEditorWidth, handleEvalEditor: evalEditor }, dispatch diff --git a/src/containers/IDE/index.ts b/src/containers/IDE/index.ts new file mode 100644 index 0000000000..f89e4b8926 --- /dev/null +++ b/src/containers/IDE/index.ts @@ -0,0 +1,28 @@ +import { connect, MapDispatchToProps, MapStateToProps } from 'react-redux' +import { bindActionCreators, Dispatch } from 'redux' + +import { updateEditorWidth } from '../../actions/playground' +import IDE, { IIDEProps } from '../../components/IDE/' +import { IState } from '../../reducers/states' + +type StateProps = Pick +type DispatchProps = Pick + +/** Provides the editorValue of the `IPlaygroundState` of the `IState` as a + * `StateProps` to the Playground component + */ +const mapStateToProps: MapStateToProps = state => { + return { + editorWidth: state.playground.editorWidth + } +} + +const mapDispatchToProps: MapDispatchToProps = (dispatch: Dispatch) => + bindActionCreators( + { + handleEditorWidthChange: updateEditorWidth + }, + dispatch + ) + +export default connect(mapStateToProps, mapDispatchToProps)(IDE)