Constructor

Theme

new Theme(blockStyles, categoryStyles, opt_componentStyles)

Class for a theme.

Parameter

blockStyles

Object with Blockly.Theme.BlockStyle properties

A map from style names (strings) to objects with style attributes for blocks.

Value must not be null.

categoryStyles

Object with Blockly.Theme.CategoryStyle properties

A map from style names (strings) to objects with style attributes for categories.

Value must not be null.

opt_componentStyles

Optional

Object with any type properties

A map of Blockly component names to style value.

Value must not be null.

Properties

blockStyles_

non-null Object with Blockly.Theme.BlockStyle properties

The block styles map.

categoryStyles_

non-null Object with Blockly.Theme.CategoryStyle properties

The category styles map.

componentStyles_

non-null Object with any type properties

The UI components styles map.

Methods

getAllBlockStyles

getAllBlockStyles() returns Object with Blockly.Theme.BlockStyle properties

Gets a map of all the block style names.

Returns

non-null Object with Blockly.Theme.BlockStyle properties Map of block styles.

getBlockStyle

getBlockStyle(blockStyleName) returns (Blockly.Theme.BlockStyle or undefined)

Gets the BlockStyle for the given block style name.

Parameter

blockStyleName

string

The name of the block style.

Returns

(Blockly.Theme.BlockStyle or undefined) The named block style.

getCategoryStyle

getCategoryStyle(categoryStyleName) returns (Blockly.Theme.CategoryStyle or undefined)

Gets the CategoryStyle for the given category style name.

Parameter

categoryStyleName

string

The name of the category style.

Returns

(Blockly.Theme.CategoryStyle or undefined) The named category style.

getComponentStyle

getComponentStyle(componentName) returns string

Gets the style for a given Blockly UI component. If the style value is a string, we attempt to find the value of any named references.

Parameter

componentName

string

The name of the component.

Returns

nullable string The style value.

setAllBlockStyles

setAllBlockStyles(blockStyles)

Overrides or adds all values from blockStyles to blockStyles_

Parameter

blockStyles

Object with Blockly.Theme.BlockStyle properties

Map of block styles.

setBlockStyle

setBlockStyle(blockStyleName, blockStyle)

Overrides or adds a style to the blockStyles map.

Parameter

blockStyleName

string

The name of the block style.

blockStyle

Blockly.Theme.BlockStyle

The block style.

setCategoryStyle

setCategoryStyle(categoryStyleName, categoryStyle)

Overrides or adds a style to the categoryStyles map.

Parameter

categoryStyleName

string

The name of the category style.

categoryStyle

Blockly.Theme.CategoryStyle

The category style.

setComponentStyle

setComponentStyle(componentName, styleValue)

Configure a specific Blockly UI component with a style value.

Parameter

componentName

string

The name of the component.

styleValue

any type

The style value.

Abstract types

BlockStyle

static

{colourPrimary:string, colourSecondary:string, colourTertiary:string, hat:string}

A block style.

CategoryStyle

static

{colour:string}

A category style.