mirror of
https://github.com/we-promise/sure.git
synced 2026-05-12 15:15:01 +00:00
feat(accounts): add activity entry highlighting in summary cards
* Introduced a new helper method `highlight_activity_entry_name` to highlight search terms in activity entry names. * Updated various views to utilize the new highlighting method for improved user experience in displaying relevant entries.
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
module AccountsHelper
|
||||
ACTIVITY_HIGHLIGHT_MARKUP = '<span class="text-warning/80 font-medium underline decoration-warning/60 underline-offset-2">\1</span>'.freeze
|
||||
|
||||
def summary_card(title:, &block)
|
||||
content = capture(&block)
|
||||
render "accounts/summary_card", title: title, content: content
|
||||
@@ -8,4 +10,11 @@ module AccountsHelper
|
||||
# Always use the account sync path, which handles syncing all providers
|
||||
sync_account_path(account)
|
||||
end
|
||||
|
||||
def highlight_activity_entry_name(name, query = params.dig(:q, :search))
|
||||
search = query.to_s.strip
|
||||
return name if search.blank?
|
||||
|
||||
highlight(name, search, highlighter: ACTIVITY_HIGHLIGHT_MARKUP)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -32,10 +32,10 @@
|
||||
</div>
|
||||
|
||||
<div class="truncate flex-shrink">
|
||||
<%= link_to entry.name,
|
||||
<%= link_to(highlight_activity_entry_name(entry.name),
|
||||
entry_path(entry),
|
||||
data: { turbo_frame: "drawer", turbo_prefetch: false },
|
||||
class: "hover:underline" %>
|
||||
class: "hover:underline") %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
|
||||
@@ -29,10 +29,10 @@
|
||||
<div class="space-y-0.5">
|
||||
<div class="flex items-center gap-1 min-w-0">
|
||||
<div class="truncate flex-shrink">
|
||||
<%= link_to entry.name,
|
||||
<%= link_to(highlight_activity_entry_name(entry.name),
|
||||
entry_path(entry),
|
||||
data: { turbo_frame: "drawer", turbo_prefetch: false },
|
||||
class: "hover:underline" %>
|
||||
class: "hover:underline") %>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center gap-1 flex-shrink-0">
|
||||
@@ -51,7 +51,7 @@
|
||||
<%= link_to entry.account.name,
|
||||
account_path(entry.account, tab: "transactions"),
|
||||
data: { turbo_frame: "_top" },
|
||||
class: "hover:underline" %>
|
||||
class: "hover:underline") %>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
<div class="truncate flex-shrink">
|
||||
<% if transaction.transfer? %>
|
||||
<%= link_to(
|
||||
entry.name,
|
||||
highlight_activity_entry_name(entry.name),
|
||||
transaction.transfer.present? ? transfer_path(transaction.transfer) : entry_path(entry),
|
||||
data: {
|
||||
turbo_frame: "drawer",
|
||||
@@ -69,7 +69,7 @@
|
||||
) %>
|
||||
<% else %>
|
||||
<%= link_to(
|
||||
entry.name,
|
||||
highlight_activity_entry_name(entry.name),
|
||||
entry_path(entry),
|
||||
data: {
|
||||
turbo_frame: "drawer",
|
||||
|
||||
@@ -17,10 +17,10 @@
|
||||
<%= render DS::FilledIcon.new(icon: icon, size: "md", hex_color: color, rounded: true) %>
|
||||
|
||||
<div class="truncate text-primary">
|
||||
<%= link_to entry.name,
|
||||
<%= link_to(highlight_activity_entry_name(entry.name),
|
||||
entry_path(entry),
|
||||
data: { turbo_frame: "drawer", turbo_prefetch: false },
|
||||
class: "hover:underline" %>
|
||||
class: "hover:underline") %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user