Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby
1.9 KB
Raw Blame
<%# locals: (title:, subtitle: nil, content:, collapsible: false, open: true, auto_open_param: nil, status: nil, meta: nil, actions: nil, badge: nil) %>
<% if collapsible %>
  <%= render DS::Disclosure.new(
    variant: :card,
    open: open,
    data: auto_open_param.present? ? { controller: "auto-open", auto_open_param_value: auto_open_param } : nil
  ) do |disclosure| %>
    <% disclosure.with_summary_content do %>
      <div class="flex items-center justify-between gap-2 w-full">
        <div class="flex items-center gap-2">
          <%= icon "chevron-right", class: "text-secondary group-open:rotate-90 motion-safe:transition-transform motion-safe:duration-150" %>
          <div>
            <div class="flex items-center gap-2 flex-wrap">
              <h2 class="text-lg font-medium text-primary"><%= title %></h2>
              <%= badge if badge.present? %>
            </div>
            <% if subtitle.present? %>
              <p class="text-secondary text-sm"><%= subtitle %></p>
            <% end %>
          </div>
        </div>
        <% if status.present? %>
          <div class="flex items-center gap-2 shrink-0 group-open:hidden">
            <% if meta.present? %>
              <span class="text-xs text-subdued"><%= meta %></span>
            <% end %>
            <%= status %>
            <%= actions if actions.present? %>
          </div>
        <% end %>
      </div>
    <% end %>
    <div class="space-y-4 mt-4">
      <%= content %>
    </div>
  <% end %>
<% else %>
  <section class="bg-container shadow-border-xs rounded-xl p-4 space-y-4">
    <% if title.present? %>
      <div>
        <h2 class="text-lg font-medium text-primary"><%= title %></h2>
        <% if subtitle.present? %>
          <p class="text-secondary text-sm mt-1"><%= subtitle %></p>
        <% end %>
      </div>
    <% end %>
    <div class="space-y-4">
      <%= content %>
    </div>
  </section>
<% end %>