mo4islona / node-blockly

Blockly for Node.js and Browser via CommonJS module
133 stars 81 forks source link

Blockly.Theme.defineTheme() is not a function #44

Closed FirstPotatoMan closed 4 years ago

FirstPotatoMan commented 4 years ago

Here's my code. However, it returns an error: browser.default.Theme.defineTheme is not a function

import Blockly from "node-blockly/browser";

const theme = Blockly.Theme.defineTheme("stone", {
  base: Blockly.Themes.Classic,
  fontStyle: {
    family: "Raleway, sans serif",
    weight: "bold",
    size: 12
  },
  componentStyles: {
    workspaceBackgroundColour: "red",
    toolboxBackgroundColour: "#333"
  }
});

export default theme;
FirstPotatoMan commented 4 years ago

Turns out Blockly.Theme.defineTheme is indeed, not a function. Here is my working updated code if anyone runs into a similar issue.

import Blockly from "node-blockly/browser";

const fontStyle = {
  family: "Raleway, sans serif",
  weight: "bold",
  size: 12
};

const componentStyle = {
  workspaceBackgroundColour: "red",
  toolboxBackgroundColour: "#333"
};

const stone = (Blockly.Theme.defineTheme = {
  base: Blockly.Themes.Classic,
  fontStyle: fontStyle,
  componentStyles: componentStyle
});

export default stone;