Class: Ui::Pagination::Component::PrevItem

Inherits:
BaseComponent
  • Object
show all
Defined in:
lib/uikit_rails/templates/components/pagination/component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(href: "#", disabled: false, **html_attrs) ⇒ PrevItem

Returns a new instance of PrevItem.



46
47
48
49
50
51
# File 'lib/uikit_rails/templates/components/pagination/component.rb', line 46

def initialize(href: "#", disabled: false, **html_attrs)
  @href = href
  @disabled = disabled
  @html_attrs = html_attrs
  super()
end

Instance Attribute Details

#disabledObject (readonly)

Returns the value of attribute disabled.



44
45
46
# File 'lib/uikit_rails/templates/components/pagination/component.rb', line 44

def disabled
  @disabled
end

#hrefObject (readonly)

Returns the value of attribute href.



44
45
46
# File 'lib/uikit_rails/templates/components/pagination/component.rb', line 44

def href
  @href
end

#html_attrsObject (readonly)

Returns the value of attribute html_attrs.



44
45
46
# File 'lib/uikit_rails/templates/components/pagination/component.rb', line 44

def html_attrs
  @html_attrs
end

Instance Method Details

#callObject



53
54
55
56
57
58
59
60
# File 'lib/uikit_rails/templates/components/pagination/component.rb', line 53

def call
  classes = class_names("ui-pagination__item ui-pagination__prev", "ui-pagination__item--disabled": disabled)
  if disabled
    (:span, content.presence || "Previous", class: classes, "aria-disabled": "true", **html_attrs)
  else
    (:a, content.presence || "Previous", class: classes, href: href, **html_attrs)
  end
end