Class: Theme

Constructor

Theme

new Theme(name, opt_blockStyles, opt_categoryStyles, opt_componentStyles)

Class for a theme.

Parameter

name

string

Theme name.

opt_blockStyles

Optional

Object with Blockly.Theme.BlockStyle properties

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

Value must not be null.

opt_categoryStyles

Optional

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

Blockly.Theme.ComponentStyle

A map of Blockly component names to style value.

Value must not be null.

Properties

blockStyles

package

non-null Object with non-null Blockly.Theme.BlockStyle properties

The block styles map.

categoryStyles

package

non-null Object with Blockly.Theme.CategoryStyle properties

The category styles map.

componentStyles

package

non-null Blockly.Theme.ComponentStyle

The UI components styles map.

fontStyle

package

non-null Blockly.Theme.FontStyle

The font style.

name

string

The theme name. This can be used to reference a specific theme in CSS.

startHats

package

nullable boolean

Whether or not to add a 'hat' on top of all blocks with no previous or output connections.

Methods

defineTheme

static

defineTheme(name, themeObj) returns Blockly.Theme

Define a new Blockly theme.

Parameter

name

string

The name of the theme.

themeObj

Object

An object containing theme properties.

Value must not be null.

Returns

non-null Blockly.Theme A new Blockly theme.

getClassName

package

getClassName() returns string

Gets the class name that identifies this theme.

Returns

string The CSS class name.

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.

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.

setFontStyle

setFontStyle(fontStyle)

Configure a theme's font style.

Parameter

fontStyle

Blockly.Theme.FontStyle

The font style.

setStartHats

setStartHats(startHats)

Configure a theme's start hats.

Parameter

startHats

boolean

True if the theme enables start hats, false otherwise.

Abstract types

BlockStyle

static

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

A block style.

CategoryStyle

static

{colour:string}

A category style.

ComponentStyle

static

{workspaceBackgroundColour: nullable string, toolboxBackgroundColour: nullable string, toolboxForegroundColour: nullable string, flyoutBackgroundColour: nullable string, flyoutForegroundColour: nullable string, flyoutOpacity: nullable number, scrollbarColour: nullable string, scrollbarOpacity: nullable number, insertionMarkerColour: nullable string, insertionMarkerOpacity: nullable number, markerColour: nullable string, cursorColour: nullable string, selectedGlowColour: nullable string, selectedGlowOpacity: nullable number, replacementGlowColour: nullable string, replacementGlowOpacity: nullable number}

A component style.

FontStyle

static

{family: nullable string, weight: nullable string, size: nullable number}

A font style.