The personal finance app for everyone (by everyone)
Ruby
<%# locals: (account:, size: "md", color: nil, url: account.logo_url, reconciliation_indicator: nil) %>
<% size_classes = {
"sm" => "w-6 h-6",
"md" => "w-9 h-9",
"lg" => "w-10 h-10",
"full" => "w-full h-full"
} %>
<% initials = {
variant: :text,
hex_color: color || account.accountable&.color,
text: account.name.to_s,
size: size,
rounded: true
} %>
<%# A sidebar logo sits in a wrapper Turbo carries across visits. A failed
same-origin image is fetched once more at a fresh URL, then drops that
permanence before it removes itself (see image_fallback_controller.js). %>
<% fallback = ProviderLogo::REMOVE_ON_ERROR.merge(image_fallback_retry_value: true, image_fallback_release_permanent_value: true) %>
<div class="relative shrink-0">
<% if url.present? %>
<%# The ProviderLogo recipe: the initials sit under the image, and a logo the
browser cannot show (an upload whose file is gone, a dead favicon or
Brandfetch URL) removes itself to reveal them. %>
<%= tag.span class: "relative block shrink-0 #{size_classes[size]}" do %>
<%= render DS::FilledIcon.new(**initials, class_name: "absolute inset-0 w-full! h-full!") %>
<%= image_tag url,
class: "absolute inset-0 w-full h-full rounded-full object-contain bg-container",
alt: "",
loading: "lazy",
data: fallback %>
<% end %>
<% else %>
<%= render DS::FilledIcon.new(**initials) %>
<% end %>
<% if reconciliation_indicator.present? %>
<%#
Status only, never an action — the account itself offers no
reconciliation control, so the tooltip explains the colour on hover and
is exposed to AT via aria-describedby.
The corner offset lives on the tooltip wrapper (`html_class:`), not on
the dot. The wrapper is inline-level, so in flow it opens a line box
inside the logo's `relative` container and grows that container — which
pushed the `absolute` dot clear of the corner. Out of flow, the wrapper
sizes to the dot and anchors to the container as intended.
The dot carries `data-row-click-ignore` so a click on it doesn't open the
account row (ClickableRowController#open).
%>
<% matched = reconciliation_indicator == :matched %>
<% if matched %>
<%= render DS::Tooltip.new(
text: t("accounts.reconciliation_indicator.matched"),
as: :span,
html_class: "absolute -bottom-0.5 -right-0.5",
trigger_content: tag.span(
icon("check", class: "w-2 h-2 text-inverse"),
class: "flex h-3 w-3 items-center justify-center rounded-full border border-container bg-success",
data: { row_click_ignore: true }
)
) %>
<% else %>
<%= render DS::Tooltip.new(
text: t("accounts.reconciliation_indicator.needs_attention"),
as: :span,
html_class: "absolute -bottom-0.5 -right-0.5",
trigger_content: tag.span(
class: "h-2.5 w-2.5 rounded-full border border-container bg-warning",
data: { row_click_ignore: true }
)
) %>
<% end %>
<% end %>
</div>