mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-09 09:22:38 +00:00
Initial UI functionality
This commit is contained in:
@@ -460,7 +460,9 @@ const Editor = createClass({
|
|||||||
currentEditorTheme={this.state.editorTheme}
|
currentEditorTheme={this.state.editorTheme}
|
||||||
updateEditorTheme={this.updateEditorTheme}
|
updateEditorTheme={this.updateEditorTheme}
|
||||||
snippetBundle={this.props.snippetBundle}
|
snippetBundle={this.props.snippetBundle}
|
||||||
cursorPos={this.codeEditor.current?.getCursorPosition() || {}} />
|
cursorPos={this.codeEditor.current?.getCursorPosition() || {}}
|
||||||
|
updateBrew={this.props.updateBrew}
|
||||||
|
/>
|
||||||
|
|
||||||
{this.renderEditor()}
|
{this.renderEditor()}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -40,7 +40,8 @@ const Snippetbar = createClass({
|
|||||||
unfoldCode : ()=>{},
|
unfoldCode : ()=>{},
|
||||||
updateEditorTheme : ()=>{},
|
updateEditorTheme : ()=>{},
|
||||||
cursorPos : {},
|
cursorPos : {},
|
||||||
snippetBundle : []
|
snippetBundle : [],
|
||||||
|
updateBrew : ()=>{}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -148,6 +149,10 @@ const Snippetbar = createClass({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
replaceContent : function(item){
|
||||||
|
return this.props.updateBrew(item);
|
||||||
|
},
|
||||||
|
|
||||||
renderHistoryItems : function() {
|
renderHistoryItems : function() {
|
||||||
const historyItems = getHistoryItems(this.props.brew);
|
const historyItems = getHistoryItems(this.props.brew);
|
||||||
|
|
||||||
@@ -156,12 +161,18 @@ const Snippetbar = createClass({
|
|||||||
if(!item.savedAt) return;
|
if(!item.savedAt) return;
|
||||||
|
|
||||||
const saveTime = new Date(item.savedAt);
|
const saveTime = new Date(item.savedAt);
|
||||||
const diffTime = new Date() - saveTime;
|
const diffMs = new Date() - saveTime;
|
||||||
const diffMins = Math.floor(diffTime / (60 * 1000));
|
const diffMins = Math.floor(diffMs / (60 * 1000));
|
||||||
|
|
||||||
return <div className='snippet' key={index} >
|
let diffString = `about ${diffMins} minutes ago`;
|
||||||
|
|
||||||
|
if(diffMins > 60) diffString = `about ${Math.floor(diffMins / 60)} hours ago`;
|
||||||
|
if(diffMins > (24 * 60)) diffString = `about ${Math.floor(diffMins / (24 * 60))} days ago`;
|
||||||
|
if(diffMins > (7 * 24 * 60)) diffString = `about ${Math.floor(diffMins / (7 * 24 * 60))} weeks ago`;
|
||||||
|
|
||||||
|
return <div className='snippet' key={index} onClick={()=>{this.replaceContent(item);}} >
|
||||||
<i className={`fas fa-${index+1}`} />
|
<i className={`fas fa-${index+1}`} />
|
||||||
<span className='name' title={saveTime.toISOString()}>v{item.version} : about {diffMins} mins ago</span>
|
<span className='name' title={saveTime.toISOString()}>v{item.version} : {diffString}</span>
|
||||||
</div>;
|
</div>;
|
||||||
})}
|
})}
|
||||||
</div>;
|
</div>;
|
||||||
|
|||||||
@@ -152,6 +152,16 @@ const EditPage = createClass({
|
|||||||
return !_.isEqual(this.state.brew, this.savedBrew);
|
return !_.isEqual(this.state.brew, this.savedBrew);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
updateBrew : function(newData){
|
||||||
|
this.setState((prevState)=>({
|
||||||
|
brew : {
|
||||||
|
...prevState.brew,
|
||||||
|
style : newData.style,
|
||||||
|
text : newData.text
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
},
|
||||||
|
|
||||||
trySave : function(immediate=false){
|
trySave : function(immediate=false){
|
||||||
if(!this.debounceSave) this.debounceSave = _.debounce(this.save, SAVE_TIMEOUT);
|
if(!this.debounceSave) this.debounceSave = _.debounce(this.save, SAVE_TIMEOUT);
|
||||||
if(this.hasChanges()){
|
if(this.hasChanges()){
|
||||||
@@ -418,6 +428,7 @@ const EditPage = createClass({
|
|||||||
renderer={this.state.brew.renderer}
|
renderer={this.state.brew.renderer}
|
||||||
userThemes={this.props.userThemes}
|
userThemes={this.props.userThemes}
|
||||||
snippetBundle={this.state.themeBundle.snippets}
|
snippetBundle={this.state.themeBundle.snippets}
|
||||||
|
updateBrew={this.updateBrew}
|
||||||
/>
|
/>
|
||||||
<BrewRenderer
|
<BrewRenderer
|
||||||
text={this.state.brew.text}
|
text={this.state.brew.text}
|
||||||
|
|||||||
Reference in New Issue
Block a user