Using the StyleSheet switcher Widget

0
Hi, I am currently developing in 6.10.3, and struggling to get this StyleSheet switcher widget to work. The idea is to have two different stylesheets live in the application as we slowly remodel different parts of it. So upon landing on the homepage you would receive style sheet A, and then after navigating to a newly remodeled page, you would receive style sheet B.  The issue that I am running into, is once a user has style sheet A and then navigates to a page that needs style sheet B, the widget is just adding the style sheet B without clearing out style sheet A.  Does anyone know if its possible to accomplish what I'm trying to do with this widget? Or if the intended use of it is to only be able to load a certain style sheet upon log in, and  not be able to flip flop within the applicatiton?       EDIT:   Thank you guys for your help. I figured out the issue had to do with the return value being the same as the default library.    So when I want style sheet A,  I have a microflow that returns the string "lib-a", and the default library is "lib-b". When I want style sheet B, I return "lib-b", and set the default to "lib-a".   Not too sure why this fixed the issue but it works now. 
asked
3 answers
2

Hi Austin,

What this widget does is loading a stylesheet based upon the outcome of a microflow (and if the MF does not provide a stylesheet, fall back on the default as configured on the page where the widget is configured. My primairy objective while creating the widget was indeed a different styling for different tenants in multi tenant environment (that's why you can also use the url that the client uses to connect to when there are multiple Mendix App URLs.

When a new stylesheet is added, the default is removed. So your workarround does indeed work to use lib-a.css on one page and lib-b.css on the other.

If you have a different usecase and cannot manage within the current implementation of the widget, please file a ticket on GitHub and I will dive into it. See: https://github.com/rik-bos/StyleSheetSwitcher/issues

For small differences within pages, the solution of different classes per layout (or even page) is indeed recommended to decrease the load. The widget will create a MF call to the server for each new instance (so for each style change) and the browser will try to load the new stylesheet (from cache if possible).

answered
1

And the stylesheet switcher does indeed need the login process to work as far as I know. To my knowledge it is not possible to flip flop like you want. But maybe the maker of the widget can chime in here (Rick Bos) to give you a definate answer.

Regards,

Ronald

[EDIT]

I noticed that the documentation in the appstore is non existant. On github you do find the documentation. Gives you some insight about the inner workings of the widget.

https://github.com/rik-bos/StyleSheetSwitcher

answered
2

Instead of using the StyleSheet switcher widget, here's an alternative that should be pretty simple to set up:

  • Use different layouts for your old and new style pages
  • Add a class to each layout, either "styleV1 or styleV2"
  • Wrap your old SASS in .styleV1 {} and put the new stuff in .styleV2 {}
answered