Class: Maquina::Application::Search

Inherits:
Phlex::HTML
  • Object
show all
Includes:
Maquina::ApplicationView, Phlex::Rails::Helpers::FormWith
Defined in:
app/views/maquina/application/search.rb

Instance Method Summary collapse

Methods included from Maquina::ApplicationView

#attribute_human_name, #button_to, #image_tag, #link_to, #model_human_name, #svg_icon

Instance Method Details

#view_templateObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/views/maquina/application/search.rb', line 11

def view_template
  current_params = request.params.except(:q, :page, :controller, :action)
  current_params.reject! { |key, value| value.blank? }
  query = params[:q]

  form_with(url: @url, method: :get, data: {controller: "submit-form"}, class: "pr-3") do |form|
    current_params.each do |key, value|
      form.hidden_field key, value: value
    end
    form.label :search, t("search.search"), class: "sr-only"

    div class: "relative" do
      div class: "absolute inset-y-0 left-0 pl-3 flex items-center pointer-events-none" do
        unsafe_raw search_icon
      end
      form.text_field :q, value: query, placeholder: t("search.search"), class: "block w-full font-sans", maxlength: 15, type: :search, data: {action: "input->submit-form#clear"}
    end
  end
end