mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2026-01-19 05:32:42 +00:00
Initial theme selector functionality
This commit is contained in:
@@ -40,8 +40,9 @@ const Snippetbar = createClass({
|
|||||||
|
|
||||||
getInitialState : function() {
|
getInitialState : function() {
|
||||||
return {
|
return {
|
||||||
renderer : this.props.renderer,
|
renderer : this.props.renderer,
|
||||||
snippets : []
|
themeSelector : false,
|
||||||
|
snippets : []
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -95,13 +96,38 @@ const Snippetbar = createClass({
|
|||||||
this.props.onInject(injectedText);
|
this.props.onInject(injectedText);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
toggleThemeSelector : function(){
|
||||||
|
this.setState({
|
||||||
|
themeSelector : !this.state.themeSelector
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
selectTheme : function(){
|
selectTheme : function(){
|
||||||
console.log('select theme');
|
console.log('select theme');
|
||||||
|
console.log(global.config);
|
||||||
const editorTheme = window.prompt('Enter theme name:', 'default');
|
const editorTheme = window.prompt('Enter theme name:', 'default');
|
||||||
if(!editorTheme) return;
|
if(!editorTheme) return;
|
||||||
this.props.updateEditorTheme(editorTheme);
|
this.props.updateEditorTheme(editorTheme);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
changeTheme : function(e){
|
||||||
|
this.props.updateEditorTheme(e.target.value);
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
showThemeSelector : false,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
renderThemeSelector : function(){
|
||||||
|
return <div className='themeSelector'>
|
||||||
|
<select value={this.props.currentEditorTheme} onChange={this.changeTheme}>
|
||||||
|
{global.config.codeMirrorThemes.map((theme, key)=>{
|
||||||
|
return <option key={key} value={theme}>{theme}</option>;
|
||||||
|
})}
|
||||||
|
</select>
|
||||||
|
</div>;
|
||||||
|
},
|
||||||
|
|
||||||
renderSnippetGroups : function(){
|
renderSnippetGroups : function(){
|
||||||
const snippets = this.state.snippets.filter((snippetGroup)=>snippetGroup.view === this.props.view);
|
const snippets = this.state.snippets.filter((snippetGroup)=>snippetGroup.view === this.props.view);
|
||||||
|
|
||||||
@@ -130,10 +156,12 @@ const Snippetbar = createClass({
|
|||||||
<i className='fas fa-redo' />
|
<i className='fas fa-redo' />
|
||||||
</div>
|
</div>
|
||||||
<div className='divider'></div>
|
<div className='divider'></div>
|
||||||
<div className={'editorTool palette'}
|
<div className={`editorTool editorTheme ${this.state.themeSelector ? 'active' : ''}`}
|
||||||
onClick={this.selectTheme} >
|
onClick={this.toggleThemeSelector} >
|
||||||
<i className='fas fa-palette' />
|
<i className='fas fa-palette' />
|
||||||
</div>
|
</div>
|
||||||
|
{this.state.themeSelector && this.renderThemeSelector()}
|
||||||
|
<div className='divider'></div>
|
||||||
<div className={cx('text', { selected: this.props.view === 'text' })}
|
<div className={cx('text', { selected: this.props.view === 'text' })}
|
||||||
onClick={()=>this.props.onViewChange('text')}>
|
onClick={()=>this.props.onViewChange('text')}>
|
||||||
<i className='fa fa-beer' />
|
<i className='fa fa-beer' />
|
||||||
|
|||||||
@@ -46,6 +46,15 @@
|
|||||||
color : black;
|
color : black;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
&.editorTheme{
|
||||||
|
.tooltipLeft('Editor Themes');
|
||||||
|
font-size : 0.75em;
|
||||||
|
color : black;
|
||||||
|
&.active{
|
||||||
|
color : white;
|
||||||
|
background-color: black;
|
||||||
|
}
|
||||||
|
}
|
||||||
&.divider {
|
&.divider {
|
||||||
background: linear-gradient(#000, #000) no-repeat center/1px 100%;
|
background: linear-gradient(#000, #000) no-repeat center/1px 100%;
|
||||||
width: 5px;
|
width: 5px;
|
||||||
@@ -54,6 +63,18 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
.themeSelector{
|
||||||
|
position: absolute;
|
||||||
|
left: -65px;
|
||||||
|
top: 30px;
|
||||||
|
z-index: 999;
|
||||||
|
width: 170px;
|
||||||
|
background-color: black;
|
||||||
|
border-radius: 5px;
|
||||||
|
&>select{
|
||||||
|
width: auto;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.snippetBarButton{
|
.snippetBarButton{
|
||||||
height : @menuHeight;
|
height : @menuHeight;
|
||||||
|
|||||||
Reference in New Issue
Block a user