Class: IronAdmin::Ui::PaginationComponent

Inherits:
ViewComponent::Base
  • Object
show all
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.

Examples:

Basic pagination

render IronAdmin::Ui::PaginationComponent.new(pagy: @pagy)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pagy:) ⇒ PaginationComponent

Returns a new instance of PaginationComponent.

Parameters:

  • pagy (Pagy)

    Pagination object



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_objPagy (readonly)

Returns The Pagy pagination object.

Returns:

  • (Pagy)

    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

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.

Parameters:

  • disabled (Boolean) (defaults to: false)

    Whether nav link is disabled

Returns:

  • (String)

    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

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.

Parameters:

  • active (Boolean) (defaults to: false)

    Whether this is the current page

Returns:

  • (String)

    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.

Returns:

  • (Boolean)

    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

#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:



24
25
26
# File 'app/components/iron_admin/ui/pagination_component.rb', line 24

def theme
  IronAdmin.configuration.theme
end