lib/pagy/extras/bulma.rb in pagy-7.0.5 vs lib/pagy/extras/bulma.rb in pagy-7.0.6
- old
+ new
@@ -22,11 +22,12 @@
pagy.series(**vars).each do |item| # series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36]
html << case item
when Integer
%(<li>#{link.call(item, pagy.label_for(item), %(class="pagination-link"))}</li>)
when String
- %(<li>#{link.call(item, pagy.label_for(item), %(class="pagination-link is-current"))}</li>)
+ %(<li><a role="link" class="pagination-link is-current" aria-current="page" aria-disabled="true">#{
+ pagy.label_for(item)}</a></li>)
when :gap
%(<li><span class="pagination-ellipsis">#{pagy_t 'pagy.gap'}</span></li>)
else raise InternalError, "expected item types in series to be Integer, String or :gap; got #{item.inspect}"
end
end
@@ -38,12 +39,13 @@
nav_aria_label: nil, nav_i18n_key: nil, **vars)
sequels = pagy.sequels(**vars)
p_id = %( id="#{pagy_id}") if pagy_id
link = pagy_link_proc(pagy, link_extra:)
tags = { 'before' => %(#{bulma_prev_next_html(pagy, link)}<ul class="pagination-list">),
- 'link' => %(<li>#{link.call(PAGE_PLACEHOLDER, LABEL_PLACEHOLDER, %(class="pagination-link"))}</li>),
- 'active' => %(<li>#{link.call(PAGE_PLACEHOLDER, LABEL_PLACEHOLDER, %(class="pagination-link is-current"))}</li>),
+ 'link' => %(<li>#{link.call(PAGE_TOKEN, LABEL_TOKEN, %(class="pagination-link"))}</li>),
+ 'active' => %(<li><a role="link" class="pagination-link is-current" aria-current="page" aria-disabled="true">#{
+ LABEL_TOKEN}</a></li>),
'gap' => %(<li><span class="pagination-ellipsis">#{pagy_t 'pagy.gap'}</span></li>),
'after' => '</ul>' }
%(<nav#{p_id} class="#{'pagy-rjs ' if sequels.size > 1}pagy-bulma-nav-js pagination #{DEFAULT[:bulma_nav_classes]}" #{
nav_aria_label_attr(pagy, nav_aria_label, nav_i18n_key)}#{
@@ -66,19 +68,19 @@
%(#{html}<div class="field is-grouped is-grouped-centered" role="group" #{
pagy_data(pagy, :combo, pagy_marked_link(link))}>#{
if (p_prev = pagy.prev)
%(<p class="control">#{link.call(p_prev, pagy_t('pagy.prev'), %(class="button" #{prev_aria_label_attr}))}</p>)
else
- %(<p class="control"><a class="button" disabled aria-disabled="true" #{
+ %(<p class="control"><a role="link" class="button" disabled aria-disabled="true" #{
prev_aria_label_attr}>#{pagy_t 'pagy.prev'}</a></p>)
end
}<div class="pagy-combo-input control level is-mobile">#{
pagy_t 'pagy.combo_nav_js', page_input: input, count: p_page, pages: p_pages}</div>#{
if (p_next = pagy.next)
%(<p class="control">#{link.call(p_next, pagy_t('pagy.next'), %(class="button" #{next_aria_label_attr}))}</p>)
else
- %(<p class="control"><a class="button" disabled aria-disabled="true"#{
+ %(<p class="control"><a role="link" class="button" disabled aria-disabled="true"#{
next_aria_label_attr}>#{pagy_t 'pagy.next'}</a></p>)
end
}</div></nav>)
end
@@ -86,16 +88,16 @@
def bulma_prev_next_html(pagy, link)
html = +if (p_prev = pagy.prev)
link.call(p_prev, pagy_t('pagy.prev'), %(#{prev_aria_label_attr} class="pagination-previous"))
else
- %(<a class="pagination-previous" disabled aria-disabled="true" #{
+ %(<a role="link" class="pagination-previous" disabled aria-disabled="true" #{
prev_aria_label_attr}>#{pagy_t 'pagy.prev'}</a>)
end
html << if (p_next = pagy.next)
link.call(p_next, pagy_t('pagy.next'), %(#{next_aria_label_attr} class="pagination-next"))
else
- %(<a class="pagination-next" disabled aria-disabled="true" #{
+ %(<a role="link" class="pagination-next" disabled aria-disabled="true" #{
next_aria_label_attr}>#{pagy_t('pagy.next')}</a>)
end
end
end
Frontend.prepend BulmaExtra