Class: ElementComponent::Components::ListGroupItem
- Defined in:
- lib/element_component/components/list_group/item.rb
Constant Summary collapse
- VALID_VARIANTS =
%i[primary secondary success danger warning info light dark].freeze
Instance Attribute Summary
Attributes inherited from Element
#attributes, #contents, #element, #html
Instance Method Summary collapse
-
#initialize(variant: nil, active: false, disabled: false, href: nil, **attributes, &block) ⇒ ListGroupItem
constructor
A new instance of ListGroupItem.
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(variant: nil, active: false, disabled: false, href: nil, **attributes, &block) ⇒ ListGroupItem
Returns a new instance of ListGroupItem.
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/element_component/components/list_group/item.rb', line 8 def initialize(variant: nil, active: false, disabled: false, href: nil, **attributes, &block) tag = href ? "a" : "li" super(tag, &block) add_attribute(class: "list-group-item") add_attribute(class: "list-group-item-action") if href || tag == "a" add_attribute(class: "list-group-item-#{variant}") if variant add_attribute(class: "active") if active add_attribute(class: "disabled") if disabled add_attribute(href: href) if href add_attribute("aria-current": "true") if active add_attribute(attributes) unless attributes.empty? end |