The personal finance app for everyone (by everyone)
Ruby
<%= tag.div data: { controller: "DS--popover", DS__popover_placement_value: placement, DS__popover_offset_value: offset, DS__popover_mobile_fullwidth_value: mobile_fullwidth, DS__popover_frame_id_value: frame_id, DS__popover_frame_src_value: frame_src, testid: testid } do %>
<% if variant == :icon %>
<%= render DS::Button.new(variant: "icon", icon: icon, aria_label: trigger_aria_label, aria: { haspopup: "dialog", expanded: "false", controls: panel_id }, data: { DS__popover_target: "button" }) %>
<% elsif variant == :button %>
<%= button %>
<% elsif variant == :avatar %>
<%# Avatar trigger needs an explicit accessible name — the inner
avatar image is decorative. Caller must pass `aria_label:` or
the fallback `ds.popover.avatar_default_label` is used. %>
<button type="button"
data-DS--popover-target="button"
class="inline-flex items-center justify-center w-9 h-9 pointer-coarse:w-11 pointer-coarse:h-11 cursor-pointer rounded-full focus-ring"
aria-label="<%= trigger_aria_label %>"
aria-haspopup="dialog"
aria-expanded="false"
aria-controls="<%= panel_id %>">
<div class="w-9 h-9">
<%= render "settings/user_avatar", avatar_url: avatar_url, initials: initials %>
</div>
</button>
<% end %>
<div id="<%= panel_id %>" data-DS--popover-target="content" class="fixed px-2 lg:px-0 max-w-full hidden z-50">
<%= tag.div class: "mx-auto min-w-[200px] shadow-border-lg bg-container rounded-lg", style: ("max-width: #{max_width}" if max_width) do %>
<%= header %>
<%= tag.div class: class_names("py-1" => !no_padding) do %>
<% if lazy_frame? %>
<%# Filled with the <turbo-frame> by the controller on first open. %>
<%= tag.div data: { DS__popover_target: "frame" } %>
<% else %>
<%= custom_content %>
<% end %>
<% end %>
<% end %>
</div>
<% end %>