Files
sure/app/views/holdings/sync_prices.turbo_stream.erb
Guillem Arias Fauste 99844c1b90 chore(design-system): swap raw gray classes for semantic tokens in holdings/ (#1654)
* chore(design-system): swap raw gray classes for semantic tokens in holdings/

Continues the raw-color sweep on the holdings/ domain plus the related
account activity feed component. 11 occurrences across 5 files.

Token additions:

- button-bg-secondary-strong (gray-200 / gray-700) and -hover (gray-300 /
  gray-600). Holdings CTAs (Add Trade, Add Holding, Edit Cost Basis,
  Sync Prices, etc.) used a hand-rolled "secondary-strong" pattern that
  doesn't match the existing button-bg-secondary token (which is gray-50
  / gray-700, much subtler). Adding the strong variant preserves the
  intentional visual weight of these CTAs and gives future PRs a name
  to reuse.
- $version bump 1.0.0 -> 1.1.0 (additive).

Mappings:

- 8x text-primary bg-gray-200 hover:bg-gray-300 theme-dark:bg-gray-700
  theme-dark:hover:bg-gray-600 (holdings/show + sync_prices +
  cost_basis_cell)
  -> text-primary button-bg-secondary-strong hover:button-bg-secondary-strong-hover
- 1x bg-gray-50 theme-dark:bg-gray-700 hover:bg-gray-100
  theme-dark:hover:bg-gray-600 (holdings/index search button)
  -> button-bg-secondary hover:button-bg-secondary-hover
- 1x hover:bg-gray-100 theme-dark:hover:bg-gray-700 (cost_basis_cell
  hover row)
  -> hover:bg-container-inset-hover
- 1x focus-within:border-gray-900 (activity_feed search wrapper)
  -> focus-within:border-primary

Left intentionally:

- bg-gray-300 status indicator dot in show.html.erb (same pattern as
  the settings pilot; no semantic equivalent for "neutral inactive
  indicator" yet).
- bg-gray-700 in _missing_price_tooltip.html.erb (already fixed in
  PR #1626; would conflict on rebase).
- focus-within:ring-gray-100 (subtle effect that works in both modes;
  ring-color tokens are a separate concern).

* chore(design-system): bump $version to 2.1.0 for additive token additions

Per the design tokens semver contract: PR #1626 already bumped to 2.0.0
(major / breaking when fg-* utilities were removed). This PR adds
button-bg-secondary-strong + hover without removing or changing existing
tokens, so the correct bump is minor (2.0.0 → 2.1.0).

Spotted by CodeRabbit on the rebased branch.

* fix(design-system): drop dead focus-within:ring-gray-100 on activity feed search

The focus-within:ring-gray-100 class only sets --tw-ring-color, but the
parent has no ring-width utility, so it produces no visible ring — dead
code from before the focus-within:border-primary swap landed.

Same issue spotted on app/views/accounts/show/_activity.html.erb in the
finalize sweep PR; applying the equivalent fix here for the holdings
activity feed component.

---------

Signed-off-by: Guillem Arias Fauste <gariasf@proton.me>
2026-05-04 21:44:47 +02:00

57 lines
2.8 KiB
Plaintext

<% unless @provider_error %>
<%= turbo_stream.replace dom_id(@holding, :current_market_price) do %>
<dd id="<%= dom_id(@holding, :current_market_price) %>" class="text-primary">
<% begin %>
<%= @holding.security.current_price ? format_money(@holding.security.current_price) : t("holdings.show.unknown") %>
<% rescue ActiveRecord::RecordInvalid %>
<%= t("holdings.show.unknown") %>
<% rescue StandardError => e %>
<% logger.error "Error fetching current price for security #{@holding.security.id}: #{e.message}" %>
<% logger.error e.backtrace.first(5).join("\n") %>
<%= t("holdings.show.unknown") %>
<% end %>
</dd>
<% end %>
<%= turbo_stream.replace dom_id(@holding, :market_value) do %>
<div id="<%= dom_id(@holding, :market_value) %>" class="flex items-center justify-between text-sm">
<dt class="text-secondary"><%= t("holdings.show.market_value_label") %></dt>
<dd class="text-primary"><%= format_money(@holding.amount_money) %></dd>
</div>
<% end %>
<%= turbo_stream.replace dom_id(@holding, :total_return) do %>
<div id="<%= dom_id(@holding, :total_return) %>" class="flex items-center justify-between text-sm">
<dt class="text-secondary"><%= t("holdings.show.total_return_label") %></dt>
<% if @holding.trend %>
<dd style="color: <%= @holding.trend.color %>;">
<%= render("shared/trend_change", trend: @holding.trend) %>
</dd>
<% else %>
<dd class="text-secondary"><%= t("holdings.show.unknown") %></dd>
<% end %>
</div>
<% end %>
<% end %>
<%= turbo_stream.replace dom_id(@holding, :market_data_section) do %>
<div id="<%= dom_id(@holding, :market_data_section) %>" class="flex items-center justify-between gap-2 p-3 border-b border-tertiary">
<div class="text-sm space-y-1">
<h4 class="text-primary"><%= t("holdings.show.market_data_label") %></h4>
<p class="text-secondary">
<%= t("holdings.show.last_price_update") %>: <%= @last_price_updated ? l(@last_price_updated, format: :long) : t("holdings.show.never") %>
</p>
<% if @provider_error %>
<p class="text-xs text-red-500"><%= @provider_error %></p>
<% end %>
</div>
<%= button_to t("holdings.show.market_data_sync_button"),
sync_prices_holding_path(@holding),
method: :post,
class: "inline-flex items-center gap-1 px-3 py-2 rounded-lg text-sm font-medium text-primary button-bg-secondary-strong hover:button-bg-secondary-strong-hover",
data: { loading_button_target: "button" },
form: { data: {
controller: "loading-button",
action: "submit->loading-button#showLoading",
loading_button_loading_text_value: t("holdings.show.syncing")
} } %>
</div>
<% end %>