Reputation: 125
I made a file called template.css.scss in my Rails app that holds all the color styling that I want dynamically changed based on a user's preferences.
Here's a little sample of it:
/* pink */
$lighter-shade: #F75F9E;
$darker-shade: #B54573;
.navbar-inverse {
background-color: $lighter-shade;
}
#command-header {
color: $darker-shade;
}
I thought I could do a migration to add a column to track the user's styling preference. Of course, there would be a default setting. Then I could update the Sass variables based on the preference.
Unfortunately, from my research it seems like the way to go is to create separate templates and then set those dynamically based on the user's preference. I really hope that's not the case because the way I have things structured right now is concise and efficient, and I'd hate to lose that.
How would you go about this?
Upvotes: 1
Views: 570
Reputation: 4453
one way to handle: get the user's preference and put it into a
data-user-preference="<%= current_user.pref %>">
then use jquery to add the appropriate class based on that pref
$('.class-name').data('user-preference').addClass('whatever')
Upvotes: 1