color-code habits

This commit is contained in:
Tyler Renelle 2012-02-01 10:50:52 -05:00
parent 9173c072c4
commit 8289741421
2 changed files with 23 additions and 3 deletions

View file

@ -1,3 +1,9 @@
// Place all the styles related to the Habits controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
.bad { background-color:rgb(224, 102, 102); }
.iffy { background-color:rgb(246, 178, 107); }
.ok { background-color:rgb(255, 217, 102); }
.good { background-color:rgb(147, 196, 125); }
.done { background-color:rgb(201, 218, 248); }

View file

@ -1,15 +1,29 @@
<div id="<%= habit.id %>">
<%
case habit.score
when -100..-5 then score = 'bad'
when -5..0 then score = 'iffy'
when 0..5 then score = 'ok'
when 5..15 then score = 'good'
when 15..100 then score = 'done'
end
name = "<span class='#{score}'>#{habit.name}</span>"
%>
<% if habit.habit_type==Habit::ALWAYS %>
<%= link_to "√", { :action => "vote", :id => habit.id, :vote => 'up' }, :remote=>true %>
<%= link_to "X", { :action => "vote", :id => habit.id, :vote => 'down' }, :remote=>true %>
<%= habit.name %> (<%= habit.score %>)
<%= raw name %> (<%= habit.score %>)
<% elsif habit.habit_type==Habit::DAILY %>
<% if habit.done %>
<%= link_to("[X]", { :action => "vote", :id => habit.id, :vote => 'down' }, :remote=>true) %>
<strike><%= habit.name %></strike> (<%= habit.score %>)
<strike><%= raw name %></strike> (<%= habit.score %>)
<% else %>
<%= link_to("[ ]", { :action => "vote", :id => habit.id, :vote => 'up' }, :remote=>true) %>
<%= habit.name %> (<%= habit.score %>)
<%= raw name %> (<%= habit.score %>)
<% end %>
<% end %>
<%= link_to 'Edit', edit_habit_path(habit) %>