Class: ElementComponent::Components::Nav

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

Constant Summary collapse

VALID_TYPES =
%i[tabs pills underline].freeze

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(type: nil, fill: false, justified: false, vertical: false, **attributes, &block) ⇒ Nav

Returns a new instance of Nav.



11
12
13
14
15
16
17
18
19
20
# File 'lib/element_component/components/nav.rb', line 11

def initialize(type: nil, fill: false, justified: false, vertical: false, **attributes, &block)
  super("ul", &block)

  add_attribute(class: "nav")
  add_attribute(class: "nav-#{type}") if type
  add_attribute(class: "nav-fill") if fill
  add_attribute(class: "nav-justified") if justified
  add_attribute(class: "flex-column") if vertical
  add_attribute(attributes) unless attributes.empty?
end