Class: ElementComponent::Components::PageItem

Inherits:
Element
  • Object
show all
Defined in:
lib/element_component/components/pagination/item.rb

Instance Attribute Summary

Attributes inherited from Element

#attributes, #contents, #element, #html

Instance Method Summary collapse

Methods inherited from Element

#add_attribute, #add_attribute!, #add_content, #add_content!, #new_element, #remove_attribute, #remove_attribute_value, #render, #reset_attributes!, #reset_contents!

Constructor Details

#initialize(active: false, disabled: false, href: "#", **attributes, &block) ⇒ PageItem

Returns a new instance of PageItem.



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/element_component/components/pagination/item.rb', line 6

def initialize(active: false, disabled: false, href: "#", **attributes, &block)
  super("li", &block)

  add_attribute(class: "page-item")
  add_attribute(class: "active") if active
  add_attribute(class: "disabled") if disabled
  add_attribute("aria-current": "page") if active
  add_attribute(attributes) unless attributes.empty?

  @page_href = href
  @page_disabled = disabled
end