Class: SearchComponent
- Defined in:
- app/components/search_component.rb
Overview
Search — search component with local/remote data.
Usage:
Search(placeholder: "Search...", name: "q")
Search(category: true, fluid: true, size: :large)
Constant Summary
Constants inherited from Component
Instance Method Summary collapse
Methods inherited from Component
default, #initialize, #render_in, slot
Constructor Details
This class inherits a constructor from Component
Instance Method Details
#to_s ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/components/search_component.rb', line 19 def to_s classes = class_names( "ui", size, aligned && "#{aligned} aligned", { "category" => category, "fluid" => fluid }, "search" ) data = { controller: "fui-search" } data[:fui_search_url_value] = url if url input_opts = { class: "prompt", type: "text", placeholder: placeholder } input_opts[:name] = name if name input_wrapper = tag.div(class: "ui icon input") { safe_join([ tag.input(**input_opts), tag.i(class: "search icon") ]) } results_el = tag.div(class: "results") tag.div(class: classes, data: data) { safe_join([ input_wrapper, results_el, @content ]) } end |