Class: IronAdmin::Ui::PaginationComponent
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- IronAdmin::Ui::PaginationComponent
- Includes:
- Pagy::Linkable
- Defined in:
- app/components/iron_admin/ui/pagination_component.rb
Overview
Renders pagination controls for record lists.
Uses Pagy for pagination logic.
Instance Attribute Summary collapse
-
#pagy_obj ⇒ Pagy
readonly
The Pagy pagination object.
Instance Method Summary collapse
-
#initialize(pagy:) ⇒ PaginationComponent
constructor
A new instance of PaginationComponent.
-
#nav_link_classes(disabled: false) ⇒ String
private
CSS classes for prev/next navigation links.
-
#page_link_classes(active: false) ⇒ String
private
CSS classes for page number links.
-
#render? ⇒ Boolean
private
Whether to render pagination.
-
#theme ⇒ IronAdmin::Configuration::Theme
private
Theme configuration.
Constructor Details
#initialize(pagy:) ⇒ PaginationComponent
Returns a new instance of PaginationComponent.
18 19 20 |
# File 'app/components/iron_admin/ui/pagination_component.rb', line 18 def initialize(pagy:) @pagy_obj = pagy end |
Instance Attribute Details
#pagy_obj ⇒ Pagy (readonly)
Returns The Pagy pagination object.
15 16 17 |
# File 'app/components/iron_admin/ui/pagination_component.rb', line 15 def pagy_obj @pagy_obj end |
Instance Method Details
#nav_link_classes(disabled: false) ⇒ 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 prev/next navigation links.
49 50 51 52 53 54 55 56 |
# File 'app/components/iron_admin/ui/pagination_component.rb', line 49 def nav_link_classes(disabled: false) base = "relative inline-flex items-center px-3 py-2 text-sm font-medium border transition-colors duration-150" if disabled "#{base} #{theme.card_bg} #{theme.card_border} text-gray-300 cursor-not-allowed" else "#{base} #{theme.card_bg} #{theme.card_border} #{theme.body_text} hover:bg-gray-50" end end |
#page_link_classes(active: false) ⇒ 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 page number links.
37 38 39 40 41 42 43 44 |
# File 'app/components/iron_admin/ui/pagination_component.rb', line 37 def page_link_classes(active: false) base = "px-3 py-2 text-sm font-medium border transition-colors duration-150" if active "#{base} bg-indigo-50 border-indigo-500 text-indigo-600 z-10" else "#{base} #{theme.card_bg} #{theme.card_border} #{theme.body_text} hover:bg-gray-50" end end |
#render? ⇒ 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 to render pagination.
30 31 32 |
# File 'app/components/iron_admin/ui/pagination_component.rb', line 30 def render? pagy_obj.pages > 1 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.
24 25 26 |
# File 'app/components/iron_admin/ui/pagination_component.rb', line 24 def theme IronAdmin.configuration.theme end |