I have a site with clients. Every client can have it’s own theme and when a user of a certain client is logged in, the company theme must be loaded. In the application.css.scss I have a line like this for every company:
@import "_theme_x.css.scss";
@import "_theme_y.css.scss";
@import "_theme_z.css.scss";
How can I load only e.g. theme_x when a user of company x is logged in and not load theme_y and theme_z? Or is there a better way of doing this? Thanks!
If themes are large, you might want to separate them from the application.css and load them conditionally in your layout. For example, if you have a helper
theme_stylesheetin application_helper which returns the name of the theme the client is using:If they are small, I like namespacing. Leave your application.css as-is, but modify the themes to use a top-level rule on the body. Place a tag on the body to select the theme. The beauty of this is you can dynamically change the theme.
_theme_x.css.scss