Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use kaminari theme for zurb foundation

I want to apply a theme for zurb foundation to kaminari pagination.

Detault theme can be installed by rails g kaminari:views default. But I couldn't figure out how to install other themes.

Especially, theme for foundation is not merged. https://github.com/amatsuda/kaminari_themes/pull/14

There is no readme in kaminari_themes, so I have no idea how to go further. What should I do to apply the foundation theme?

like image 616
ironsand Avatar asked Jan 24 '14 13:01

ironsand


4 Answers

Foundation was added in a recent release, so now you can do this:

rails g kaminari:views foundation
like image 198
GSto Avatar answered Nov 17 '22 13:11

GSto


If you generate the theme (it might not matter which one), for example

rails g kaminari:views bootstrap

You can see all of the "machinery" in the views\kaminari\ folder. Here is my "hack" to get Foundations Pagination working with Kaminari:

I tweaked _paginator.html.haml to reflect the Foundation class on the ul tag:

= paginator.render do
  %ul.pagination
  ...

And I tweaked _page.html.haml to reflect Foundations current class (instead of Kaminari's active:

%li{class: "#{'current' if page.current?}"}

And then it just worked!

like image 37
Jon Kern Avatar answered Nov 17 '22 14:11

Jon Kern


I tried this command and it worked: rails g kaminari:views bootstrap. The source, here, makes it clear that he's pulling themes from his themes repo when running rails g kaminari:views. Pretty cool!

like image 1
pdobb Avatar answered Nov 17 '22 15:11

pdobb


A not so hacky solution would be to use theme from RalphAtHamburg's fork.

Simply copy kaminari views to app/views/kaminari/ directory.

This is similar to what happens when you run rails g kaminari:views [default|bootstrap|google|github], If these partials are present in app/views/kaminari/ Kaminari uses them instead of the default partial views.

For more info on themes use Kaminari Readme

like image 1
abhishek77in Avatar answered Nov 17 '22 13:11

abhishek77in