Class: Playbook::Pagination::Rails
- Inherits:
-
WillPaginate::ActionView::LinkRenderer
- Object
- WillPaginate::ActionView::LinkRenderer
- Playbook::Pagination::Rails
- Defined in:
- lib/playbook/pagination_renderer.rb
Instance Method Summary collapse
- #container_attributes ⇒ Object
- #gap ⇒ Object
- #next_page ⇒ Object
- #page_number(page) ⇒ Object
- #previous_or_next_page(page, text, classname) ⇒ Object
- #previous_page ⇒ Object
Instance Method Details
#container_attributes ⇒ Object
8 9 10 |
# File 'lib/playbook/pagination_renderer.rb', line 8 def container_attributes { class: "pb_pagination" } end |
#gap ⇒ Object
28 |
# File 'lib/playbook/pagination_renderer.rb', line 28 def gap; end |
#next_page ⇒ Object
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, "<svg xmlns='http://www.w3.org/2000/svg' width='auto' height='auto' viewBox='0 0 30 24' fill='none' class='pb_custom_icon svg-inline--fa pb_icon_kit svg_fw svg_xs' id='' data='{}' aria='{:label=>"away"}' tabindex=''><path d='M21.7969 11.2031C22.2188 11.6719 22.2188 12.375 21.7969 12.7969L12.7969 21.7969C12.3281 22.2656 11.625 22.2656 11.2031 21.7969C10.7344 21.375 10.7344 20.6719 11.2031 20.25L19.4062 12.0469L11.2031 3.79688C10.7344 3.375 10.7344 2.67188 11.2031 2.25C11.625 1.78125 12.3281 1.78125 12.75 2.25L21.7969 11.2031Z' fill='currentColor'></path></svg>", "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_page ⇒ Object
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, "<svg xmlns='http://www.w3.org/2000/svg' width='auto' height='auto' viewBox='0 0 30 24' fill='none' class='pb_custom_icon svg-inline--fa pb_icon_kit svg_fw svg_xs' id='' data='{}' aria='{:label=>"away"}' tabindex=''><path d='M8.20312 11.2031L17.2031 2.25C17.625 1.78125 18.3281 1.78125 18.7969 2.25C19.2188 2.67188 19.2188 3.375 18.7969 3.79688L10.5469 12L18.75 20.25C19.2188 20.6719 19.2188 21.375 18.75 21.7969C18.3281 22.2656 17.625 22.2656 17.2031 21.7969L8.20312 12.7969C7.73438 12.375 7.73438 11.6719 8.20312 11.2031Z' fill='currentColor'></path></svg>", "prev" ) end |