Skip to content

Commit

Permalink
deprecated and renamed foundation navs in code, tests and docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ddnexus committed Nov 30, 2018
1 parent 95045c3 commit f984f83
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 40 deletions.
10 changes: 5 additions & 5 deletions docs/extras/foundation.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Render the navigation links in some view...
with a fast helper:

```erb
<%== pagy_nav_foundation(@pagy) %>
<%== pagy_foundation_nav(@pagy) %>
```

or with a template:
Expand All @@ -28,7 +28,7 @@ or with a template:
<%== render 'pagy/nav_foundation', locals: {pagy: @pagy} %>
```

Configure [javascript](../extras.md#javascript) if you use `pagy_nav_responsive_foundation` or `pagy_nav_compact_foundation`.
Configure [javascript](../extras.md#javascript) if you use `pagy_foundation_responsive_nav` or `pagy_foundation_compact_nav`.

## Files

Expand All @@ -43,19 +43,19 @@ This extra is composed of 4 files:

This extra adds 3 nav helpers to the `Pagy::Frontend` module. You can customize it by overriding it directly in your own view helper.

### pagy_nav_foundation(pagy)
### pagy_foundation_nav(pagy)

This method is the same as the `pagy_nav`, but customized for Foundation.

The `nav_foundation.*` templates produce the same output, and can be used as an easier (but slower) starting point to override it.

### pagy_nav_compact_foundation(pagy, ...)
### pagy_foundation_compact_nav(pagy, ...)

This method is the same as the `pagy_nav_compact`, but customized for the Foundation framework.

See more details in the [compact navs](navs.md#compact-navs) documentation.

### pagy_nav_responsive_foundation(pagy, ...)
### pagy_foundation_responsive_nav(pagy, ...)

This method is the same as the `pagy_nav_responsive`, but customized for the Foundation framework.

Expand Down
4 changes: 2 additions & 2 deletions docs/extras/navs.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Other extras provide also the following framework-styled helpers:
```erb
<%== pagy_bootstrap_compact_nav(@pagy) %>
<%== pagy_bulma_compact_nav(@pagy) %>
<%== pagy_nav_compact_foundation(@pagy) %>
<%== pagy_foundation_compact_nav(@pagy) %>
<%== pagy_nav_compact_materialize(@pagy) %>
<%== pagy_nav_compact_semantic(@pagy) %>
```
Expand Down Expand Up @@ -81,7 +81,7 @@ Other extras provide also the following framework-styled helpers:
```erb
<%== pagy_bootstrap_responsive_nav(@pagy) %>
<%== pagy_bulma_responsive_nav(@pagy) %>
<%== pagy_nav_responsive_foundation(@pagy) %>
<%== pagy_foundation_responsive_nav(@pagy) %>
<%== pagy_nav_responsive_materialize(@pagy) %>
<%== pagy_nav_responsive_semantic(@pagy) %>
```
Expand Down
4 changes: 2 additions & 2 deletions docs/how-to.md
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ These helpers take the Pagy object and return the HTML string with the paginatio
| ------------------------------------ | ----------------------------------------------------------------------------------------- |
| [bootstrap](extras/bootstrap.md) | `pagy_bootstrap_nav`, `pagy_bootstrap_responsive_nav`, `pagy_bootstrap_compact_nav` |
| [bulma](extras/bulma.md) | `pagy_bulma_nav`, `pagy_bulma_responsive_nav`, `pagy_bulma_compact_nav` |
| [foundation](extras/foundation.md) | `pagy_nav_foundation`, `pagy_nav_responsive_foundation`, `pagy_nav_compact_foundation` |
| [foundation](extras/foundation.md) | `pagy_foundation_nav`, `pagy_foundation_responsive_nav`, `pagy_foundation_compact_nav` |
| [materialize](extras/materialize.md) | `pagy_nav_materialize`, `pagy_nav_responsive_materialize`, `pagy_nav_compact_materialize` |
| [navs](extras/navs.md) | `pagy_nav_responsive`, `pagy_nav_compact` |

Expand All @@ -328,7 +328,7 @@ By default Pagy generates all the page links including the `page` param. If you

The `pagy_nav*` helpers are optimized for speed, and they are really fast. On the other hand editing a template might be easier when you have to customize the rendering, however every template system adds some inevitable overhead and it will be about 40-80% slower than using the related helper. That will still be dozens of times faster than the other gems, but... you should choose wisely.

Pagy provides the replacement templates for the `pagy_nav`, `pagy_bootstrap_nav`, `pagy_bulma_nav` and the `pagy_nav_foundation` helpers (available with the relative extras) in 3 flavors: `erb`, `haml` and `slim`.
Pagy provides the replacement templates for the `pagy_nav`, `pagy_bootstrap_nav`, `pagy_bulma_nav` and the `pagy_foundation_nav` helpers (available with the relative extras) in 3 flavors: `erb`, `haml` and `slim`.

They produce exactly the same output of the helpers, but since they are slower, using them wouldn't make any sense unless you need to change something. In that case customize a copy in your app, then use it as any other template: just remember to pass the `:pagy` local set to the `@pagy` object. Here are the links to the sources to copy:

Expand Down
15 changes: 9 additions & 6 deletions lib/pagy/extras/foundation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Pagy
module Frontend

# Pagination for Foundation: it returns the html with the series of links to the pages
def pagy_nav_foundation(pagy)
def pagy_foundation_nav(pagy)
html, link, p_prev, p_next = +'', pagy_link_proc(pagy), pagy.prev, pagy.next

html << (p_prev ? %(<li class="prev">#{link.call p_prev, pagy_t('pagy.nav.prev'), 'aria-label="previous"'}</li>)
Expand All @@ -20,15 +20,16 @@ def pagy_nav_foundation(pagy)
end
html << (p_next ? %(<li class="next">#{link.call p_next, pagy_t('pagy.nav.next'), 'aria-label="next"'}</li>)
: %(<li class="next disabled">#{pagy_t('pagy.nav.next')}</li>))
%(<nav class="pagy-nav-foundation" role="navigation" aria-label="Pagination"><ul class="pagination">#{html}</ul></nav>)
%(<nav class="pagy-nav-foundation pagy-foundation-nav" role="navigation" aria-label="Pagination"><ul class="pagination">#{html}</ul></nav>)
end
Pagy.deprecate self, :pagy_nav_foundation, :pagy_foundation_nav

# Compact pagination for Foundation: it returns the html with the series of links to the pages
# we use a numeric input tag to set the page and the Pagy.compact javascript to navigate
def pagy_nav_compact_foundation(pagy, id=caller(1,1)[0].hash)
def pagy_foundation_compact_nav(pagy, id=caller(1,1)[0].hash)
html, link, p_prev, p_next, p_page, p_pages = +'', pagy_link_proc(pagy), pagy.prev, pagy.next, pagy.page, pagy.pages

html << %(<nav id="pagy-nav-#{id}" class="pagy-nav-compact-foundation" role="navigation" aria-label="Pagination">)
html << %(<nav id="pagy-nav-#{id}" class="pagy-nav-compact-foundation pagy-foundation-compact-nav" role="navigation" aria-label="Pagination">)
html << link.call(MARKER, '', %(style="display: none;" ))
(html << link.call(1, '', %(style="display: none;" ))) if defined?(TRIM)
html << %(<div class="input-group">)
Expand All @@ -40,10 +41,11 @@ def pagy_nav_compact_foundation(pagy, id=caller(1,1)[0].hash)
: %(<a style="margin-bottom: 0px;" class="next button primary disabled" href="#">#{pagy_t('pagy.nav.next')}</a>))
html << %(</div></nav><script type="application/json" class="pagy-compact-json">["#{id}", "#{MARKER}", "#{p_page}", #{!!defined?(TRIM)}]</script>)
end
Pagy.deprecate self, :pagy_nav_compact_foundation, :pagy_foundation_compact_nav

# Responsive pagination for Foundation: it returns the html with the series of links to the pages
# rendered by the Pagy.responsive javascript
def pagy_nav_responsive_foundation(pagy, id=caller(1,1)[0].hash)
def pagy_foundation_responsive_nav(pagy, id=caller(1,1)[0].hash)
tags, link, p_prev, p_next, responsive = {}, pagy_link_proc(pagy), pagy.prev, pagy.next, pagy.responsive

tags['before'] = +'<ul class="pagination">'
Expand All @@ -59,8 +61,9 @@ def pagy_nav_responsive_foundation(pagy, id=caller(1,1)[0].hash)
: %(<li class="next disabled">#{pagy_t('pagy.nav.next')}</li>))
tags['after'] << '</ul>'
script = %(<script type="application/json" class="pagy-responsive-json">["#{id}", #{tags.to_json}, #{responsive[:widths].to_json}, #{responsive[:series].to_json}]</script>)
%(<nav id="pagy-nav-#{id}" class="pagy-nav-responsive-foundation" aria-label="Pagination"></nav>#{script})
%(<nav id="pagy-nav-#{id}" class="pagy-nav-responsive-foundation pagy-foundation-responsive-nav" aria-label="Pagination"></nav>#{script})
end
Pagy.deprecate self, :pagy_nav_responsive_foundation, :pagy_foundation_responsive_nav

end
end
Loading

0 comments on commit f984f83

Please sign in to comment.