Class: PhlexKit::Pagination

Inherits:
BaseComponent show all
Defined in:
app/components/phlex_kit/pagination/pagination.rb

Overview

Page navigation. Ported from ruby_ui's RubyUI::Pagination. Compose Pagination > PaginationContent > PaginationItem(href:, active:) / PaginationEllipsis.

Instance Method Summary collapse

Methods inherited from BaseComponent

#on

Constructor Details

#initialize(label: "pagination", **attrs) ⇒ Pagination

label: is a named kwarg (not a mix default) because mix would fuse a caller aria-label with the hardcoded "pagination" ("pagination Résultats").



7
8
9
10
# File 'app/components/phlex_kit/pagination/pagination.rb', line 7

def initialize(label: "pagination", **attrs)
  @label = label
  @attrs = attrs
end

Instance Method Details

#view_templateObject



12
13
14
15
16
# File 'app/components/phlex_kit/pagination/pagination.rb', line 12

def view_template(&)
  base = { class: "pk-pagination", role: "navigation" }
  base[:aria] = { label: @label } unless aria_labelled?
  nav(**mix(base, @attrs), &)
end