User theme switching with SASS - Ruby on Rails

后端 未结 4 544
执笔经年
执笔经年 2021-02-04 13:45

So I have an rails admin system that will allow a user to choose a theme, basically a set of SASS color variables that will recompile application.css.scss with the new colors. H

4条回答
  •  旧时难觅i
    2021-02-04 14:10

    One option is to simply load a set of custom css rules (your theme) after your application.css and let your theme override the default colors from application.css. You could just add a database column "theme" and load the css with this name dynamically like.

    SASS is not designed for compiling dynamic data on the fly. If you want dynamic css processing, you could add a controller method called "custom_css" and make this respond to the css format and load this dynamically with inline variables, but I don't think SASS is meant to be used for it at all.

提交回复
热议问题