mirror of
https://github.com/we-promise/sure.git
synced 2026-04-19 12:04:08 +00:00
Add balance heading, date period partials (#507)
* Make balance heading partial * Move period dropdown to partial * Fix tests * Remove redundant arg
This commit is contained in:
25
app/views/shared/_balance_heading.html.erb
Normal file
25
app/views/shared/_balance_heading.html.erb
Normal file
@@ -0,0 +1,25 @@
|
||||
<%# locals: (label:, period:, balance:, trend:, size: "lg")%>
|
||||
<div class="space-y-2">
|
||||
<p class="text-sm text-gray-500"><%= label %></p>
|
||||
<p class="text-gray-900 -space-x-0.5">
|
||||
<span class="text-gray-500"><%= balance.symbol %></span>
|
||||
<span class="<%= size == "lg" ? "text-xl" : "text-lg" %> font-medium"><%= format_currency(balance.amount, precision: 0, unit: '') %></span>
|
||||
<%- if balance.precision.positive? -%>
|
||||
<span class="text-gray-500">
|
||||
<%= balance.separator %><%= balance.cents %>
|
||||
</span>
|
||||
<% end %>
|
||||
</p>
|
||||
<% if trend.nil? %>
|
||||
<p class="text-sm text-gray-500">Data not available for the selected period</p>
|
||||
<% elsif trend.direction == "flat" %>
|
||||
<p class="text-sm text-gray-500">No change vs. prior period</p>
|
||||
<% else %>
|
||||
<% styles = trend_styles(trend) %>
|
||||
<p class="text-sm <%= styles[:text_class] %>">
|
||||
<span><%= styles[:symbol] %><%= format_currency(trend.amount.abs, precision: balance.precision) %></span>
|
||||
<span>(<%= lucide_icon(styles[:icon], class: "w-4 h-4 align-text-bottom inline") %><%= trend.percent %>%)</span>
|
||||
<span class="text-gray-500"><%= period_label(period) %></span>
|
||||
</p>
|
||||
<% end %>
|
||||
</div>
|
||||
Reference in New Issue
Block a user