Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kaminari pagination default view #42

Merged
merged 17 commits into from
Jan 20, 2024
Merged

Kaminari pagination default view #42

merged 17 commits into from
Jan 20, 2024

Conversation

kalashnikovisme
Copy link
Member

@kalashnikovisme kalashnikovisme commented Jan 8, 2024

What's changed basically?

This update is not supposed to set the default pagination behavior of applications, just setting views for kaminari.

  • Add default Tailwind-styled pagination for kaminari
  • Use anyway_config for gem configuration
  • Refactored Engineclass

About dummy application views.

I have a plan to use these views as Tramway default views. That's dummy application views are already Tailwind-styled.

What's changed for tramway drivers?

To use tailwind-styled pagination

Gemfile

gem 'tramway'
gem 'kaminari'

config/initializers/tramway.rb

Tramway.configure do |config|
  config.pagination = { enabled: true } # enabled is false by default
end

app/views/users/index.html.haml

= paginate @users # it will render tailwind-styled pagination buttons by default

Pagination buttons look like this

Song for code review

It's Pentatonix this time. I know that one track is enough for the code review, so I'll prepare a little playlist next time 🙂
https://youtu.be/ywYfMlyIkeo?si=jo7rUFGw6aZzB-Kh

@kalashnikovisme kalashnikovisme changed the base branch from main to use_values_in_forms January 8, 2024 13:05
@kalashnikovisme kalashnikovisme changed the title WIP: Pagination Pagination Jan 8, 2024
@kalashnikovisme kalashnikovisme changed the title Pagination Kaminari pagination default view Jan 8, 2024
Gemfile Outdated
@@ -6,6 +6,8 @@ git_source(:github) { |repo| "https://github.com/#{repo}.git" }
# Specify your gem's dependencies in tramway.gemspec.
gemspec

gem 'anyway_config'

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why you need empty lines in gemfile?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need, you are right! Removed 🙂

# :reek:NestedIterators { enabled: false }
# :reek:TooManyStatements { enabled: false }
def configure_pagination
ActiveSupport.on_load(:action_controller) do |_|
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
ActiveSupport.on_load(:action_controller) do |_|
ActiveSupport.on_load(:action_controller) do

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

%nav.pagination.flex.items-center.justify-center.space-x-1
= first_page_tag unless current_page.first?
= prev_page_tag unless current_page.first?
- each_page do |page|
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe its better empty line before and after each. just to make the code easier to read

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no such empty lines in default kaminari views, so I think we don't need them either 🙂

Base automatically changed from use_values_in_forms to main January 14, 2024 10:46
@kalashnikovisme kalashnikovisme merged commit a9e5536 into main Jan 20, 2024
3 checks passed
@kalashnikovisme kalashnikovisme deleted the pagination branch January 20, 2024 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants