-
Notifications
You must be signed in to change notification settings - Fork 167
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make IDE component contain Resizable
Note that this make the IDE/index component stateful, handling the editor width.
- Loading branch information
Showing
8 changed files
with
77 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<{}> = () => ( | ||
<div className="IDE"> | ||
<div className="row ide-content-parent"> | ||
<div className="editor-parent"> | ||
<EditorContainer /> | ||
</div> | ||
<div className="repl-parent"> | ||
<ReplContainer /> | ||
export interface IIDEProps { | ||
editorWidth: number | ||
handleEditorWidthChange: (widthChange: number) => void | ||
} | ||
|
||
class IDE extends React.Component<IIDEProps, {}> { | ||
public render() { | ||
return ( | ||
<div className="IDE"> | ||
<div className="row ide-content-parent"> | ||
<Resizable | ||
className="editor-parent" | ||
size={{ width: this.props.editorWidth, height: '100%' }} | ||
// tslint:disable-next-line jsx-no-lambda | ||
onResizeStop={(e, direction, ref, d) => { | ||
this.props.handleEditorWidthChange(d.width) | ||
}} | ||
enable={{ | ||
top: false, | ||
right: true, | ||
bottom: false, | ||
left: false, | ||
topRight: false, | ||
bottomRight: false, | ||
bottomLeft: false, | ||
topLeft: false | ||
}} | ||
> | ||
<EditorContainer /> | ||
</Resizable> | ||
<div className="repl-parent"> | ||
<ReplContainer /> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
) | ||
) | ||
} | ||
} | ||
|
||
export default IDE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<IIDEProps, 'editorWidth'> | ||
type DispatchProps = Pick<IIDEProps, 'handleEditorWidthChange'> | ||
|
||
/** Provides the editorValue of the `IPlaygroundState` of the `IState` as a | ||
* `StateProps` to the Playground component | ||
*/ | ||
const mapStateToProps: MapStateToProps<StateProps, {}, IState> = state => { | ||
return { | ||
editorWidth: state.playground.editorWidth | ||
} | ||
} | ||
|
||
const mapDispatchToProps: MapDispatchToProps<DispatchProps, {}> = (dispatch: Dispatch<any>) => | ||
bindActionCreators( | ||
{ | ||
handleEditorWidthChange: updateEditorWidth | ||
}, | ||
dispatch | ||
) | ||
|
||
export default connect(mapStateToProps, mapDispatchToProps)(IDE) |