1
0
Fork 0
mirror of https://github.com/maybe-finance/maybe.git synced 2025-07-24 07:39:39 +02: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:
Zach Gollwitzer 2024-03-01 17:33:54 -05:00 committed by GitHub
parent 0fe9b6d34a
commit 19f15e9391
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 41 additions and 26 deletions

View file

@ -49,13 +49,12 @@ module ApplicationHelper
end
# Styles to use when displaying a change in value
def trend_styles(trend, mode: :asset)
puts mode == :liability ? "it is a liability" : "it is an asset"
def trend_styles(trend)
bg_class, text_class, symbol, icon = case trend.direction
when "up"
mode == :liability ? [ "bg-red-500/5", "text-red-500", "+", "arrow-up" ] : [ "bg-green-500/5", "text-green-500", "+", "arrow-up" ]
trend.type == :liability ? [ "bg-red-500/5", "text-red-500", "+", "arrow-up" ] : [ "bg-green-500/5", "text-green-500", "+", "arrow-up" ]
when "down"
mode == :liability ? [ "bg-green-500/5", "text-green-500", "-", "arrow-down" ] : [ "bg-red-500/5", "text-red-500", "-", "arrow-down" ]
trend.type == :liability ? [ "bg-green-500/5", "text-green-500", "-", "arrow-down" ] : [ "bg-red-500/5", "text-red-500", "-", "arrow-down" ]
when "flat"
[ "bg-gray-500/5", "text-gray-500", "", "minus" ]
else
@ -65,7 +64,7 @@ module ApplicationHelper
{ bg_class: bg_class, text_class: text_class, symbol: symbol, icon: icon }
end
def trend_label(period)
def period_label(period)
return "since account creation" if period.date_range.nil?
start_date, end_date = period.date_range.first, period.date_range.last