From c1aec4c213a99862ec4e75b9112970db7b64360d Mon Sep 17 00:00:00 2001
From: Domizio Demichelis
Date: Sun, 30 Sep 2018 17:40:36 +0700
Subject: [PATCH] removed marginal pagy.nav.current key used only by foundation
an fixed consistency in foundation helpers and templates
---
lib/locales/pagy.yml | 5 -----
lib/pagy/extras/foundation.rb | 12 ++++++------
lib/templates/nav_foundation.html.erb | 4 ++--
lib/templates/nav_foundation.html.haml | 7 ++-----
lib/templates/nav_foundation.html.slim | 5 +----
test/pagy/extras/foundation_test.rb | 16 ++++++++--------
6 files changed, 19 insertions(+), 30 deletions(-)
diff --git a/lib/locales/pagy.yml b/lib/locales/pagy.yml
index fa4f2acc9..91540ae54 100644
--- a/lib/locales/pagy.yml
+++ b/lib/locales/pagy.yml
@@ -6,7 +6,6 @@ en:
prev: "‹ Prev"
next: "Next ›"
gap: "…"
- current: "You're on page"
info:
single_page:
zero: "No %{item_name} found"
@@ -27,7 +26,6 @@ es:
prev: "‹ Prev"
next: "Siguiente ›"
gap: "…"
- current: "Estás en la página"
info:
single_page:
zero: "Sin resultados"
@@ -48,7 +46,6 @@ id:
prev: "‹ Balik"
next: "Lanjut ›"
gap: "…"
- current: "Anda di halaman"
info:
single_page:
zero: "Tidak ditemukan %{item_name}"
@@ -89,7 +86,6 @@ pt-br:
prev: "‹ Anterior"
next: "Próximo ›"
gap: "…"
- current: "Está na página"
info:
single_page:
zero: "Sem resultados"
@@ -110,7 +106,6 @@ ru:
prev: "‹ Назад"
next: "Вперёд ›"
gap: "…"
- current: "Вы на странице"
info:
single_page:
zero: "Пока %{item_name} нет"
diff --git a/lib/pagy/extras/foundation.rb b/lib/pagy/extras/foundation.rb
index c818ab32f..dc8dcc545 100644
--- a/lib/pagy/extras/foundation.rb
+++ b/lib/pagy/extras/foundation.rb
@@ -13,9 +13,9 @@ def pagy_nav_foundation(pagy)
html << (p_prev ? %(#{link.call p_prev, pagy_t('pagy.nav.prev'), 'aria-label="previous"'})
: %(#{pagy_t('pagy.nav.prev')}))
pagy.series.each do |item| # series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36]
- html << if item.is_a?(Integer); %(#{link.call item}) # page link
- elsif item.is_a?(String) ; %(#{pagy_t('pagy.nav.current')} #{item}) # active page
- elsif item == :gap ; %() # page gap
+ html << if item.is_a?(Integer); %(#{link.call item}) # page link
+ elsif item.is_a?(String) ; %(#{item}) # active page
+ elsif item == :gap ; %() # page gap
end
end
html << (p_next ? %(#{link.call p_next, pagy_t('pagy.nav.next'), 'aria-label="next"'})
@@ -50,9 +50,9 @@ def pagy_nav_responsive_foundation(pagy, id=caller(1,1)[0].hash)
tags['before'] << (p_prev ? %(#{link.call p_prev, pagy_t('pagy.nav.prev'), 'aria-label="previous"'})
: %(#{pagy_t('pagy.nav.prev')}))
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) ; %(#{pagy_t('pagy.nav.current')} #{item}) # active page
- elsif item == :gap ; %(#{pagy_t('pagy.nav.gap')}) # page gap
+ tags[item.to_s] = if item.is_a?(Integer); %(#{link.call item}) # page link
+ elsif item.is_a?(String) ; %(#{item}) # active page
+ elsif item == :gap ; %() # page gap
end
end
tags['after'] = +(p_next ? %(#{link.call p_next, pagy_t('pagy.nav.next'), 'aria-label="next"'})
diff --git a/lib/templates/nav_foundation.html.erb b/lib/templates/nav_foundation.html.erb
index 49f5a6c35..7a17eba00 100644
--- a/lib/templates/nav_foundation.html.erb
+++ b/lib/templates/nav_foundation.html.erb
@@ -13,8 +13,8 @@
<% end -%>
<% pagy.series.each do |item| # series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36] -%>
<% if item.is_a?(Integer) -%> <%== link.call(item) %>
-<% elsif item.is_a?(String) -%> <%== pagy_t('pagy.nav.current')%> <%= item %>
-<% elsif item == :gap -%> <%== pagy_t('pagy.nav.gap') %>
+<% elsif item.is_a?(String) -%> <%= item %>
+<% elsif item == :gap -%>
<% end -%>
<% end -%>
<% if pagy.next -%> <%== link.call(pagy.next, pagy_t('pagy.nav.next'), 'aria-label="next"') %>
diff --git a/lib/templates/nav_foundation.html.haml b/lib/templates/nav_foundation.html.haml
index 511012265..bf59778b1 100644
--- a/lib/templates/nav_foundation.html.haml
+++ b/lib/templates/nav_foundation.html.haml
@@ -22,13 +22,10 @@
- elsif item.is_a?(String) # current page
%li.current
- %span.show-for-sr
- != pagy_t('pagy.nav.current')
- != item
+ = item
- elsif item == :gap # page gap
- %li.disabled.gap
- != pagy_t('pagy.nav.gap')
+ %li.ellipsis.gap{"aria-hidden" => true}
- if pagy.next
%li.next!= link.call(pagy.next, pagy_t('pagy.nav.next'), 'aria-label="next"')
diff --git a/lib/templates/nav_foundation.html.slim b/lib/templates/nav_foundation.html.slim
index 8a846ef22..b03615e8d 100644
--- a/lib/templates/nav_foundation.html.slim
+++ b/lib/templates/nav_foundation.html.slim
@@ -22,13 +22,10 @@ nav.pagy-nav-foundation role="navigation" aria-label="Pagination"
- elsif item.is_a?(String) # current page
li.current
- span.show-for-sr
- == pagy_t('pagy.nav.current')
= item
- elsif item == :gap # page gap
- li.disabled.gap
- == pagy_t('pagy.nav.gap')
+ li.ellipsis.gap aria-hidden="true"
- if pagy.next
li.next == link.call(pagy.next, pagy_t('pagy.nav.next'), 'aria-label="next"')
diff --git a/test/pagy/extras/foundation_test.rb b/test/pagy/extras/foundation_test.rb
index 143097031..44f3ad8a6 100644
--- a/test/pagy/extras/foundation_test.rb
+++ b/test/pagy/extras/foundation_test.rb
@@ -16,26 +16,26 @@
it 'renders page 1' do
pagy, _ = @array.pagy(1)
frontend.pagy_nav_foundation(pagy).must_equal \
- ""
+ ""
end
it 'renders page 3' do
pagy, _ = @array.pagy(3)
frontend.pagy_nav_foundation(pagy).must_equal \
- ""
+ ""
end
it 'renders page 6' do
pagy, _ = @array.pagy(6)
frontend.pagy_nav_foundation(pagy).must_equal \
- ""
+ ""
end
it 'renders page 10' do
@array = (1..1000).to_a.extend(Pagy::Array::PageMethod)
pagy, _ = @array.pagy(10)
frontend.pagy_nav_foundation(pagy).must_equal \
- ""
+ ""
end
end
@@ -79,21 +79,21 @@
pagy, _ = @array.pagy(1)
html, id = frontend.pagy_nav_responsive_foundation(pagy), caller(0,1)[0].hash
html.must_equal \
- ""
+ ""
end
it 'renders page 3 for foundation' do
pagy, _ = @array.pagy(3)
html, id = frontend.pagy_nav_responsive_foundation(pagy), caller(0,1)[0].hash
html.must_equal \
- ""
+ ""
end
it 'renders page 6 for foundation' do
pagy, _ = @array.pagy(6)
html, id = frontend.pagy_nav_responsive_foundation(pagy), caller(0,1)[0].hash
html.must_equal \
- ""
+ ""
end
it 'renders page 10 for foundation' do
@@ -101,7 +101,7 @@
pagy, _ = @array.pagy(10)
html, id = frontend.pagy_nav_responsive_foundation(pagy), caller(0,1)[0].hash
html.must_equal \
- ""
+ ""
end
end