0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-10 17:52:47 +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); window.removeEventListener('resize', this.updateEditorSize);
}, },
componentDidUpdate : function() { componentDidUpdate : function(prevProps, prevState, snapshot) {
this.highlightCustomMarkdown(); this.highlightCustomMarkdown();
if(prevProps.moveBrew !== this.props.moveBrew) {
this.brewJump();
};
if(prevProps.moveSource !== this.props.moveSource) {
this.sourceJump();
};
}, },
updateEditorSize : function() { updateEditorSize : function() {

View File

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