Class: Forms::Search

Inherits:
Components::Base
  • Object
show all
Includes:
Phlex::Rails::Helpers::FormWith
Defined in:
app/components/databasium/forms/search.rb

Instance Method Summary collapse

Constructor Details

#initialize(url:, turbo_frame:, placeholder:) ⇒ Search

Returns a new instance of Search.



8
9
10
11
12
# File 'app/components/databasium/forms/search.rb', line 8

def initialize(url:, turbo_frame:, placeholder:)
  @url = url
  @turbo_frame = turbo_frame
  @placeholder = placeholder
end

Instance Method Details

#view_templateObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'app/components/databasium/forms/search.rb', line 14

def view_template
  div(data: { controller: "search" }) do
    form_with url: @url,
              method: :get,
              data: {
                turbo_frame: @turbo_frame,
                action: "input->search#update"
              } do |form|
      raw form.search_field :search,
                            class:
                              "border-2 border-border bg-background rounded-md p-2 w-full",
                            placeholder: @placeholder
    end
  end
end