mirror of
https://github.com/we-promise/sure.git
synced 2026-05-30 15:59:02 +00:00
- StatusPill: use functional `text-success` / `text-warning` tokens with matching icon colors and `px-2 py-1`, mirroring `app/views/budget_categories/_budget_category.html.erb:29-43`. - ProgressRing: rework center text to match `_budget_donut.html.erb` (small "Saved" label, `text-3xl font-medium` headline, "of $X" underline). Stroke color now derives from goal.status (yellow when behind, blue on track, green reached, gray for no-date). - GoalCard bar: track height + transition match budget category bar (`h-1.5`, `transition-all duration-500`, `inline-size`). - Index/show layouts: render page header inline (`<h1>` + actions). The default application layout doesn't yield `:page_actions`, so the CTA + kebab menu wouldn't appear when emitted via `content_for`. - Stepper review summary: target the actual form inputs by `name` rather than relying on the `data-target` Stimulus attribute, since `money_field` puts the attribute on the wrapper. Step 1 validation scoped to the step 1 panel. - Demo generator: filter Depository accounts via `where(accountable_type: "Depository")` — Rails delegated_type generates the `depository?` predicate, not a `.depository` scope.
38 lines
730 B
Ruby
38 lines
730 B
Ruby
class Savings::ProgressRingComponent < ApplicationComponent
|
|
SIZE = 220
|
|
STROKE = 14
|
|
RADIUS = (SIZE - STROKE) / 2.0
|
|
CIRCUMFERENCE = 2 * Math::PI * RADIUS
|
|
|
|
def initialize(goal:)
|
|
@goal = goal
|
|
end
|
|
|
|
attr_reader :goal
|
|
|
|
def percent
|
|
[ [ goal.progress_percent.to_i, 0 ].max, 100 ].min
|
|
end
|
|
|
|
def offset
|
|
CIRCUMFERENCE * (1 - percent / 100.0)
|
|
end
|
|
|
|
def stroke_color
|
|
case goal.status
|
|
when :reached then "var(--color-green-500)"
|
|
when :behind then "var(--color-yellow-500)"
|
|
when :on_track then "var(--color-blue-500)"
|
|
else "var(--color-gray-400)"
|
|
end
|
|
end
|
|
|
|
def current_label
|
|
goal.current_balance_money.format
|
|
end
|
|
|
|
def target_label
|
|
goal.target_amount_money.format
|
|
end
|
|
end
|