Skip to content

Instantly share code, notes, and snippets.

@TeriPastorino
Created March 31, 2015 21:13
Show Gist options
  • Save TeriPastorino/52c67f9666f5d9dd1990 to your computer and use it in GitHub Desktop.
Save TeriPastorino/52c67f9666f5d9dd1990 to your computer and use it in GitHub Desktop.
conditional formatting
<%= content_tag :li, class: 'list-group-item todo-item', id: "item-#{item.id}" do %>
- <%= item.description %>
- <%= link_to " ", [current_user, item], method: :delete, class: 'glyphicon glyphicon-ok pull-right', remote: true %>
- <div class="text-center-small">
- <small class="<%= format_days_remaining(item.days_left) %>">
- <%= item.days_left.to_s. + " days left to complete" %>
- </small>
- </div>
-<% end %>
<%= content_tag :li, class: 'list-group-item', id: "item-#{item.id}" do %>
<%= item.description %>
<%= link_to " ", [current_user, item], method: :delete, class: 'glyphicon glyphicon-ok pull-right', remote: true %></li>
<div class="text-center-small">
<% if item.days_left >= 6 %>
<small class="active"><%= item.days_left.to_s + " days left to complete" %></small>
<% elsif item.days_left <= 4 %>
<small class="pending"><%= item.days_left.to_s + " days left to complete" %></small>
<% else %>
<small class="urgent"><%= item.days_left.to_s + " days left to complete" %></small>
</div>
<% end %>
<% end %>
.active {
color: green;
}
.pending {
color: yellow;
}
.urgent {
color: red;
}
.todo-item:nth-child(odd) {
background-color: red;
}
def format_days_remaining(days_left)
# if days_left >= 6
# "active"
# elsif days_left <= 4
# "urgent"
# else
# "critical"
# end
# end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment