Class: EasyAdmin::InfiniteScrollComponent
- Inherits:
-
Phlex::HTML
- Object
- Phlex::HTML
- EasyAdmin::InfiniteScrollComponent
- Defined in:
- app/components/easy_admin/infinite_scroll_component.rb
Instance Method Summary collapse
-
#initialize(pagy:, resource_class:, current_params: {}, current_path:) ⇒ InfiniteScrollComponent
constructor
A new instance of InfiniteScrollComponent.
- #view_template ⇒ Object
Constructor Details
#initialize(pagy:, resource_class:, current_params: {}, current_path:) ⇒ InfiniteScrollComponent
Returns a new instance of InfiniteScrollComponent.
3 4 5 6 7 8 |
# File 'app/components/easy_admin/infinite_scroll_component.rb', line 3 def initialize(pagy:, resource_class:, current_params: {}, current_path:) @pagy = pagy @resource_class = resource_class @current_params = current_params @current_path = current_path end |
Instance Method Details
#view_template ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'app/components/easy_admin/infinite_scroll_component.rb', line 10 def view_template div( id: "infinite-scroll-container", class: "infinite-scroll-container mt-6", data: { controller: "infinite-scroll", infinite_scroll_url_value: next_page_url, infinite_scroll_has_more_value: has_more_pages? } ) do div( class: "infinite-scroll-loading bg-gray-50 border border-gray-200 rounded-lg p-6 text-center hidden", data: { infinite_scroll_target: "loading" } ) do div(class: "loading-spinner mb-3") do div(class: "animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500 mx-auto") end div(class: "text-gray-600 text-sm font-medium mb-1") { "Loading more #{@resource_class.title.downcase}..." } div(class: "text-gray-500 text-xs") { "Scroll down or click 'Load More' to see additional results" } end # "Load More" button - simple and clean if has_more_pages? div( class: "infinite-scroll-load-more mt-6 text-center", data: { infinite_scroll_target: "loadMore" } ) do a( href: next_page_url, class: "inline-flex items-center justify-center px-8 py-3 bg-blue-600 text-white text-sm font-medium rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-colors duration-200", data: { action: "click->infinite-scroll#loadMore" } ) do span { "Load More" } end end end # End message when no more pages - always show for infinite scroll unless has_more_pages? div( class: "infinite-scroll-end mt-6 text-center bg-gray-50 border border-gray-200 rounded-lg p-6", data: { infinite_scroll_target: "end" } ) do div(class: "mb-3") do div(class: "w-12 h-12 mx-auto bg-gray-200 rounded-full flex items-center justify-center mb-3") do unsafe_raw '<svg class="w-6 h-6 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24"> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path> </svg>' end end div(class: "text-gray-700 font-medium mb-1") { "All records loaded" } div(class: "text-gray-400 text-xs") { "You've reached the end of the list" } end end end end |