Class: ElementComponent::Components::NavLink
- Defined in:
- lib/element_component/components/nav/link.rb
Instance Attribute Summary
Attributes inherited from Element
#attributes, #contents, #element, #html
Instance Method Summary collapse
-
#initialize(href: "#", active: false, disabled: false, **attributes, &block) ⇒ NavLink
constructor
A new instance of NavLink.
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(href: "#", active: false, disabled: false, **attributes, &block) ⇒ NavLink
Returns a new instance of NavLink.
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/element_component/components/nav/link.rb', line 6 def initialize(href: "#", active: false, disabled: false, **attributes, &block) super("a", &block) add_attribute(class: "nav-link") add_attribute(class: "active") if active add_attribute(class: "disabled") if disabled add_attribute(href: href) add_attribute("aria-current": "page") if active add_attribute(attributes) unless attributes.empty? end |