Skip to content

Commit

Permalink
Hide infinity trend percentage changes (#1261)
Browse files Browse the repository at this point in the history
  • Loading branch information
zachgoll authored Oct 7, 2024
1 parent d2a6ab1 commit c397f1b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion app/views/pages/dashboard.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,9 @@
<% @top_savers.first(3).each do |account| %>
<%= link_to account, class: "border border-alpha-black-25 rounded-full p-1 pr-2 flex items-center gap-1 text-xs text-gray-900 font-medium hover:bg-gray-25" do %>
<%= image_tag account_logo_url(account), class: "w-5 h-5" %>
<span><%= account.savings_rate > 0 ? "+" : "-" %><%= number_to_percentage(account.savings_rate.abs * 100, precision: 2) %></span>
<% unless account.savings_rate.infinite? %>
<span><%= account.savings_rate > 0 ? "+" : "-" %><%= number_to_percentage(account.savings_rate.abs * 100, precision: 2) %></span>
<% end %>
<% end %>
<% end %>
<% if @top_savers.count > 3 %>
Expand Down
6 changes: 5 additions & 1 deletion app/views/shared/_trend_change.html.erb
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<%# locals: { trend: } %>
<% styles = trend_styles(trend) %>

<p class="text-sm <%= styles[:text_class] %>">
<% if trend.direction.flat? %>
<span>No change</span>
<% else %>
<span><%= styles[:symbol] %><%= trend.value.is_a?(Money) ? format_money(trend.value.abs) : trend.value.abs.round(2) %></span>
<span>(<%= lucide_icon(styles[:icon], class: "w-4 h-4 align-text-bottom inline") %><%= trend.percent.abs %>%)</span>
<% unless trend.percent.infinite? %>
<span>(<%= lucide_icon(styles[:icon], class: "w-4 h-4 align-text-bottom inline") %><%= trend.percent.abs %>%)</span>
<% end %>
<% end %>
</p>

0 comments on commit c397f1b

Please sign in to comment.