-
Notifications
You must be signed in to change notification settings - Fork 407
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
253 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
title: Materialize | ||
--- | ||
# Materialize Extra | ||
|
||
This extra adds nav helper and templates for Materialize CSS framework [pagination component](https://materializecss.com/pagination.html). | ||
|
||
## Synopsys | ||
|
||
See [extras](../extras.md) for general usage info. | ||
|
||
Render the navigation links in some view... | ||
with a fast helper: | ||
|
||
```erb | ||
<%== pagy_nav_materialize(@pagy) %> | ||
``` | ||
|
||
## Files | ||
|
||
This extra is composed of 1 file: | ||
|
||
- [materialize.rb](https://github.com/ddnexus/pagy/blob/master/lib/pagy/extras/materialize.rb) | ||
|
||
## Methods | ||
|
||
This extra adds one nav helpers to the `Pagy::Frontend` module. You can customize it by overriding it directly in your own view helper. | ||
|
||
### pagy_nav_materialize(pagy) | ||
|
||
This method is the same as the `pagy_nav`, but customized for Materialize. | ||
|
||
## Templates | ||
|
||
There is currently no template for Materialize. Please, create a Pull Request or an Issue requesting that. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# See the Pagy documentation: https://ddnexus.github.io/pagy/extras/materialize | ||
# frozen_string_literal: true | ||
|
||
class Pagy | ||
# Add nav helper for materialize pagination | ||
module Frontend | ||
|
||
# Pagination for materialize: it returns the html with the series of links to the pages | ||
def pagy_nav_materialize(pagy) | ||
html, link, p_prev, p_next = +'', pagy_link_proc(pagy), pagy.prev, pagy.next | ||
html << (p_prev ? %(<li class="waves-effect prev">#{link.call p_prev, '<i class="material-icons">chevron_left</i>', 'aria-label="previous"'}</li>) | ||
: %(<li class="prev disabled"><a href="#"><i class="material-icons">chevron_left</i></a></li>)) | ||
pagy.series.each do |item| # series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36] | ||
html << if item.is_a?(Integer); %(<li class="waves-effect">#{link.call item}</li>) # page link | ||
elsif item.is_a?(String) ; %(<li class="active">#{link.call item}</li>) # active page | ||
elsif item == :gap ; %(<li class="gap disabled"><a href="#">#{pagy_t('pagy.nav.gap')}</a></li>) # page gap | ||
end | ||
end | ||
html << (p_next ? %(<li class="waves-effect next">#{link.call p_next, '<i class="material-icons">chevron_right</i>', 'aria-label="next"'}</li>) | ||
: %(<li class="next disabled"><a href="#"><i class="material-icons">chevron_right</i></a></li>)) | ||
%(<div class="pagy-nav-materialize pagination" role="navigation" aria-label="pager"><ul class="pagination">#{html}</ul></div>) | ||
end | ||
|
||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.