Class: Uchi::Ui::SearchInput

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/uchi/ui/search_input.rb

Overview

Renders a labelled search input with a submit button, for use inside a form_tag. This is the shared building block behind both the global search form and each repository's index page search form.

Based on Flowbite's Simple search input (https://flowbite.com/docs/forms/search-input/#simple-search-input)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(autofocus: false, label: nil, query: nil) ⇒ SearchInput

Returns a new instance of SearchInput.



14
15
16
17
18
19
# File 'app/components/uchi/ui/search_input.rb', line 14

def initialize(autofocus: false, label: nil, query: nil)
  super()
  @autofocus = autofocus
  @label = label || Uchi::I18n.translate("search.label", default: "Search")
  @query = query
end

Instance Attribute Details

#autofocus ⇒ Object (readonly)

Returns the value of attribute autofocus.



12
13
14
# File 'app/components/uchi/ui/search_input.rb', line 12

def autofocus
  @autofocus
end

#label ⇒ Object (readonly)

Returns the value of attribute label.



12
13
14
# File 'app/components/uchi/ui/search_input.rb', line 12

def label
  @label
end

#query ⇒ Object (readonly)

Returns the value of attribute query.



12
13
14
# File 'app/components/uchi/ui/search_input.rb', line 12

def query
  @query
end