0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 18:32:41 +00:00

Initial pass at split pane button functionality

This commit is contained in:
G.Ambatte
2022-05-29 15:18:35 +12:00
parent 3ccd1ebb7b
commit eca39369de
2 changed files with 21 additions and 5 deletions

View File

@@ -61,8 +61,14 @@ const Editor = createClass({
window.removeEventListener('resize', this.updateEditorSize);
},
componentDidUpdate : function() {
componentDidUpdate : function(prevProps, prevState, snapshot) {
this.highlightCustomMarkdown();
if(prevProps.moveBrew !== this.props.moveBrew) {
this.brewJump();
};
if(prevProps.moveSource !== this.props.moveSource) {
this.sourceJump();
};
},
updateEditorSize : function() {

View File

@@ -17,7 +17,9 @@ const SplitPane = createClass({
return {
currentDividerPos : null,
windowWidth : 0,
isDragging : false
isDragging : false,
moveSource : false,
moveBrew : false
};
},
@@ -93,12 +95,12 @@ const SplitPane = createClass({
return <>
<div className='arrow left'
style={{ left: this.state.currentDividerPos-4 }}
onClick={()=>console.log('left')} >
onClick={()=>this.setState({ moveSource: !this.state.moveSource })} >
<i className='fas fa-arrow-left' />
</div>
<div className='arrow right'
style={{ left: this.state.currentDividerPos-4 }}
onClick={()=>console.log('right')} >
onClick={()=>this.setState({ moveBrew: !this.state.moveBrew })} >
<i className='fas fa-arrow-right' />
</div>
<div className='divider' onMouseDown={this.handleDown} >
@@ -113,7 +115,15 @@ const SplitPane = createClass({
render : function(){
return <div className='splitPane' onMouseMove={this.handleMove} onMouseUp={this.handleUp}>
<Pane ref='pane1' width={this.state.currentDividerPos}>{this.props.children[0]}</Pane>
<Pane
ref='pane1'
width={this.state.currentDividerPos}
>
{React.cloneElement(this.props.children[0], {
moveBrew : this.state.moveBrew,
moveSource : this.state.moveSource
})}
</Pane>
{this.renderDivider()}
<Pane ref='pane2' isDragging={this.state.isDragging}>{this.props.children[1]}</Pane>
</div>;