The personal finance app for everyone (by everyone)
Ruby
<%# locals: (transaction:) %>
<div id="<%= dom_id(transaction, "transfer_match") %>" class="flex flex-wrap items-center justify-end gap-1 min-w-0 max-w-full">
<% if transaction.transfer.confirmed? %>
<span title="<%= transaction.transfer.payment? ? t("transactions.transfer_match.payment_confirmed") : t("transactions.transfer_match.transfer_confirmed") %>">
<%= icon "link-2", size: "sm", class: "text-secondary" %>
</span>
<% elsif transaction.transfer.pending? %>
<%# The pill's tooltip gives the other side of the suggested match (see
Transfer::PendingMatch) and, when the viewer may see it, the pill
opens the transfer. The tooltip is the design system's rather than a
native title, so the amount in it is blurred in privacy mode. %>
<% match = pending_transfer_match(transaction) %>
<% pills = capture do %>
<%# Empty titles: the tooltip below replaces the pills' native ones. %>
<span class="hidden lg:flex items-center">
<%= render DS::Pill.new(
label: t("transactions.transfer_match.auto_matched"),
tone: :neutral,
marker: false,
show_dot: false,
title: "",
label_testid: "transfer-match-pill"
) %>
</span>
<span class="flex items-center lg:hidden">
<%= render DS::Pill.new(
label: t("transactions.transfer_match.auto_matched_short"),
tone: :neutral,
marker: false,
show_dot: false,
title: "",
label_testid: "transfer-match-pill"
) %>
</span>
<% end %>
<%= render DS::Tooltip.new(placement: "top", html_class: "min-w-0") do |tooltip| %>
<% tooltip.with_trigger do %>
<%# The focusable element itself names the tooltip as its description:
an ancestor's aria-describedby is not announced for it. %>
<% if match.links_to_transfer? %>
<%= link_to transfer_path(match.transfer),
class: "flex items-center rounded-full hover:opacity-80 focus-ring",
aria: { describedby: tooltip.tooltip_id },
data: { turbo_frame: "drawer", turbo_prefetch: false } do %>
<%= pills %>
<% end %>
<% else %>
<%# Its own tab stop, so keyboard users can open the tooltip. %>
<span class="flex items-center rounded-full focus-ring" tabindex="0" aria-describedby="<%= tooltip.tooltip_id %>"><%= pills %></span>
<% end %>
<% end %>
<% if match.counterpart_visible? %>
<%= t("transactions.transfer_match.auto_matched_tooltip_html",
amount: tag.span(format_money(match.counterpart_entry.amount_money.abs), class: "privacy-sensitive"),
account: match.counterpart_account.name,
date: l(match.counterpart_entry.date, format: :long)) %>
<% else %>
<%= t("transactions.transfer_match.auto_matched_tooltip_hidden") %>
<% end %>
<% end %>
<div class="flex items-center gap-1">
<%= render DS::Button.new(
variant: :icon, size: :sm, icon: "check",
href: transfer_path(transaction.transfer, transfer: { status: "confirmed" }),
method: :patch,
title: t("transactions.transfer_match.confirm_match"),
aria: { label: t("transactions.transfer_match.confirm_match") }
) %>
<%= render DS::Button.new(
variant: :icon, size: :sm, icon: "x",
href: transfer_path(transaction.transfer, transfer: { status: "rejected" }),
method: :patch,
title: t("transactions.transfer_match.reject_match"),
aria: { label: t("transactions.transfer_match.reject_match") }
) %>
</div>
<% end %>
</div>