Class: ListItemComponent

Inherits:
Component show all
Defined in:
app/components/list_item_component.rb

Overview

ListItem — individual item within a List.

Usage:

List {
  ListItem { text "Apples" }
  ListItem(icon: "users") { ListContent { text "Fomantic UI" } }
  ListItem(href: "#") { text "Link item" }
}

Constant Summary

Constants inherited from Component

Component::HTML_OPTIONS

Instance Method Summary collapse

Methods inherited from Component

default, #initialize, #render_in, slot

Constructor Details

This class inherits a constructor from Component

Instance Method Details

#to_sObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/components/list_item_component.rb', line 19

def to_s
  classes = class_names(
    { "active" => active, "disabled" => disabled },
    "item"
  )

  icon_el = icon ? tag.i(class: "#{icon} icon") : nil
  opts = { class: classes }
  opts[:"data-value"] = value if value

  inner = safe_join([ icon_el, @content ])

  if href
    tag.a(inner, **merge_html_options(**opts, href: href))
  else
    tag.div(inner, **merge_html_options(**opts))
  end
end