initTwThemes(schema, themes, [initialThemeName], [initialInvertShade]): TwThemes
The initTwThemes()
function is the entry point into tw-themes.
It initializes the utility for use in your application, and must be
invoked very early in the application startup lifecycle (typically in
a module scoped context).
Once the application has fully loaded (via the window load
event),
the initialThemeName
/initialInvertShade
will be activated
automatically. This allows the application to manage this initial
state (for example in the browser's local storage).
In essence initTwThemes()
is an object creator. It returns the
TwThemes
object, from which from which all
remaining tw-themes API is promoted. This is done so as to fuse
the relationship between the Schema
and
Themes
.
The TwThemes
object contains functions to:
change the active theme at run-time ... see:
activateNextTheme()
,activatePriorTheme()
,activateTheme()
,toggleInvertShade()
miscellaneous API in support of the app's theme selection UI control ... see:
getActiveInvertShade()
getActiveThemeName()
,getThemes()
,auto configure the tailwind context colors in
tailwind.config.js
(part of the build process) ... see:colorConfig()
NOTE: These TwThemes
methods are in reality functions
(not methods). In other words, they can be used without
dereferencing the object at run-time. The object wrapper (in this
case) is simply a delivery mechanism.
NOTE: For additional considerations regarding the
TwThemes
object, please refer to the discussions on
App State and TwThemes Reactivity.
API:
+ initTwThemes(schema, themes, [initialThemeName], [initialInvertShade]): TwThemes
Parameters:
schema
:Schema
- the app-specific color schema, defining all Context Colors.themes
:Themes
- the structure defining one or more named color themes supported by this application. This applies real colors to the context colors specified in the app'sSchema
.initialThemeName
: {string} - the initialthemeName
to use at app startup.DEFAULT: The first theme in the
themes
reference.initialInvertShade
: {boolean} - the initialinvertShade
option to use at app startup.DEFAULT:
false
Return: TwThemes
- a TwThemes
object, from which
from which all remaining tw-themes API is promoted.