Skip to content

Commit

Permalink
Merge pull request #98 from lxxxvi/fix-pagination
Browse files Browse the repository at this point in the history
style pagination
  • Loading branch information
lxxxvi committed Aug 18, 2023
2 parents a92713b + f08ecc3 commit 4ea5bc1
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
30 changes: 30 additions & 0 deletions app/assets/stylesheets/application.tailwind.css
Expand Up @@ -115,3 +115,33 @@ input[type=text], textarea {
.flash-success {
@apply border-green-500;
}

/* pagy */

.pagy-nav.pagination {
@apply isolate inline-flex -space-x-px rounded shadow-sm;
}

.page.next a {
@apply relative inline-flex items-center rounded-r border border-gray-300 bg-white py-1 px-4 text-sm font-medium text-gray-500 hover:bg-gray-50 focus:z-20;
}

.page.prev a {
@apply relative inline-flex items-center rounded-l border border-gray-300 bg-white py-1 px-4 text-sm font-medium text-gray-500 hover:bg-gray-50 focus:z-20;
}

.page.next.disabled {
@apply relative inline-flex items-center rounded-r border border-gray-300 bg-slate-100 py-1 px-4 text-sm font-medium text-gray-500 focus:z-20;
}

.page.prev.disabled {
@apply relative inline-flex items-center rounded-l border border-gray-300 bg-slate-100 py-1 px-4 text-sm font-medium text-gray-500 hover:bg-gray-50 focus:z-20;
}

.page a, .page.gap {
@apply bg-white border-gray-300 text-gray-500 hover:bg-gray-50 relative inline-flex items-center border px-4 py-1 text-sm font-medium focus:z-20;
}

.page.active {
@apply z-10 border-red-700 bg-red-50 text-red-700 relative inline-flex items-center border px-4 py-1 text-sm font-medium focus:z-20;
}
2 changes: 1 addition & 1 deletion app/controllers/saab900_controller.rb
Expand Up @@ -2,6 +2,6 @@ class Saab900Controller < ApplicationController
include Pagy::Backend

def show
@pagy, @records = pagy(Upload.published.ordered_chronologically)
@pagy, @records = pagy(Upload.published.ordered_chronologically, items: 10)
end
end
7 changes: 6 additions & 1 deletion app/views/uploads/_index.html.haml
@@ -1,12 +1,17 @@
- if records.any?

= raw pagy_nav(@pagy) if @pagy.pages > 1
.flex.justify-center
= raw pagy_nav(@pagy) if @pagy.pages > 1

%ul.text-center
- records.each do |record|
%li.gallery-item
= render 'uploads/file', record: record, image_size: :gallery

.flex.justify-center
= raw pagy_nav(@pagy) if @pagy.pages > 1


- else
.text-gray-500.text-center
= t('.nothing_there_yet')

0 comments on commit 4ea5bc1

Please sign in to comment.