mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-31 02:12:43 +00:00
Themes list to use object instead of array.
This commit is contained in:
@@ -30,11 +30,6 @@ const MetadataEditor = createClass({
|
||||
};
|
||||
},
|
||||
|
||||
getThemeData : function(renderer, theme){
|
||||
|
||||
return Themes[_.upperFirst(renderer)].find((x)=>x.path == theme);
|
||||
},
|
||||
|
||||
handleFieldChange : function(name, e){
|
||||
this.props.onChange(_.merge({}, this.props.metadata, {
|
||||
[name] : e.target.value
|
||||
@@ -136,7 +131,8 @@ const MetadataEditor = createClass({
|
||||
|
||||
renderThemeDropdown : function(){
|
||||
const listThemes = (renderer)=>{
|
||||
return _.map(Themes[renderer], (theme)=>{
|
||||
return _.map(_.values(Themes[renderer]), (theme)=>{
|
||||
console.log(theme);
|
||||
return <div className='item' key={''} onClick={()=>this.handleTheme(theme)} title={''}>
|
||||
{`${theme.renderer} : ${theme.name}`}
|
||||
<img src={`/themes/${theme.renderer}/${theme.path}/dropdownTexture.png`}/>
|
||||
@@ -144,7 +140,7 @@ const MetadataEditor = createClass({
|
||||
});
|
||||
};
|
||||
|
||||
const currentTheme = this.getThemeData(this.props.metadata.renderer, this.props.metadata.theme);
|
||||
const currentTheme = Themes[this.props.metadata.renderer][this.props.metadata.theme];
|
||||
let dropdown;
|
||||
|
||||
if(this.props.metadata.renderer == 'legacy') {
|
||||
|
||||
@@ -6,9 +6,12 @@ const cx = require('classnames');
|
||||
|
||||
//Import all themes
|
||||
|
||||
const ThemesSettings = require('themes/themes.json');
|
||||
|
||||
const Themes = {};
|
||||
Themes['Legacy_5ePHB'] = require('themes/Legacy/5ePHB/snippets.js');
|
||||
Themes['V3_5ePHB'] = require('themes/V3/5ePHB/snippets.js');
|
||||
Themes['V3_5eDMG'] = require('themes/V3/5eDMG/snippets.js');
|
||||
|
||||
const execute = function(val, brew){
|
||||
if(_.isFunction(val)) return val(brew);
|
||||
@@ -42,7 +45,8 @@ const Snippetbar = createClass({
|
||||
componentDidMount : async function() {
|
||||
const rendererPath = this.props.renderer == 'V3' ? 'V3' : 'Legacy';
|
||||
const themePath = this.props.theme ?? '5ePHB';
|
||||
const snippets = Themes[`${rendererPath}_${themePath}`];
|
||||
let snippets = Themes[`${rendererPath}_${themePath}`];
|
||||
snippets = this.compileSnippets(rendererPath, themePath, snippets);
|
||||
this.setState({
|
||||
snippets : snippets
|
||||
});
|
||||
@@ -52,13 +56,29 @@ const Snippetbar = createClass({
|
||||
if(prevProps.renderer != this.props.renderer) {
|
||||
const rendererPath = this.props.renderer == 'V3' ? 'V3' : 'Legacy';
|
||||
const themePath = this.props.theme ?? '5ePHB';
|
||||
const snippets = Themes[`${rendererPath}_${themePath}`];
|
||||
let snippets = Themes[`${rendererPath}_${themePath}`];
|
||||
snippets = this.compileSnippets(rendererPath, themePath, snippets);
|
||||
this.setState({
|
||||
snippets : snippets
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
compileSnippets : function(rendererPath, themePath, snippets) {
|
||||
let compiledSnippets = snippets;
|
||||
console.log(ThemesSettings);
|
||||
console.log("rendererpath:");
|
||||
console.log(rendererPath);
|
||||
console.log("themepath");
|
||||
console.log(themePath);
|
||||
const baseThemePath = ThemesSettings[rendererPath][themePath].baseTheme;
|
||||
if(baseThemePath) {
|
||||
compiledSnippets = _.merge(compiledSnippets, Themes[`${rendererPath}_${baseThemePath}`]);
|
||||
this.compileSnippets(rendererPath, themePath, compiledSnippets);
|
||||
}
|
||||
return compiledSnippets;
|
||||
},
|
||||
|
||||
handleSnippetClick : function(injectedText){
|
||||
this.props.onInject(injectedText);
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user