Version 2
What is new? Migration Guide From V1
Getting Started
Understanding WinnetouJs Setting Up
Constructos
Creating Constructos Advanced Options Lazy Loading
Mutables
Constructos State Management Case: Custom State Management System Winnetou FX
Addons
Winnetou Selectors Winnetou Router App Translations CSS Sass Built-in Transpiler SVG Icons Color Themes
Extras
Useful JsDoc Syntax
Plugins
Creating Plugins SlideScreen Official Plugin Animate Official Plugin
Compiling to Production
WBR
API Change Log Git Hub Pull Requests Guidelines Get in touch
Addons

Color Themes

The current css now allows us to work with variables within the css and change them via javascript. That is why WinnetouJs implements the newTheme method, responsible for dynamically changing themes within web applications.

First, our app has to be using the css variables in order to create your style sheets.

base.scss

        
:root {
    --main-bg-color: #222;
    --main-fg-color: #eee;
}
body,
html {
    background-color: var(--main-bg-color);
    color: var(--main-fg-color);
}
       
      

Now we can create our themes and change them at any time. The themes will be saved in client and will be loaded the next time the user open our app.

app.js

        
function lightTheme() {
    Winnetou.newTheme({
        "--main-bg-color": "#fff",
        "--main-fg-color": "#333",
    });
}

function darkTheme() {
    Winnetou.newTheme({
        "--main-bg-color": "#222",
        "--main-fg-color": "#eee",
    });
}