Class: IronAdmin::Filters::BarComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- IronAdmin::Filters::BarComponent
- Defined in:
- app/components/iron_admin/filters/bar_component.rb
Overview
Renders the filter bar containing search and filter controls.
Instance Attribute Summary collapse
-
#active_count ⇒ Integer
readonly
Number of active filters.
-
#form_url ⇒ String
readonly
Form submission URL.
-
#query ⇒ String?
readonly
Current search query.
-
#scope ⇒ String?
readonly
Current scope.
Instance Method Summary collapse
-
#dropdown_classes ⇒ String
private
CSS classes for filter dropdown panel.
-
#has_active_filters? ⇒ Boolean
private
Whether any filters are active.
-
#initialize(form_url:, scope: nil, query: nil, active_count: 0) ⇒ BarComponent
constructor
A new instance of BarComponent.
-
#theme ⇒ IronAdmin::Configuration::Theme
private
Theme configuration.
-
#trigger_classes ⇒ String
private
CSS classes for filter dropdown trigger button.
Constructor Details
#initialize(form_url:, scope: nil, query: nil, active_count: 0) ⇒ BarComponent
Returns a new instance of BarComponent.
26 27 28 29 30 31 |
# File 'app/components/iron_admin/filters/bar_component.rb', line 26 def initialize(form_url:, scope: nil, query: nil, active_count: 0) @form_url = form_url @scope = scope @query = query @active_count = active_count end |
Instance Attribute Details
#active_count ⇒ Integer (readonly)
Returns Number of active filters.
20 21 22 |
# File 'app/components/iron_admin/filters/bar_component.rb', line 20 def active_count @active_count end |
#form_url ⇒ String (readonly)
Returns Form submission URL.
11 12 13 |
# File 'app/components/iron_admin/filters/bar_component.rb', line 11 def form_url @form_url end |
#query ⇒ String? (readonly)
Returns Current search query.
17 18 19 |
# File 'app/components/iron_admin/filters/bar_component.rb', line 17 def query @query end |
#scope ⇒ String? (readonly)
Returns Current scope.
14 15 16 |
# File 'app/components/iron_admin/filters/bar_component.rb', line 14 def scope @scope end |
Instance Method Details
#dropdown_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 filter dropdown panel.
55 56 57 58 |
# File 'app/components/iron_admin/filters/bar_component.rb', line 55 def dropdown_classes "absolute right-0 top-full mt-2 w-72 border z-20 #{theme.border_radius} " \ "#{theme.card_border} #{theme.card_bg} #{theme.card_shadow}-lg" end |
#has_active_filters? ⇒ Boolean
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 Whether any filters are active.
41 42 43 |
# File 'app/components/iron_admin/filters/bar_component.rb', line 41 def has_active_filters? active_count.positive? 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.
35 36 37 |
# File 'app/components/iron_admin/filters/bar_component.rb', line 35 def theme IronAdmin.configuration.theme end |
#trigger_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 filter dropdown trigger button.
47 48 49 50 51 |
# File 'app/components/iron_admin/filters/bar_component.rb', line 47 def trigger_classes "inline-flex items-center gap-2 px-4 cursor-pointer select-none text-sm font-medium " \ "#{theme.border_radius} border shadow-sm transition duration-150 " \ "#{theme.label_text} #{theme.card_border} #{theme.card_bg} py-2.5 hover:bg-gray-50" end |