0
0
mirror of https://github.com/naturalcrit/homebrewery.git synced 2026-01-04 16:52:38 +00:00
This commit is contained in:
Trevor Buckner
2022-05-16 01:41:31 -04:00
parent 4f6555b522
commit a17a9ac0a0

View File

@@ -56,7 +56,7 @@ const Snippetbar = createClass({
if(prevProps.renderer != this.props.renderer || prevProps.theme != this.props.theme) { if(prevProps.renderer != this.props.renderer || prevProps.theme != this.props.theme) {
const rendererPath = this.props.renderer == 'V3' ? 'V3' : 'Legacy'; const rendererPath = this.props.renderer == 'V3' ? 'V3' : 'Legacy';
const themePath = this.props.theme ?? '5ePHB'; const themePath = this.props.theme ?? '5ePHB';
console.log({ThemeSnippets:ThemeSnippets}); console.log({ ThemeSnippets: ThemeSnippets });
let snippets = ThemeSnippets[`${rendererPath}_${themePath}`]; let snippets = ThemeSnippets[`${rendererPath}_${themePath}`];
snippets = this.compileSnippets(rendererPath, themePath, snippets); snippets = this.compileSnippets(rendererPath, themePath, snippets);
this.setState({ this.setState({
@@ -66,21 +66,21 @@ const Snippetbar = createClass({
}, },
mergeCustomizer : function(objValue, srcValue) { mergeCustomizer : function(objValue, srcValue) {
  if (_.isArray(objValue)) { if(_.isArray(objValue)) {
let result = _.unionBy(srcValue, objValue, 'name'); // Join snippets together, with preference for the current theme over the base theme const result = _.unionBy(srcValue, objValue, 'name'); // Join snippets together, with preference for the current theme over the base theme
return _.filter(result, 'gen'); //Only keep snippets with a 'gen' property. return _.filter(result, 'gen'); //Only keep snippets with a 'gen' property.
  } }
}, },
compileSnippets : function(rendererPath, themePath, snippets) { compileSnippets : function(rendererPath, themePath, snippets) {
let compiledSnippets = snippets; let compiledSnippets = snippets;
const baseThemePath = Themes[rendererPath][themePath].baseTheme; const baseThemePath = Themes[rendererPath][themePath].baseTheme;
console.log({baseSnippets:ThemeSnippets[`${rendererPath}_${baseThemePath}`]}); console.log({ baseSnippets: ThemeSnippets[`${rendererPath}_${baseThemePath}`] });
console.log({themeSnippets:compiledSnippets}); console.log({ themeSnippets: compiledSnippets });
if(baseThemePath) { if(baseThemePath) {
compiledSnippets = _.mergeWith([], ThemeSnippets[`${rendererPath}_${baseThemePath}`], compiledSnippets, this.mergeCustomizer); compiledSnippets = _.mergeWith([], ThemeSnippets[`${rendererPath}_${baseThemePath}`], compiledSnippets, this.mergeCustomizer);
console.log({compiledSnippets:compiledSnippets}); console.log({ compiledSnippets: compiledSnippets });
//this.compileSnippets(rendererPath, themePath, compiledSnippets); (for nested baseThemes) //this.compileSnippets(rendererPath, themePath, compiledSnippets); (for nested baseThemes)
} }
return compiledSnippets; return compiledSnippets;