Skip to content

Commit

Permalink
deprecated and renamed semantic 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 a9c3822 commit 4bc72af
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 39 deletions.
4 changes: 2 additions & 2 deletions docs/extras/navs.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Other extras provide also the following framework-styled helpers:
<%== pagy_bulma_compact_nav(@pagy) %>
<%== pagy_foundation_compact_nav(@pagy) %>
<%== pagy_materialize_compact_nav(@pagy) %>
<%== pagy_nav_compact_semantic(@pagy) %>
<%== pagy_semantic_compact_nav(@pagy) %>
```

## Methods
Expand Down Expand Up @@ -83,7 +83,7 @@ Other extras provide also the following framework-styled helpers:
<%== pagy_bulma_responsive_nav(@pagy) %>
<%== pagy_foundation_responsive_nav(@pagy) %>
<%== pagy_materialize_responsive_nav(@pagy) %>
<%== pagy_nav_responsive_semantic(@pagy) %>
<%== pagy_semantic_responsive_nav(@pagy) %>
```

## Variables
Expand Down
12 changes: 6 additions & 6 deletions docs/extras/semantic.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_semantic(@pagy) %>
<%== pagy_nav_compact_semantic(@pagy) %>
<%== pagy_nav_responsive_semantic(@pagy) %>
<%== pagy_semantic_nav(@pagy) %>
<%== pagy_semantic_compact_nav(@pagy) %>
<%== pagy_semantic_responsive_nav(@pagy) %>
```

## Files
Expand All @@ -34,17 +34,17 @@ This extra is composed of 1 file:

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_semantic(pagy)
### pagy_semantic_nav(pagy)

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

### pagy_nav_compact_semantic(pagy, ...)
### pagy_semantic_compact_nav(pagy, ...)

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

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

### pagy_nav_responsive_semantic(pagy, ...)
### pagy_semantic_responsive_nav(pagy, ...)

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

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

# Pagination for semantic-ui: it returns the html with the series of links to the pages
def pagy_nav_semantic(pagy)
def pagy_semantic_nav(pagy)
html, link, p_prev, p_next = +'', pagy_link_proc(pagy, 'class="item"'), pagy.prev, pagy.next

html << (p_prev ? %(#{link.call p_prev, '<i class="left small chevron icon"></i>', 'aria-label="previous"'})
Expand All @@ -20,15 +20,16 @@ def pagy_nav_semantic(pagy)
end
html << (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>))
%(<div class="ui pagination menu" aria-label="pager">#{html}</div>)
%(<div class="pagy-nav-semantic pagy-semantic-nav ui pagination menu" aria-label="pager">#{html}</div>)
end
Pagy.deprecate self, :pagy_nav_semantic, :pagy_semantic_nav

# Compact pagination for semantic: 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_semantic(pagy, id=caller(1,1)[0].hash)
def pagy_semantic_compact_nav(pagy, id=caller(1,1)[0].hash)
html, link, p_prev, p_next, p_page, p_pages = +'', pagy_link_proc(pagy, 'class="item"'), pagy.prev, pagy.next, pagy.page, pagy.pages

html << %(<div id="pagy-nav-#{id}" class="pagy-nav-compact-semantic ui compact menu" role="navigation" aria-label="pager">)
html << %(<div id="pagy-nav-#{id}" class="pagy-nav-compact-semantic pagy-semantic-compact-nav ui compact menu" role="navigation" aria-label="pager">)
html << link.call(MARKER, '', %(style="display: none;" ))
(html << link.call(1, '', %(style="display: none;" ))) if defined?(TRIM)
html << (p_prev ? %(#{link.call p_prev, '<i class="left small chevron icon"></i>', 'aria-label="previous"'})
Expand All @@ -39,10 +40,11 @@ def pagy_nav_compact_semantic(pagy, id=caller(1,1)[0].hash)
: %(<div class="item disabled"><i class="right small chevron icon"></i></div>))
html << %(</div><script type="application/json" class="pagy-compact-json">["#{id}", "#{MARKER}", "#{p_page}", #{!!defined?(TRIM)}]</script>)
end
Pagy.deprecate self, :pagy_nav_compact_semantic, :pagy_semantic_compact_nav

# Responsive pagination for semantic: it returns the html with the series of links to the pages
# rendered by the Pagy.responsive javascript
def pagy_nav_responsive_semantic(pagy, id=caller(1,1)[0].hash)
def pagy_semantic_responsive_nav(pagy, id=caller(1,1)[0].hash)
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"'})
Expand All @@ -56,8 +58,9 @@ def pagy_nav_responsive_semantic(pagy, id=caller(1,1)[0].hash)
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 = %(<script type="application/json" class="pagy-responsive-json">["#{id}", #{tags.to_json}, #{responsive[:widths].to_json}, #{responsive[:series].to_json}]</script>)
%(<div id="pagy-nav-#{id}" class="pagy-nav-responsive-semantic ui pagination menu" role="navigation" aria-label="pager"></div>#{script})
%(<div id="pagy-nav-#{id}" class="pagy-nav-responsive-semantic pagy-semantic-responsive-nav ui pagination menu" role="navigation" aria-label="pager"></div>#{script})
end
Pagy.deprecate self, :pagy_nav_responsive_semantic, :pagy_semantic_responsive_nav

end
end
Loading

0 comments on commit 4bc72af

Please sign in to comment.