module Pagy::Frontend
def pagy_semantic_responsive_nav(pagy, id=pagy_id)
Responsive pagination for semantic: it returns the html with the series of links to the pages
def pagy_semantic_responsive_nav(pagy, id=pagy_id) tags, link, p_prev, p_next, responsive = {}, pagy_link_proc(pagy, 'class="item"'), pagy.prev, pagy.next, pagy.responsive tags['before'] = (p_prev ? %(#{link.call p_prev, '<i class="left small chevron icon"></i>', 'aria-label="previous"'}) : %(<div class="item disabled"><i class="left small chevron icon"></i></div>)) responsive[:items].each do |item| # series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36] tags[item.to_s] = if item.is_a?(Integer); %(#{link.call item}) # page link elsif item.is_a?(String) ; %(<a class="item active">#{item}</a>) # current page elsif item == :gap ; %(<div class="disabled item">...</div>) # page gap end end tags['after'] = (p_next ? %(#{link.call p_next, '<i class="right small chevron icon"></i>', 'aria-label="next"'}) : %(<div class="item disabled"><i class="right small chevron icon"></i></div>)) script = pagy_json_tag(:responsive, id, tags, responsive[:widths], responsive[:series]) %(<div id="#{id}" class="pagy-nav-responsive-semantic pagy-semantic-responsive-nav ui pagination menu" role="navigation" aria-label="pager"></div>#{script}) end