Class: Playbook::Pagination::Rails

Inherits:
WillPaginate::ActionView::LinkRenderer
  • Object
show all
Defined in:
lib/playbook/pagination_renderer.rb

Instance Method Summary collapse

Instance Method Details

#container_attributesObject



8
9
10
# File 'lib/playbook/pagination_renderer.rb', line 8

def container_attributes
  { class: "pb_pagination" }
end

#gapObject



28
# File 'lib/playbook/pagination_renderer.rb', line 28

def gap; end

#next_pageObject



39
40
41
42
43
44
45
46
# File 'lib/playbook/pagination_renderer.rb', line 39

def next_page
  num = @collection.current_page < @collection.total_pages && @collection.current_page + 1
  previous_or_next_page(
    num,
    "<i> pb_rails('icon', props: { icon: 'chevron-right', fixed_width: true, size: 'xs' }) </i>",
    "next"
  )
end

#page_number(page) ⇒ Object



12
13
14
15
16
17
18
# File 'lib/playbook/pagination_renderer.rb', line 12

def page_number(page)
  if page == current_page
    tag("li", tag("span", page), class: "active")
  else
    tag("li", link(page, page, rel: rel_value(page)))
  end
end

#previous_or_next_page(page, text, classname) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/playbook/pagination_renderer.rb', line 20

def previous_or_next_page(page, text, classname)
  if page
    tag("li", link(text, page), class: classname)
  else
    tag("li", tag("span", text), class: "%s disabled")
  end
end

#previous_pageObject



30
31
32
33
34
35
36
37
# File 'lib/playbook/pagination_renderer.rb', line 30

def previous_page
  num = @collection.current_page > 1 && @collection.current_page - 1
  previous_or_next_page(
    num,
    "<i> pb_rails('icon', props: { icon: 'chevron-left', fixed_width: true, size: 'xs' }) </i>",
    "prev"
  )
end