mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-08-05 13:35:21 +02:00
Improve dashboard/account charts and tooltips (#2157)
* Improve net worth hover * Improve graph tooltip * Use locales files for some text on net worth and account charts * Consolidate and simplify trend change between net worth and account charts * Fix test and self-review stuff * Clean up some stuff on the holding sidebar
This commit is contained in:
parent
e6b69c1f5c
commit
341a800b65
10 changed files with 37 additions and 45 deletions
|
@ -3,16 +3,7 @@
|
|||
|
||||
<%= turbo_frame_tag dom_id(@account, :chart_details) do %>
|
||||
<div class="px-4">
|
||||
<% if trend.direction.flat? %>
|
||||
<%= tag.span t(".no_change"), class: "text-secondary" %>
|
||||
<% else %>
|
||||
<%= tag.span "#{trend.value.positive? ? "+" : ""}#{format_money(trend.value)}", style: "color: #{trend.color}" %>
|
||||
<% unless trend.percent.infinite? %>
|
||||
<%= tag.span "(#{trend.percent}%)", style: "color: #{trend.color}" %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<%= tag.span @period.comparison_label, class: "text-secondary" %>
|
||||
<%= render partial: "shared/trend_change", locals: { trend: trend, comparison_label: @period.comparison_label } %>
|
||||
</div>
|
||||
|
||||
<div class="h-64 pb-4">
|
||||
|
@ -24,7 +15,7 @@
|
|||
data-time-series-chart-data-value="<%= series.to_json %>"></div>
|
||||
<% else %>
|
||||
<div class="w-full h-full flex items-center justify-center">
|
||||
<p class="text-secondary text-sm">No data available for the selected period.</p>
|
||||
<p class="text-secondary text-sm"><%= t(".data_not_available") %></p>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<div class="grid grid-cols-12 items-center uppercase text-xs font-medium text-secondary px-4 py-2">
|
||||
<%= tag.p t(".name"), class: "col-span-4" %>
|
||||
<%= tag.p t(".weight"), class: "col-span-2 justify-self-end" %>
|
||||
<%= tag.p t(".cost"), class: "col-span-2 justify-self-end" %>
|
||||
<%= tag.p t(".average_cost"), class: "col-span-2 justify-self-end" %>
|
||||
<%= tag.p t(".holdings"), class: "col-span-2 justify-self-end" %>
|
||||
<%= tag.p t(".return"), class: "col-span-2 justify-self-end" %>
|
||||
</div>
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
</div>
|
||||
|
||||
<div class="flex items-center justify-between text-sm">
|
||||
<dt class="text-secondary"><%= t(".trend_label") %></dt>
|
||||
<dt class="text-secondary"><%= t(".total_return_label") %></dt>
|
||||
<dd style="color: <%= @holding.trend&.color %>;">
|
||||
<%= @holding.trend ? render("shared/trend_change", trend: @holding.trend) : t(".unknown") %>
|
||||
</dd>
|
||||
|
|
|
@ -3,19 +3,14 @@
|
|||
<div class="flex justify-between gap-4 px-4">
|
||||
<div class="space-y-2">
|
||||
<div class="space-y-2">
|
||||
<p class="text-sm text-secondary font-medium">Net Worth</p>
|
||||
<p class="text-sm text-secondary font-medium"><%= t(".title") %></p>
|
||||
<p class="text-primary -space-x-0.5 text-3xl font-medium">
|
||||
<%= series.current.format %>
|
||||
</p>
|
||||
<% if series.trend.nil? %>
|
||||
<p class="text-sm text-secondary">Data not available for the selected period</p>
|
||||
<% elsif series.trend.direction.flat? %>
|
||||
<p class="text-sm text-secondary">No change vs. prior period</p>
|
||||
<p class="text-sm text-secondary"><%= t(".data_not_available") %></p>
|
||||
<% else %>
|
||||
<div class="flex items-center gap-2">
|
||||
<%= render partial: "shared/trend_change", locals: { trend: series.trend } %>
|
||||
<span class="text-sm text-secondary"><%= period.comparison_label %></span>
|
||||
</div>
|
||||
<%= render partial: "shared/trend_change", locals: { trend: series.trend, comparison_label: period.comparison_label } %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -32,6 +27,6 @@
|
|||
data-time-series-chart-data-value="<%= series.to_json %>"></div>
|
||||
<% else %>
|
||||
<div class="w-full h-full flex items-center justify-center">
|
||||
<p class="text-secondary text-sm">No data available for the selected period.</p>
|
||||
<p class="text-secondary text-sm"><%= t(".data_not_available") %></p>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<%# locals: { trend: } %>
|
||||
<%# locals: { trend:, comparison_label: nil } %>
|
||||
|
||||
<p class="text-sm" style="color: <%= trend.color %>">
|
||||
<% if trend.direction.flat? %>
|
||||
<span>No change</span>
|
||||
<%= t(".no_change") %><%= " #{comparison_label}" if defined?(comparison_label) && comparison_label.present? %>
|
||||
<% else %>
|
||||
<span class="font-mono">
|
||||
<%= trend.value.is_a?(Money) ? format_money(trend.value) : trend.value.round(2) %>
|
||||
|
@ -10,5 +10,8 @@
|
|||
<% unless trend.percent.infinite? %>
|
||||
<span class="font-mono">(<%= lucide_icon(trend.icon, class: "w-4 h-4 align-text-bottom inline") %><%= trend.percent_formatted %>)</span>
|
||||
<% end %>
|
||||
<span class="text-secondary">
|
||||
<%= " #{comparison_label}" if defined?(comparison_label) && comparison_label.present? %>
|
||||
</span>
|
||||
<% end %>
|
||||
</p>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue