Class: Ui::Dropdown::Component::Item

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(href: nil, **html_attrs) ⇒ Item

Returns a new instance of Item.



29
30
31
32
33
# File 'lib/uikit_rails/templates/components/dropdown/component.rb', line 29

def initialize(href: nil, **html_attrs)
  @href = href
  @html_attrs = html_attrs
  super()
end

Instance Attribute Details

#hrefObject (readonly)

Returns the value of attribute href.



27
28
29
# File 'lib/uikit_rails/templates/components/dropdown/component.rb', line 27

def href
  @href
end

#html_attrsObject (readonly)

Returns the value of attribute html_attrs.



27
28
29
# File 'lib/uikit_rails/templates/components/dropdown/component.rb', line 27

def html_attrs
  @html_attrs
end

Instance Method Details

#callObject



35
36
37
38
39
# File 'lib/uikit_rails/templates/components/dropdown/component.rb', line 35

def call
  tag_name = href ? :a : :div
  attrs = merge_attrs({ class: "ui-dropdown__item", href: href, role: "menuitem" }.compact, html_attrs)
  (tag_name, content, **attrs)
end