Class: TagComponent
- Includes:
- Attachable
- Defined in:
- app/components/tag_component.rb
Overview
Tag — colored labels, tags, and badges.
Renders Fomantic-UI’s “label” element. Named ‘Tag` in the DSL to avoid collision with Rails’ ‘label` form helper.
Usage:
Tag(color: :blue) { "New" }
Tag(tag_style: true, color: :teal) { "Featured" }
Tag(ribbon: true, color: :red) { "Sale" }
Tag(icon: "mail", detail: "23") { "Mail" }
Constant Summary
Constants inherited from Component
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_s ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/components/tag_component.rb', line 35 def to_s classes = class_names( "ui", color, size, pointing && "#{pointing} pointing", corner && "#{corner} corner", { "attached" => attached, "ribbon" => ribbon, "circular" => circular, "floating" => floating, "tag" => tag_style, "image" => image, "basic" => basic, "horizontal" => horizontal, "inverted" => inverted, "fluid" => fluid, "disabled" => disabled, "empty" => empty }, "label" ) icon_el = icon ? tag.i(class: "#{icon} icon") : nil detail_el = detail ? tag.div(class: "detail") { detail } : nil tag.div(**(class: classes)) { safe_join([ icon_el, @content, detail_el ]) } end |