mirror of
https://github.com/we-promise/sure.git
synced 2026-05-30 15:59:02 +00:00
Previous savings goals UI looked nothing like the Claude Design output
(see sure-design-context/design/savings-goals/project/goals/*.jsx) and
the hand-rolled ring did not match the segmented D3 donut used at
app/views/budgets/_budget_donut.html.erb. This rewires the surface end
to end.
Donut chart:
- SavingsGoal#to_donut_segments_json returns the same segment shape as
Budget#to_donut_segments_json: filled portion in goal color, unused
remainder as `var(--budget-unallocated-fill)`. Visual identity is now
the same: segmented arc with cornerRadius and gap, courtesy of the
shared `donut-chart` Stimulus controller and D3.
- ProgressRingComponent renders a `data-controller="donut-chart"` div
with the same default-content/inner-text pattern as `_budget_donut`.
Index page (matches GoalsIndex.jsx):
- Page header: title + "Save toward what matters." subtitle + "New goal"
primary CTA right-aligned.
- Summary strip card: total saved / target, overall bar, active goals,
on-track ratio, behind count.
- State filter rendered as DS::Tabs-style pill nav (`bg-surface-inset
p-1 rounded-lg`, white-pill active state).
- Cards rebuilt: avatar (44px, rounded-xl, white initial on goal color)
+ name + secondary line ("N days left · by date" / "No target date" /
"Completed" / "Past due"), status pill with leading dot, big
$current/$target line + percent, bar in status colour, AccountStack
(overlapping initials) + "N accounts" + "to go".
Goal detail (matches GoalDetail.jsx):
- Header: 64px avatar + h1 name + status pill + "Target $X by date ·
N days left" subline + Edit (outline) + Add contribution (primary) +
kebab (DS::Menu for AASM transitions).
- Donut-chart ring card with stats overlay.
- 4-col stat row (Avg monthly, Total contributions, Target date,
Started) with mono numerals and "Needs $X/mo" / "Above target pace"
sub-captions where relevant.
- Two-col bottom: contributions list (avatar + account · date · source
· green +$amount) and funding accounts breakdown (stacked bar +
per-account row with $ and % of saved).
New components: Savings::AccountStackComponent (overlapping account
initials with ring-2 ring-container). StatusPillComponent now uses a
leading colored dot instead of an icon. GoalAvatarComponent radii
match Claude Design (rounded-md/lg/xl/2xl) and white initial.
Locale: new keys under savings_goals.{index.subtitle, index.summary.*,
goal_card.{accounts,days_left,completed,past_due,no_target_date},
show.header.*, show.ring.{of,to_go}, show.stats.*, show.funding_balance,
show.of_saved, show.notes}.
35 lines
867 B
Ruby
35 lines
867 B
Ruby
class Savings::GoalAvatarComponent < ApplicationComponent
|
|
SIZES = {
|
|
"sm" => { box: "w-6 h-6", text: "text-[10px]", radius: "rounded-md" },
|
|
"md" => { box: "w-9 h-9", text: "text-sm", radius: "rounded-lg" },
|
|
"lg" => { box: "w-11 h-11", text: "text-base", radius: "rounded-xl" },
|
|
"xl" => { box: "w-16 h-16", text: "text-2xl", radius: "rounded-2xl" }
|
|
}.freeze
|
|
|
|
def initialize(goal: nil, name: nil, color: nil, size: "md")
|
|
@goal = goal
|
|
@name = name || goal&.name
|
|
@color = color || goal&.color || SavingsGoal::COLORS.first
|
|
@size = SIZES.key?(size) ? size : "md"
|
|
end
|
|
|
|
attr_reader :color
|
|
|
|
def initial
|
|
return "?" if @name.blank?
|
|
@name.strip.first&.upcase || "?"
|
|
end
|
|
|
|
def box_classes
|
|
SIZES[@size][:box]
|
|
end
|
|
|
|
def text_classes
|
|
SIZES[@size][:text]
|
|
end
|
|
|
|
def radius_classes
|
|
SIZES[@size][:radius]
|
|
end
|
|
end
|