开发者

Add style switcher to Rails App admin section?

I have been working on a Rails template recently called BaseApp2. You can see it on GitHub here: http://github.com/dannyweb/BaseApp2

There is an administrators section setup which allows the management of Users and I am working on the ability to add announcements to the public site via the admin section.

What I would really like to do, is come up with two or three开发者_如何转开发 alternative colour schemes for the interface and allow the administrator to choose which they prefer and select it. The chosen colour scheme would then show for all users from then on.

I have literally no idea how to go about doing this - ideally I am looking for a tutorial of some sort or something equally beginner-esque.

Thanks in advance!

Thanks,

Danny


It should be fairly easy and there are many ways to do it. You will need to save that preference somewhere. Maybe add an attribute to your user/person model that will specify that preference. And in your admin layout template, based on that preference, add an additional stylesheet. Or, add a class to the body tag and in your style sheet subclass the styles:

body {
  background-color: white;
}

body.sunshine {
  background-color: yellow;
}

The layout template:

<%= stylesheet_link_tag(current_user.theme) if current_user.theme %> 

or

<body class="<%= current_user.theme || '' %>">
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜