Constructs a ThemeManager.
If a themeMap isn't provided, this gets default light
and dark
themes
that are copies of Themes.Light and Themes.Dark, respectively.
Optional
init: Partial<ThemeManager>Optional initialization properties.
Gets or sets whether this ThemeManager changes the div background color when currentTheme changes.
If true, the background color will be set to the CSS color string denoted by the div
property
of the Theme.colors object.
Gets or sets the current theme for this ThemeManager.
A value of system
will rely on the browser's preferred color scheme,
using light
or dark
themes.
Gets or sets the default theme for this ThemeManager.
This property determines which theme is used as a fallback if a lookup doesn't find a value in the current theme.
Readonly
preferredThis read-only property returns the user's preferred color scheme,
useful when currentTheme is set to system
.
See https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme.
Gets or sets the map of theme names -> Themes for this ThemeManager.
Virtual
findFinds a value in this ThemeManager's themes.
By default, this first looks in the currentTheme, then the defaultTheme.
Because findTheme is called, this method also handles currentTheme being system
.
The default implementation is:
return this.getValue(this.findTheme(this.currentTheme), prop, source, tprop) || this.getValue(this.findTheme(this.defaultTheme), prop, source, tprop);
This method may be overridden to search Themes in different orders. Please read the Introduction page on Extensions for how to override methods and how to call this base method.
a property to search for in the Theme, also accepting '.'-separated paths, an array of strings representing a path, or an index to an array element
Optional
source: string | string[]where to perform the lookup within the Theme object
Optional
tprop: stringan optional target property name, used if a full path is not provided, which can determine the property on the Theme object to search via Theme.targetPropertyMap
the value found, or undefined if not found
Virtual
getGets a value from the given Theme.
the Theme to search
a property to search for in the Theme, also accepting '.'-separated paths, an array of strings representing a path, or an index to an array element
Optional
source: string | string[]where to perform the lookup within the Theme object
Optional
tprop: stringan optional target property name, used if a full path is not provided, which can determine the property on the Theme object to search via Theme.targetPropertyMap
the value in the given Theme, or undefined if not found
Inform this ThemeManager that it will no longer handle theming for a given diagram.
this
Set a particular theme and update all associated theme bindings. Note that this will modify the named Theme object via a merge if it exists.
If passed system
, this method will create/update the preferredColorScheme theme.
which theme to change, or the empty string to update the default theme
a partial Theme object to merge into the given theme or add as a new theme
this
This class is responsible for managing a Diagram's theming (or multiple Diagrams, if shared).
Read more about theming at Theming.
Your templates can make use of the values held by the current Theme by calling GraphObject.theme or GraphObject.themeData or GraphObject.themeModel methods, or by adding a ThemeBinding to a GraphObject when using GraphObject.make. All theme bindings are OneWay only -- from source data to target GraphObject property.
Use GraphObject.theme to look up a value directly from the current Theme. Use GraphObject.themeData to look up a value in the current Theme based on the value of a data property. Use GraphObject.themeModel to look up a value in the current Theme based on the value of a data property on the Model.modelData shared object.
For example:
See Themes for the definitions of the two predefined Themes that are normally used.
There are additional theming resources defined in Themes.js in the extensions or extensionsJSM directories.
since
3.0