Skip to content

Commit

Permalink
fix(theme): make sure use default theme by default
Browse files Browse the repository at this point in the history
User could use `theme="ide"` and get no theme on editor
  • Loading branch information
AlexanderPrendota committed Aug 3, 2018
1 parent b9239fd commit 5e6f265
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/executable-code/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export default class ExecutableCode {
const indent = targetNode.hasAttribute(ATTRIBUTES.INDENT) ? parseInt(targetNode.getAttribute(ATTRIBUTES.INDENT)) : DEFAULT_INDENT;
const from = targetNode.hasAttribute(ATTRIBUTES.FROM) ? parseInt(targetNode.getAttribute(ATTRIBUTES.FROM)) : null;
const to = targetNode.hasAttribute(ATTRIBUTES.TO) ? parseInt(targetNode.getAttribute(ATTRIBUTES.TO)) : null;
const editorTheme = targetNode.hasAttribute(ATTRIBUTES.THEME) ? targetNode.getAttribute(ATTRIBUTES.THEME) : THEMES.DEFAULT;
const editorTheme = this.getTheme(targetNode);
const args = targetNode.hasAttribute(ATTRIBUTES.ARGUMENTS) ? targetNode.getAttribute(ATTRIBUTES.ARGUMENTS) : "";
const hiddenDependencies = this.getHiddenDependencies(targetNode);
let targetPlatform = targetNode.getAttribute(ATTRIBUTES.PLATFORM);
Expand Down Expand Up @@ -150,6 +150,18 @@ export default class ExecutableCode {
}, [])
}

getTheme(targetNode){
const theme = targetNode.getAttribute(ATTRIBUTES.THEME);
switch (theme) {
case THEMES.DARCULA:
return THEMES.DARCULA;
case THEMES.IDEA:
return THEMES.IDEA;
default:
return THEMES.DEFAULT;
}
}

getMode(targetNode) {
const mode = targetNode.getAttribute(ATTRIBUTES.MODE);
switch (mode) {
Expand Down
1 change: 1 addition & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import defaultConfig from './config';
*/
export const THEMES = {
DARCULA: "darcula",
IDEA: "idea",
DEFAULT: "default"
};
/**
Expand Down

0 comments on commit 5e6f265

Please sign in to comment.