0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-11 00:22:43 +00:00

Hide divider arrows when not required

This commit is contained in:
G.Ambatte
2022-05-29 15:49:37 +12:00
parent 7b2486e411
commit 08db2e8492
2 changed files with 34 additions and 13 deletions

View File

@@ -232,6 +232,7 @@ const Editor = createClass({
renderEditor : function(){ renderEditor : function(){
if(this.isText()){ if(this.isText()){
this.props.setMoveArrows(true);
return <> return <>
<CodeEditor key='codeEditor' <CodeEditor key='codeEditor'
ref='codeEditor' ref='codeEditor'
@@ -243,6 +244,7 @@ const Editor = createClass({
</>; </>;
} }
if(this.isStyle()){ if(this.isStyle()){
this.props.setMoveArrows(false);
return <> return <>
<CodeEditor key='codeEditor' <CodeEditor key='codeEditor'
ref='codeEditor' ref='codeEditor'
@@ -255,6 +257,7 @@ const Editor = createClass({
</>; </>;
} }
if(this.isMeta()){ if(this.isMeta()){
this.props.setMoveArrows(false);
return <> return <>
<CodeEditor key='codeEditor' <CodeEditor key='codeEditor'
view={this.state.view} view={this.state.view}

View File

@@ -19,7 +19,8 @@ const SplitPane = createClass({
windowWidth : 0, windowWidth : 0,
isDragging : false, isDragging : false,
moveSource : false, moveSource : false,
moveBrew : false moveBrew : false,
showMoveArrows : true
}; };
}, },
@@ -91,18 +92,34 @@ const SplitPane = createClass({
}, },
*/ */
setMoveArrows : function(newState) {
if(this.state.showMoveArrows != newState){
this.setState({
showMoveArrows : newState
});
}
},
renderMoveArrows : function(){
if(this.state.showMoveArrows) {
return <>
<div className='arrow left'
style={{ left: this.state.currentDividerPos-4 }}
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={()=>this.setState({ moveBrew: !this.state.moveBrew })} >
<i className='fas fa-arrow-right' />
</div>
</>;
}
},
renderDivider : function(){ renderDivider : function(){
return <> return <>
<div className='arrow left' {this.renderMoveArrows()}
style={{ left: this.state.currentDividerPos-4 }}
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={()=>this.setState({ moveBrew: !this.state.moveBrew })} >
<i className='fas fa-arrow-right' />
</div>
<div className='divider' onMouseDown={this.handleDown} > <div className='divider' onMouseDown={this.handleDown} >
<div className='dots'> <div className='dots'>
<i className='fas fa-circle' /> <i className='fas fa-circle' />
@@ -120,8 +137,9 @@ const SplitPane = createClass({
width={this.state.currentDividerPos} width={this.state.currentDividerPos}
> >
{React.cloneElement(this.props.children[0], { {React.cloneElement(this.props.children[0], {
moveBrew : this.state.moveBrew, moveBrew : this.state.moveBrew,
moveSource : this.state.moveSource moveSource : this.state.moveSource,
setMoveArrows : this.setMoveArrows
})} })}
</Pane> </Pane>
{this.renderDivider()} {this.renderDivider()}