Skip to content

Commit

Permalink
deprecated and renamed bulma 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 e4f859f commit dbad41a
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 49 deletions.
14 changes: 7 additions & 7 deletions docs/extras/bulma.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ Render the navigation links in some view...
with a fast helper:

```erb
<%== pagy_nav_bulma(@pagy) %>
<%== pagy_nav_responsive_bulma(@pagy) %>
<%== pagy_nav_compact_bulma(@pagy) %>
<%== pagy_bulma_nav(@pagy) %>
<%== pagy_bulma_responsive_nav(@pagy) %>
<%== pagy_bulma_compact_nav(@pagy) %>
```

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

Configure [javascript](../extras.md#javascript) if you use `pagy_nav_responsive_bulma` or `pagy_nav_compact_bulma`.
Configure [javascript](../extras.md#javascript) if you use `pagy_bulma_responsive_nav` or `pagy_bulma_compact_nav`.

## Files

Expand All @@ -45,13 +45,13 @@ This extra is composed of 4 files:

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

### pagy_nav_bulma(pagy)
### pagy_bulma_nav(pagy)

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

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

### pagy_nav_compact_bulma(pagy, ...)
### pagy_bulma_compact_nav(pagy, ...)

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

Expand All @@ -61,7 +61,7 @@ Here is an example:

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

### pagy_nav_responsive_bulma(pagy, ...)
### pagy_bulma_responsive_nav(pagy, ...)

This method is the same as the `pagy_nav_responsive`, but customized for the Bulma CSS 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 @@ -41,7 +41,7 @@ Other extras provide also the following framework-styled helpers:

```erb
<%== pagy_bootstrap_compact_nav(@pagy) %>
<%== pagy_nav_compact_bulma(@pagy) %>
<%== pagy_bulma_compact_nav(@pagy) %>
<%== pagy_nav_compact_foundation(@pagy) %>
<%== pagy_nav_compact_materialize(@pagy) %>
<%== pagy_nav_compact_semantic(@pagy) %>
Expand Down Expand Up @@ -80,7 +80,7 @@ Other extras provide also the following framework-styled helpers:

```erb
<%== pagy_bootstrap_responsive_nav(@pagy) %>
<%== pagy_nav_responsive_bulma(@pagy) %>
<%== pagy_bulma_responsive_nav(@pagy) %>
<%== pagy_nav_responsive_foundation(@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 @@ -303,7 +303,7 @@ These helpers take the Pagy object and return the HTML string with the paginatio
| Extra | Helpers |
| ------------------------------------ | ----------------------------------------------------------------------------------------- |
| [bootstrap](extras/bootstrap.md) | `pagy_bootstrap_nav`, `pagy_bootstrap_responsive_nav`, `pagy_bootstrap_compact_nav` |
| [bulma](extras/bulma.md) | `pagy_nav_bulma`, `pagy_nav_responsive_bulma`, `pagy_nav_compact_bulma` |
| [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` |
| [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_nav_bulma` 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_nav_foundation` 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/bulma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class Pagy
module Frontend

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

html << (p_prev ? link.call(p_prev, pagy_t('pagy.nav.prev'), 'class="pagination-previous" aria-label="previous page"')
Expand All @@ -22,15 +22,16 @@ def pagy_nav_bulma(pagy)
end
end
html << '</ul>'
%(<nav class="pagy-nav-bulma pagination is-centered" role="navigation" aria-label="pagination">#{html}</nav>)
%(<nav class="pagy-nav-bulma pagy-bulma-nav pagination is-centered" role="navigation" aria-label="pagination">#{html}</nav>)
end
Pagy.deprecate self, :pagy_nav_bulma, :pagy_bulma_nav

# Compact pagination for Bulma: 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_bulma(pagy, id=caller(1,1)[0].hash)
def pagy_bulma_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-bulma" role="navigation" aria-label="pagination">)
html << %(<nav id="pagy-nav-#{id}" class="pagy-nav-compact-bulma pagy-bulma-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="field is-grouped is-grouped-centered" role="group">)
Expand All @@ -42,10 +43,11 @@ def pagy_nav_compact_bulma(pagy, id=caller(1,1)[0].hash)
: %(<p class="control"><a class="button" disabled>#{pagy_t('pagy.nav.next')}</a></p>))
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_bulma, :pagy_bulma_compact_nav

# Responsive pagination for Bulma: it returns the html with the series of links to the pages
# rendered by the Pagy.responsive javascript
def pagy_nav_responsive_bulma(pagy, id=caller(1,1)[0].hash)
def pagy_bulma_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'] = +(p_prev ? link.call(p_prev, pagy_t('pagy.nav.prev'), 'class="pagination-previous" aria-label="previous page"')
Expand All @@ -61,8 +63,9 @@ def pagy_nav_responsive_bulma(pagy, id=caller(1,1)[0].hash)
end
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-bulma pagination is-centered" role="navigation" aria-label="pagination"></nav>#{script})
%(<nav id="pagy-nav-#{id}" class="pagy-nav-responsive-bulma pagy-bulma-responsive-nav pagination is-centered" role="navigation" aria-label="pagination"></nav>#{script})
end
Pagy.deprecate self, :pagy_nav_responsive_bulma, :pagy_bulma_responsive_nav

end
end
Loading

0 comments on commit dbad41a

Please sign in to comment.