mirror of
https://github.com/we-promise/sure.git
synced 2026-05-30 07:49:01 +00:00
fix(savings_goals/show): contributions list + funding accounts breakdown use per-account deterministic color
Both used goal.color for every account avatar, so every linked account ended up the same color as the goal. Sure's convention elsewhere (accounts/_logo.html.erb) is accountable.color (type color: Depository → purple) — but savings goals only link Depository accounts, so that would still collapse to one color. Reuse the deterministic Savings::GoalAvatarComponent.color_for(name) helper from the index card stack instead. Same account always resolves to the same color across processes, and multiple accounts on the same goal read as distinct. Funding-accounts breakdown bar at the top now also colors each segment by account so the proportions are visibly typed (not a single goal- color block).
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
<div class="flex h-2 rounded-full overflow-hidden mb-4">
|
||||
<% rows.each do |row| %>
|
||||
<% next if row[:amount].to_d.zero? %>
|
||||
<div style="width: <%= percent_for(row[:amount]) %>%; background-color: <%= goal.color %>;"
|
||||
<div style="width: <%= percent_for(row[:amount]) %>%; background-color: <%= Savings::GoalAvatarComponent.color_for(row[:account].name) %>;"
|
||||
title="<%= row[:account].name %>"></div>
|
||||
<% end %>
|
||||
</div>
|
||||
@@ -12,7 +12,7 @@
|
||||
<ul class="space-y-3">
|
||||
<% rows.each do |row| %>
|
||||
<li class="flex items-center gap-3">
|
||||
<%= render Savings::GoalAvatarComponent.new(name: row[:account].name, color: goal.color, size: "sm") %>
|
||||
<%= render Savings::GoalAvatarComponent.new(name: row[:account].name, color: Savings::GoalAvatarComponent.color_for(row[:account].name), size: "sm") %>
|
||||
<div class="flex-1 min-w-0">
|
||||
<p class="text-sm font-medium text-primary truncate"><%= row[:account].name %></p>
|
||||
<p class="text-[11px] text-subdued"><%= row[:account].subtype&.titleize || row[:account].accountable_type %> · <%= t("savings_goals.show.funding_balance", amount: Money.new(row[:account].balance, row[:account].currency).format) %></p>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<li class="flex items-center gap-3 px-2 py-2 rounded-lg hover:bg-surface-hover">
|
||||
<%= render Savings::GoalAvatarComponent.new(
|
||||
name: contribution.account.name,
|
||||
color: @savings_goal.color,
|
||||
color: Savings::GoalAvatarComponent.color_for(contribution.account.name),
|
||||
size: "sm"
|
||||
) %>
|
||||
<div class="flex-1 min-w-0">
|
||||
|
||||
Reference in New Issue
Block a user