Skip to main content

Class: Theme

Defined in: packages/blockly/core/theme.ts:30

Class for a theme.

Implements​

  • ITheme

Properties index​

PropertyDescription
nameTheme name.

Methods index​

MethodDescription
setBlockStyleOverrides or adds a style to the blockStyles map.
setCategoryStyleOverrides or adds a style to the categoryStyles map.
getComponentStyleGets 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.
setComponentStyleConfigure a specific Blockly UI component with a style value.
setFontStyleConfigure a theme's font style.
setStartHatsConfigure a theme's start hats.
defineThemeDefine a new Blockly theme.

Constructors​

Constructor​

new Theme(
name,
opt_blockStyles?,
opt_categoryStyles?,
opt_componentStyles?
): Theme;

Defined in: packages/blockly/core/theme.ts:56

Parameters​

ParameterTypeDescription
namestringTheme name.
opt_blockStyles?{ [key: string]: Partial<BlockStyle>; }A map from style names (strings) to objects with style attributes for blocks.
opt_categoryStyles?{ [key: string]: CategoryStyle; }A map from style names (strings) to objects with style attributes for categories.
opt_componentStyles?ComponentStyleA map of Blockly component names to style value.

Returns​

Theme

Properties​

name​

name: string;

Defined in: packages/blockly/core/theme.ts:57

Theme name.

Implementation of​

ITheme.name

Methods​

setBlockStyle()​

setBlockStyle(blockStyleName, blockStyle): void;

Defined in: packages/blockly/core/theme.ts:95

Overrides or adds a style to the blockStyles map.

Parameters​

ParameterTypeDescription
blockStyleNamestringThe name of the block style.
blockStyleBlockStyleThe block style.

Returns​

void


setCategoryStyle()​

setCategoryStyle(categoryStyleName, categoryStyle): void;

Defined in: packages/blockly/core/theme.ts:105

Overrides or adds a style to the categoryStyles map.

Parameters​

ParameterTypeDescription
categoryStyleNamestringThe name of the category style.
categoryStyleCategoryStyleThe category style.

Returns​

void


getComponentStyle()​

getComponentStyle(componentName): string | null;

Defined in: packages/blockly/core/theme.ts:116

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.

Parameters​

ParameterTypeDescription
componentNamestringThe name of the component.

Returns​

string | null

The style value.


setComponentStyle()​

setComponentStyle(componentName, styleValue): void;

Defined in: packages/blockly/core/theme.ts:136

Configure a specific Blockly UI component with a style value.

Parameters​

ParameterTypeDescription
componentNamestringThe name of the component.
styleValueanyThe style value.

Returns​

void


setFontStyle()​

setFontStyle(fontStyle): void;

Defined in: packages/blockly/core/theme.ts:145

Configure a theme's font style.

Parameters​

ParameterTypeDescription
fontStyleFontStyleThe font style.

Returns​

void


setStartHats()​

setStartHats(startHats): void;

Defined in: packages/blockly/core/theme.ts:154

Configure a theme's start hats.

Parameters​

ParameterTypeDescription
startHatsbooleanTrue if the theme enables start hats, false otherwise.

Returns​

void


defineTheme()​

static defineTheme(name, themeObj): Theme;

Defined in: packages/blockly/core/theme.ts:165

Define a new Blockly theme.

Parameters​

ParameterTypeDescription
namestringThe name of the theme.
themeObjIThemeAn object containing theme properties.

Returns​

Theme

A new Blockly theme.