From f182da79c8f583dfd1c4f0362c79af13055ee150 Mon Sep 17 00:00:00 2001 From: Guillem Arias Date: Thu, 14 May 2026 22:30:26 +0200 Subject: [PATCH] fix(goals): unified per-goal account color map + smaller pen toggle MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit User flagged two regressions: account colors didn't match between the goal preview-card avatar stack on the index and the funding-widget rows on the show page, and the color-picker pen toggle on the new-goal modal still felt too big. Color matching: - `AccountStackComponent` (index card) used `Goals::AvatarComponent.color_for(account.name)` — MD5-of-name into the 10-color palette. - `FundingAccountsBreakdownComponent` (show page) recently switched to `color_for(account.id.to_s)` — MD5-of-id. - Same account, two surfaces, two different palette picks. Plus either hashing scheme can collide within a multi-account goal (palette has 10 colors). Move ownership to the Goal model: `Goal#account_color_map` returns `{ account_id => palette_hex }` for the goal's linked accounts. Sort by `id` for a stable order across reloads, then assign `palette[i % palette.size]`. Stable + collision-free up to 10 accounts in a single goal (a realistic upper bound — most goals link 1-3). Both consumers now read off the same source: - `AccountStackComponent.new(accounts:, color_map:)` accepts a hash and falls back to the name-hash if no map provided (kept for callers that don't have a goal in scope yet). - `FundingAccountsBreakdownComponent#color_for` reads `goal.account_color_map[account.id]`. - Goal card on index passes `goal.account_color_map` to the stack. Pen toggle: The new-goal color-picker pen sat in a `w-5 h-5` circle with a `border` ring + `text-secondary` icon. The border + secondary text weight kept it loud against the avatar even at 20px. Drop the border, drop the size another step (`w-4 h-4`), recolor the icon `text-subdued` + `hover:text-secondary` so the affordance recedes when not interacted with. Position shifts from `-bottom-1 -right-1` (8px overhang) to `-bottom-0.5 -right-0.5` (2px overhang) since the smaller circle doesn't need the larger float. Icon swaps "pen" for "pencil" (the more conventional edit indicator across Sure). --- .../goals/account_stack_component.html.erb | 2 +- app/components/goals/account_stack_component.rb | 11 ++++++++++- app/components/goals/card_component.html.erb | 2 +- .../goals/funding_accounts_breakdown_component.rb | 8 ++++---- app/models/goal.rb | 15 +++++++++++++++ app/views/goals/_color_picker.html.erb | 4 ++-- 6 files changed, 33 insertions(+), 9 deletions(-) diff --git a/app/components/goals/account_stack_component.html.erb b/app/components/goals/account_stack_component.html.erb index c8fa6be8c..99ea5936e 100644 --- a/app/components/goals/account_stack_component.html.erb +++ b/app/components/goals/account_stack_component.html.erb @@ -1,7 +1,7 @@