Class: Maquina::Navbar::Search

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

Instance Method Summary collapse

Methods included from ApplicationView

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

Constructor Details

#initialize(url: nil, query: "") ⇒ Search

Returns a new instance of Search.



11
12
13
14
# File 'app/views/maquina/navbar/search.rb', line 11

def initialize(url: nil, query: "")
  @url = url
  @query = query
end

Instance Method Details

#view_templateObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/views/maquina/navbar/search.rb', line 16

def view_template
  div class: "flex-1 flex items-center justify-center px-2 lg:ml-6 lg:justify-end" do
    div class: "max-w-lg w-full lg:max-w-xs" do
      form_with(url: @url, method: :get, data: {controller: "submit-form"}) do |form|
        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
            svg_icon(:fill, view_box: "0 0 20 20", css_class: "h-5 w-5 text-skin-dimmed", icon: 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
  end
end