Files
sure/app/components/savings/status_pill_component.rb
Guillem Arias 8a9f4b1a67 fix(savings): DS conformance pass on stepper, ring, card, status pill
- 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.
2026-05-11 11:39:13 +02:00

37 lines
872 B
Ruby

class Savings::StatusPillComponent < ApplicationComponent
VARIANTS = {
on_track: { classes: "bg-green-500/10 text-success", icon: "check-circle", icon_color: "green" },
behind: { classes: "bg-yellow-500/10 text-warning", icon: "alert-triangle", icon_color: "yellow" },
reached: { classes: "bg-green-500/10 text-success", icon: "circle-check-big", icon_color: "green" },
no_target_date: { classes: "bg-surface-inset text-secondary", icon: "calendar-off", icon_color: "default" }
}.freeze
def initialize(goal:)
@goal = goal
end
def status
@goal.status
end
def variant
VARIANTS.fetch(status, VARIANTS[:no_target_date])
end
def label
I18n.t("savings_goals.status.#{status}")
end
def icon_name
variant[:icon]
end
def icon_color
variant[:icon_color]
end
def classes
variant[:classes]
end
end