0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2025-12-24 20:42:43 +00:00

Create autosave toggle dropdown menu

This commit is contained in:
Gazook89
2022-09-27 19:35:29 -05:00
parent f681948a35
commit c7ed9ea717
2 changed files with 16 additions and 7 deletions

View File

@@ -55,6 +55,13 @@
text-align : center;
text-transform : initial;
}
.save-menu .navItem i.fa-power-off {
color : red;
&.active {
color : rgb(0, 182, 52);
filter : drop-shadow(0 0 2px rgba(0, 182, 52, 0.765))
}
}
.patreon.navItem{
border-left : 1px solid #666;
border-right : 1px solid #666;

View File

@@ -143,12 +143,8 @@ const EditPage = createClass({
return !_.isEqual(this.state.brew, this.savedBrew);
},
toggleAutoSave : function(){
this.setState((prevState)=>({ autoSave: !prevState.autoSave }));
},
trySave : function(){
if(!this.state.autoSave){ console.log('Auto-save is off.'); return };
if(!this.state.autoSave){return;};
if(!this.debounceSave) this.debounceSave = _.debounce(this.save, SAVE_TIMEOUT);
if(this.hasChanges()){
this.debounceSave();
@@ -342,7 +338,7 @@ const EditPage = createClass({
return <Nav.item className='save' onClick={this.save} color='blue' icon='fas fa-save'>Save Now</Nav.item>;
}
if(!this.state.isPending && !this.state.isSaving){
return <Nav.item className='save saved' onClick={this.toggleAutoSave}>{this.state.autoSave ? `saved.` : `auto-save off`}</Nav.item>;
return <Nav.item className='save saved'>saved.</Nav.item>;
}
},
@@ -384,7 +380,13 @@ const EditPage = createClass({
<Nav.section>
{this.renderGoogleDriveIcon()}
{this.renderSaveButton()}
<Nav.dropdown className='save-menu'>
{this.renderSaveButton()}
<Nav.item onClick={()=>{ this.setState((prevState)=>({ autoSave: !prevState.autoSave }));}}>
Autosave <i className={this.state.autoSave ? 'fas fa-power-off active' : 'fas fa-power-off'}></i>
</Nav.item>
</Nav.dropdown>
<NewBrew />
<HelpNavItem/>
<Nav.dropdown>