Class: Flowbite::Pagination::PreviousLink

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/flowbite/pagination/previous_link.rb

Overview

Renders the "Previous page" link in a pagination component.

This is automatically used by Flowbite::Pagination, but can be used standalone if needed.

Examples:

Standalone usage

<%= render Flowbite::Pagination::PreviousLink.new(url: "/posts?page=1") %>

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url:, disabled: false) ⇒ PreviousLink

Returns a new instance of PreviousLink.



28
29
30
31
# File 'app/components/flowbite/pagination/previous_link.rb', line 28

def initialize(url:, disabled: false)
  @disabled = disabled
  @url = url
end

Instance Attribute Details

#url ⇒ Object (readonly)

Returns the value of attribute url.



26
27
28
# File 'app/components/flowbite/pagination/previous_link.rb', line 26

def url
  @url
end

Class Method Details

.classes(disabled: false) ⇒ Object



19
20
21
22
23
# File 'app/components/flowbite/pagination/previous_link.rb', line 19

def classes(disabled: false)
  classes = ["flex", "items-center", "justify-center", "text-body", "bg-neutral-secondary-medium", "box-border", "border", "border-default-medium", "hover:bg-neutral-tertiary-medium", "hover:text-heading", "font-medium", "rounded-s-base", "text-sm", "w-9", "h-9", "focus:outline-none"]
  classes += ["opacity-50", "cursor-not-allowed"] if disabled
  classes
end

Instance Method Details

#call ⇒ Object



33
34
35
# File 'app/components/flowbite/pagination/previous_link.rb', line 33

def call
  (:li) { render_link }
end

#disabled? ⇒ Boolean

Returns:

  • (Boolean)


37
38
39
# File 'app/components/flowbite/pagination/previous_link.rb', line 37

def disabled?
  !!@disabled
end