Created
March 31, 2015 21:13
-
-
Save TeriPastorino/52c67f9666f5d9dd1990 to your computer and use it in GitHub Desktop.
conditional formatting
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= 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 %> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.active { | |
color: green; | |
} | |
.pending { | |
color: yellow; | |
} | |
.urgent { | |
color: red; | |
} | |
.todo-item:nth-child(odd) { | |
background-color: red; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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