Skip to content

armgit / sure

Public Imported from GitHub
0

The personal finance app for everyone (by everyone)

Ruby
2.0 KB
Raw Blame
<%= form_with url: transactions_path,
              id: "transactions-search",
              scope: :q,
              method: :get,
              data: { controller: "auto-submit-form" } do |form| %>
  <%= hidden_field_tag :per_page, params[:per_page] %>

  <div class="flex gap-2 mb-4">
    <div class="grow">
      <div class="flex items-center px-3 py-2 gap-2 border border-secondary rounded-lg focus-within:ring-secondary focus-within:border-secondary">
        <%= icon("search") %>
        <%= form.text_field :search,
                            placeholder: t(".search_placeholder"),
                            value: @q[:search],
                            class: "form-field__input placeholder:text-sm placeholder:text-secondary",
                            "data-auto-submit-form-target": "auto" %>
      </div>
    </div>

    <%= render DS::Popover.new(variant: "button", no_padding: true) do |popover| %>
      <% popover.with_button(
        id: "transaction-filters-button",
        type: "button",
        text: t(".filter"),
        variant: "outline",
        icon: "list-filter"
      ) %>

      <% popover.with_custom_content do %>
        <%= turbo_frame_tag "transaction-filters", src: filters_transactions_path(q: @q), loading: :lazy do %>
          <div class="flex items-center justify-center h-[50vh] md:h-80 w-full md:w-[540px] p-6">
            <p class="text-sm text-secondary animate-pulse"><%= t("transactions.searches.menu.loading") %></p>
          </div>
        <% end %>
      <% end %>
    <% end %>

    <%= button_tag type: "button",
        id: "toggle-checkboxes-button",
        aria: { label: t(".toggle_selection_checkboxes") },
        class: "lg:hidden font-medium whitespace-nowrap inline-flex items-center gap-1 rounded-lg px-3 py-2 text-sm text-primary border border-secondary hover:bg-surface-hover",
        data: {
          action: "click->checkbox-toggle#toggle",
          checkbox_toggle_target: "toggleButton"
        } do %>
      <%= icon("list-todo") %>
    <% end %>
  </div>
<% end %>