diff --git a/README.md b/README.md
index 9eeb6d8c4..111d4355b 100644
--- a/README.md
+++ b/README.md
@@ -87,6 +87,10 @@ Paginate arrays efficiently avoiding expensive array-wrapping and without any ov
Nav helper and templates for Bootstrap pagination. _(see [more...](http://ddnexus.github.io/pagy/extras/bootstrap))_
+### Bulma Extra
+
+Nav helper and templates for Bulma CSS framework pagination. _(see [more...](http://ddnexus.github.io/pagy/extras/bulma))_
+
### Compact Extra
An alternative UI that combines the pagination feature with the navigation info in one compact element. _(see [more...](http://ddnexus.github.io/pagy/extras/compact))_
diff --git a/docs/assets/images/pagy_compact_bulma_g.png b/docs/assets/images/pagy_compact_bulma_g.png
new file mode 100644
index 000000000..58c95432c
Binary files /dev/null and b/docs/assets/images/pagy_compact_bulma_g.png differ
diff --git a/docs/extras.md b/docs/extras.md
index ab60c66e0..df6082e03 100644
--- a/docs/extras.md
+++ b/docs/extras.md
@@ -9,6 +9,7 @@ Pagy comes with a few optional extensions/extras:
| ------------ | ------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------- |
| `array` | Paginate arrays efficiently avoiding expensive array-wrapping and without overriding | [array.rb](https://github.com/ddnexus/pagy/blob/master/lib/pagy/extras/array.rb), [documentation](extras/array.md) |
| `bootstrap` | Nav helper and templates for Bootstrap pagination | [bootstrap.rb](https://github.com/ddnexus/pagy/blob/master/lib/pagy/extras/bootstrap.rb), [documentation](extras/bootstrap.md) |
+| `bulma` | Nav helper and templates for [Bulma](https://bulma.io) pagination component | [bulma.rb](https://github.com/ddnexus/pagy/blob/master/lib/pagy/extras/bulma.rb), [documentation](extras/bulma.md) |
| `compact` | An alternative UI that combines the pagination with the nav info in a single compact element | [compact.rb](https://github.com/ddnexus/pagy/blob/master/lib/pagy/extras/compact.rb), [documentation](extras/compact.md) |
| `i18n` | Use the `I18n` gem instead of the pagy implementation | [i18n.rb](https://github.com/ddnexus/pagy/blob/master/lib/pagy/extras/i81n.rb), [documentation](extras/i18n.md) |
| `items` | Allow the client to request a custom number of items per page with a ready to use selector UI | [items.rb](https://github.com/ddnexus/pagy/blob/master/lib/pagy/extras/items.rb), [documentation](extras/items.md) |
diff --git a/docs/extras/bulma.md b/docs/extras/bulma.md
new file mode 100644
index 000000000..c3b15d045
--- /dev/null
+++ b/docs/extras/bulma.md
@@ -0,0 +1,46 @@
+---
+title: Bulma
+---
+# Bulma Extra
+
+This extra adds nav helper and templates for Bulma CSS framework [pagination component](https://bulma.io/documentation/components/pagination).
+
+## Synopsys
+
+See [extras](../extras.md) for general usage info.
+
+Render the navigation links in some view...
+with a fast helper:
+
+```erb
+<%== pagy_nav_bulma(@pagy) %>
+```
+
+or with a template:
+
+```erb
+<%== render 'pagy/nav_bulma', locals: {pagy: @pagy} %>
+```
+
+## Files
+
+This extra is composed of 4 files:
+
+- [bulma.rb](https://github.com/ddnexus/pagy/blob/master/lib/pagy/extras/bulma.rb)
+- [nav_bulma.html.erb](https://github.com/ddnexus/pagy/blob/master/lib/pagy/extras/templates/nav_bulma.html.erb) (optional template)
+- [nav_bulma.html.haml](https://github.com/ddnexus/pagy/blob/master/lib/pagy/extras/templates/nav_bulma.html.haml) (optional template)
+- [nav_bulma.html.slim](https://github.com/ddnexus/pagy/blob/master/lib/pagy/extras/templates/nav_bulma.html.slim) (optional template)
+
+## 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_bulma(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.
+
+### Optional Template Files
+
+See [Using Templates](../how-to.md#using-templates).
diff --git a/docs/extras/compact.md b/docs/extras/compact.md
index b2b36992b..13ce8c3b3 100644
--- a/docs/extras/compact.md
+++ b/docs/extras/compact.md
@@ -22,6 +22,7 @@ Then use the responsive helper(s) in any view:
```erb
<%== pagy_nav_compact(@pagy) %>
<%== pagy_nav_compact_bootstrap(@pagy) %>
+<%== pagy_nav_compact_bulma(@pagy) %>
```
## Files
@@ -41,3 +42,10 @@ It can take an extra `id` argument, which is used to build the `id` attribute of
### pagy_nav_compact_bootstrap(pagy, ...)
This method is the same as the `pagy_nav_compact`, but customized for Bootstrap.
+
+### pagy_nav_compact_bulma(pagy, ...)
+
+This method is the same as the `pagy_nav_compact`, but customized for Bulma CSS framework.
+
+Generated pagination preview:
+![pagy-compact-bulma](../assets/images/pagy-compact-bulma-g.png)
diff --git a/docs/extras/responsive.md b/docs/extras/responsive.md
index 1ef2272b1..710bc4067 100644
--- a/docs/extras/responsive.md
+++ b/docs/extras/responsive.md
@@ -28,6 +28,7 @@ Then use the responsive helper(s) in any view:
```erb
<%== pagy_nav_responsive(@pagy) %>
<%== pagy_nav_responsive_bootstrap(@pagy) %>
+<%== pagy_nav_responsive_bulma(@pagy) %>
```
## Files
@@ -57,9 +58,9 @@ The `reponsive` extra adds an instance method to the `Pagy` class and couple of
### responsive
-**Notice**: Unless you are going to override a `pagy_nav_responsive` or `pagy_nav_responsive_bootstrap` helper you can ignore this method.
+**Notice**: Unless you are going to override a `pagy_nav_responsive*` helpers you can ignore this method.
-This is a `Pagy` instance method that returns the data structure used by the `pagy_nav_responsive` and `pagy_nav_responsive_bootstrap` helpers in order to build the html and the javascript codes needed to make Pagy responsive to different widths.
+This is a `Pagy` instance method that returns the data structure used by the `pagy_nav_responsive*` helpers in order to build the html and the javascript codes needed to make Pagy responsive to different widths.
### pagy_nav_responsive(pagy, ...)
@@ -70,3 +71,7 @@ It can take an extra `id` argument, which is used to build the `id` attribute of
### pagy_nav_responsive_bootstrap(pagy, ...)
This method is the same as the `pagy_nav_responsive`, but customized for Bootstrap.
+
+### pagy_nav_responsive_bulma(pagy, ...)
+
+This method is the same as the `pagy_nav_responsive`, but customized for Bulma CSS framework.
diff --git a/lib/pagy/extras/bulma.rb b/lib/pagy/extras/bulma.rb
new file mode 100644
index 000000000..67eb930a9
--- /dev/null
+++ b/lib/pagy/extras/bulma.rb
@@ -0,0 +1,37 @@
+# See the Pagy documentation: https://ddnexus.github.io/pagy/extras/bulma
+# frozen_string_literal: true
+
+class Pagy
+ # Add nav helper for Bulma pagination
+ module Frontend
+
+ def pagy_nav_bulma(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"')
+ : %(#{pagy_t('pagy.nav.prev')}))
+ html << (p_next ? link.call(p_next, pagy_t('pagy.nav.next'), 'class="pagination-next" aria-label="next page"')
+ : %(#{pagy_t('pagy.nav.next')}))
+ html << '
'
+ pagy.series.each do |item| # series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36]
+ html << pagy_nav_bulma_item(link, item)
+ end
+ html << '
'
+ %()
+ end
+
+ private
+
+ def pagy_nav_bulma_item(link, item)
+ if item.is_a?(Integer) # page link
+ aria = %( area-label="goto page #{item}")
+ %(
)
+ end
+ end
+ end
+end
diff --git a/lib/pagy/extras/compact.rb b/lib/pagy/extras/compact.rb
index b551fac4f..59e0291b0 100644
--- a/lib/pagy/extras/compact.rb
+++ b/lib/pagy/extras/compact.rb
@@ -38,5 +38,22 @@ def pagy_nav_compact_bootstrap(pagy, id=caller(1,1)[0].hash)
html << %()
end
+ # 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)
+ html, link, p_prev, p_next, p_page, p_pages = +'', pagy_link_proc(pagy), pagy.prev, pagy.next, pagy.page, pagy.pages
+
+ html << %()
+ end
+
end
end
diff --git a/lib/pagy/extras/responsive.rb b/lib/pagy/extras/responsive.rb
index 106070e53..298a1d747 100644
--- a/lib/pagy/extras/responsive.rb
+++ b/lib/pagy/extras/responsive.rb
@@ -69,5 +69,24 @@ def pagy_nav_responsive_bootstrap(pagy, id=caller(1,1)[0].hash)
%(#{script})
end
+ # 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)
+ tags, link, p_prev, p_next, responsive = {}, pagy_link_proc(pagy), pagy.prev, pagy.next, pagy.responsive
+
+ tags['prev'] = (p_prev ? %(#{link.call(p_prev, pagy_t('pagy.nav.prev'), 'class="pagination-previous" aria-label="previous page"')}