Skip to content

armgit / spree

Public Imported from GitHub
0

Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.

Storefront kaminari templates

Damian Legawiec58f0909017c5
diff --git a/storefront/app/views/kaminari/storefront/_first_page.html.erb b/storefront/app/views/kaminari/storefront/_first_page.html.erb
new file mode 100644
index 0000000000..95fc7f4da2
--- /dev/null
+++ b/storefront/app/views/kaminari/storefront/_first_page.html.erb
@@ -0,0 +1,8 @@
+<%# Link to the "First" page
+ - available local variables
+ url: url to the first page
+ current_page: a page object for the currently displayed page
+ total_pages: total number of pages
+ per_page: number of items to fetch per page
+ remote: data-remote
+-%>
diff --git a/storefront/app/views/kaminari/storefront/_gap.html.erb b/storefront/app/views/kaminari/storefront/_gap.html.erb
new file mode 100644
index 0000000000..f4ca7b25aa
--- /dev/null
+++ b/storefront/app/views/kaminari/storefront/_gap.html.erb
@@ -0,0 +1,8 @@
+<%# Non-link tag that stands for skipped pages...
+ - available local variables
+ current_page: a page object for the currently displayed page
+ total_pages: total number of pages
+ per_page: number of items to fetch per page
+ remote: data-remote
+-%>
+<span class="w-8 text-center"><%= t('views.pagination.truncate').html_safe %></span>
diff --git a/storefront/app/views/kaminari/storefront/_last_page.html.erb b/storefront/app/views/kaminari/storefront/_last_page.html.erb
new file mode 100644
index 0000000000..1731126317
--- /dev/null
+++ b/storefront/app/views/kaminari/storefront/_last_page.html.erb
@@ -0,0 +1,8 @@
+<%# Link to the "Last" page
+ - available local variables
+ url: url to the last page
+ current_page: a page object for the currently displayed page
+ total_pages: total number of pages
+ per_page: number of items to fetch per page
+ remote: data-remote
+-%>
diff --git a/storefront/app/views/kaminari/storefront/_next_page.html.erb b/storefront/app/views/kaminari/storefront/_next_page.html.erb
new file mode 100644
index 0000000000..d7597ce452
--- /dev/null
+++ b/storefront/app/views/kaminari/storefront/_next_page.html.erb
@@ -0,0 +1,13 @@
+<%# Link to the "Next" page
+ - available local variables
+ url: url to the next page
+ current_page: a page object for the currently displayed page
+ total_pages: total number of pages
+ per_page: number of items to fetch per page
+ remote: data-remote
+-%>
+<% css = "inline-flex justify-center items-center gap-x-1.5 px-4#{' pagination-link--disabled' if current_page.last?}" %>
+
+<%= link_to(url, disabled: current_page.last?, class: css) do %>
+ <%= render 'spree/shared/icons/chevron_right', size: 20, color: current_page.last? ? theme_setting(:neutral_color) : theme_setting(:text_color) %>
+<% end %>
diff --git a/storefront/app/views/kaminari/storefront/_page.html.erb b/storefront/app/views/kaminari/storefront/_page.html.erb
new file mode 100644
index 0000000000..2459161ed2
--- /dev/null
+++ b/storefront/app/views/kaminari/storefront/_page.html.erb
@@ -0,0 +1,10 @@
+<%# Link showing page number
+ - available local variables
+ page: a page object for "this" page
+ url: url to this page
+ current_page: a page object for the currently displayed page
+ total_pages: total number of pages
+ per_page: number of items to fetch per page
+ remote: data-remote
+-%>
+<%= active_link_to page, url, class: 'pagination-link w-8 text-center', active: page.current?, class_active: 'pagination-link--active' %>
diff --git a/storefront/app/views/kaminari/storefront/_paginator.html.erb b/storefront/app/views/kaminari/storefront/_paginator.html.erb
new file mode 100644
index 0000000000..5adb437ebc
--- /dev/null
+++ b/storefront/app/views/kaminari/storefront/_paginator.html.erb
@@ -0,0 +1,27 @@
+<%# The container tag
+ - available local variables
+ current_page: a page object for the currently displayed page
+ total_pages: total number of pages
+ per_page: number of items to fetch per page
+ remote: data-remote
+ paginator: the paginator that renders the pagination tags inside
+-%>
+<%= paginator.render do -%>
+ <nav class="pagination flex items-center justify-center gap-x-1 mt-16" role="navigation" aria-label="pager">
+ <%= prev_page_tag %>
+
+ <div class="flex items-center gap-x-1">
+ <% each_page do |page| -%>
+ <% if page.display_tag? -%>
+ <%= page_tag page %>
+ <% elsif !page.was_truncated? -%>
+ <%= gap_tag %>
+ <% end -%>
+ <% end -%>
+ </div>
+
+ <% unless current_page.out_of_range? %>
+ <%= next_page_tag %>
+ <% end %>
+ </nav>
+<% end -%>
diff --git a/storefront/app/views/kaminari/storefront/_prev_page.html.erb b/storefront/app/views/kaminari/storefront/_prev_page.html.erb
new file mode 100644
index 0000000000..c1b532a07c
--- /dev/null
+++ b/storefront/app/views/kaminari/storefront/_prev_page.html.erb
@@ -0,0 +1,13 @@
+<%# Link to the "Previous" page
+ - available local variables
+ url: url to the previous page
+ current_page: a page object for the currently displayed page
+ total_pages: total number of pages
+ per_page: number of items to fetch per page
+ remote: data-remote
+-%>
+<% css = "inline-flex justify-center items-center gap-x-1.5 px-4#{' pagination-link--disabled' if current_page.first?}" %>
+
+<%= link_to(url, disabled: current_page.first?, class: css) do %>
+ <%= render 'spree/shared/icons/chevron', size: 20, color: current_page.first? ? theme_setting(:neutral_color) : theme_setting(:text_color) %>
+<% end %>