Class: IronAdmin::Filters::SearchComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/iron_admin/filters/search_component.rb

Overview

Renders the search input in the filter bar.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(form_url:, value: nil, placeholder: "Search...", hidden_params: {}) ⇒ SearchComponent

Returns a new instance of SearchComponent.

Parameters:

  • form_url (String)

    Form submission URL

  • value (String, nil) (defaults to: nil)

    Current value

  • placeholder (String) (defaults to: "Search...")

    Placeholder text

  • hidden_params (Hash) (defaults to: {})

    Hidden params



23
24
25
26
27
28
# File 'app/components/iron_admin/filters/search_component.rb', line 23

def initialize(form_url:, value: nil, placeholder: "Search...", hidden_params: {})
  @value = value
  @placeholder = placeholder
  @form_url = form_url
  @hidden_params = hidden_params
end

Instance Attribute Details

#form_urlString (readonly)

Returns Form submission URL.

Returns:

  • (String)

    Form submission URL



14
15
16
# File 'app/components/iron_admin/filters/search_component.rb', line 14

def form_url
  @form_url
end

#hidden_paramsHash (readonly)

Returns Hidden params to preserve.

Returns:

  • (Hash)

    Hidden params to preserve



17
18
19
# File 'app/components/iron_admin/filters/search_component.rb', line 17

def hidden_params
  @hidden_params
end

#placeholderString (readonly)

Returns Placeholder text.

Returns:

  • (String)

    Placeholder text



11
12
13
# File 'app/components/iron_admin/filters/search_component.rb', line 11

def placeholder
  @placeholder
end

#valueString? (readonly)

Returns Current search value.

Returns:

  • (String, nil)

    Current search value



8
9
10
# File 'app/components/iron_admin/filters/search_component.rb', line 8

def value
  @value
end

Instance Method Details

#input_classesString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns CSS classes for search input field.

Returns:

  • (String)

    CSS classes for search input field



38
39
40
41
42
# File 'app/components/iron_admin/filters/search_component.rb', line 38

def input_classes
  "block w-full border py-2 pl-10 pr-4 text-sm shadow-sm outline-none " \
    "transition duration-150 ease-in-out #{theme.border_radius} #{theme.input_border} " \
    "#{theme.navbar_search_bg} #{theme.body_text} #{theme.input_focus} #{theme.navbar_search_focus_bg}"
end

#themeIronAdmin::Configuration::Theme

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns Theme configuration.

Returns:



32
33
34
# File 'app/components/iron_admin/filters/search_component.rb', line 32

def theme
  IronAdmin.configuration.theme
end