1

I have hundreds of ExtJS theme (Classic toolkit) global variables placed in ./theme/sass/var/Component.scss

Is there some way to create a condition depending on my JavaScript or Http query string environments?

I want to split a bunch of global variables on to separate groups and have ability to choose it from my application functions.

1 Answer 1

2

MODERN

Add variables to the theme. In modern you can use:

    $compoany-base-color-50: green; 
    :root {
        --company-base-color-50: export;
    }

In scss you now have to use the $company-base-color-50 or var(--company-base-color-50).

In JavaScript you can set the variable:

Ext.getBody().dom.setProperty("--company-base-color-50", "red");

CLASSIC

For custom components you can still use a variation of the MODERN approach.

:root {
    --company-base-color-50: #aabbcc;  // add more colors
}

And in your custom components you can easily switch colors.

const myComp  = Ext.get('myComp'),
      element = myComp.el,
      dom     = element.dom;

dom.setProperty("--company-base-color-50", "red");

But to switch a full theme you have to generate all themes and then use them via javascript. Follow this example:

How to Implement a Theme Switcher (Light/Dark Mode) in ExtJS 6.6 Classic Toolkit?

OR

https://www.thesitewizard.com/javascripts/change-style-sheets.shtml

With slight modifications you can load themes on the fly, so you do not have to load all themes initially.

3
  • Thank you very much Torsten! But i use classic toolkit (updated my Q). Is it possible here? Commented Jun 28 at 9:37
  • May be there is some hack with scss groups which I can choose from JS? Commented Jun 28 at 9:48
  • I updated my example
    – Dinkheller
    Commented Jun 29 at 9:59

Not the answer you're looking for? Browse other questions tagged or ask your own question.