Class: IronAdmin::Filters::SelectFilterComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- IronAdmin::Filters::SelectFilterComponent
- Defined in:
- app/components/iron_admin/filters/select_filter_component.rb
Overview
Renders a select dropdown filter.
Instance Attribute Summary collapse
-
#label ⇒ String
readonly
Filter label.
-
#name ⇒ Symbol
readonly
Filter name.
-
#options ⇒ Array
readonly
Available options.
-
#selected ⇒ String?
readonly
Currently selected value.
Instance Method Summary collapse
-
#chevron_style ⇒ String
private
Inline CSS style for dropdown chevron.
-
#field_name ⇒ String
private
Form field name.
-
#initialize(name:, options:, label: nil, selected: nil) ⇒ SelectFilterComponent
constructor
A new instance of SelectFilterComponent.
-
#label_classes ⇒ String
private
CSS classes for label elements.
-
#select_classes ⇒ String
private
CSS classes for select element.
-
#theme ⇒ IronAdmin::Configuration::Theme
private
Theme configuration.
Constructor Details
#initialize(name:, options:, label: nil, selected: nil) ⇒ SelectFilterComponent
Returns a new instance of SelectFilterComponent.
23 24 25 26 27 28 |
# File 'app/components/iron_admin/filters/select_filter_component.rb', line 23 def initialize(name:, options:, label: nil, selected: nil) @name = name @label = label || name.to_s.humanize @options = @selected = selected end |
Instance Attribute Details
#label ⇒ String (readonly)
Returns Filter label.
11 12 13 |
# File 'app/components/iron_admin/filters/select_filter_component.rb', line 11 def label @label end |
#name ⇒ Symbol (readonly)
Returns Filter name.
8 9 10 |
# File 'app/components/iron_admin/filters/select_filter_component.rb', line 8 def name @name end |
#options ⇒ Array (readonly)
Returns Available options.
14 15 16 |
# File 'app/components/iron_admin/filters/select_filter_component.rb', line 14 def @options end |
#selected ⇒ String? (readonly)
Returns Currently selected value.
17 18 19 |
# File 'app/components/iron_admin/filters/select_filter_component.rb', line 17 def selected @selected end |
Instance Method Details
#chevron_style ⇒ String
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 Inline CSS style for dropdown chevron.
58 59 60 61 62 63 |
# File 'app/components/iron_admin/filters/select_filter_component.rb', line 58 def chevron_style "background-image: url(\"data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' " \ "viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' " \ "stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e\"); background-position: right 0.5rem center; " \ "background-repeat: no-repeat; background-size: 1.5em 1.5em; padding-right: 2.5rem;" end |
#field_name ⇒ String
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 Form field name.
38 39 40 |
# File 'app/components/iron_admin/filters/select_filter_component.rb', line 38 def field_name "filters[#{name}]" end |
#label_classes ⇒ String
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 label elements.
44 45 46 |
# File 'app/components/iron_admin/filters/select_filter_component.rb', line 44 def label_classes "block text-xs font-semibold uppercase tracking-wider #{theme.muted_text}" end |
#select_classes ⇒ String
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 select element.
50 51 52 53 54 |
# File 'app/components/iron_admin/filters/select_filter_component.rb', line 50 def select_classes "block w-full appearance-none border px-3 py-2 text-sm shadow-sm outline-none " \ "transition duration-150 ease-in-out #{theme.border_radius} #{theme.input_border} " \ "#{theme.card_bg} #{theme.body_text} #{theme.input_focus}" end |
#theme ⇒ IronAdmin::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.
32 33 34 |
# File 'app/components/iron_admin/filters/select_filter_component.rb', line 32 def theme IronAdmin.configuration.theme end |