Class: TextComponent
- Defined in:
- app/components/text_component.rb
Overview
Text — inline text container. Merges the holy spec primitive with Fomantic-UI text.
Usage:
Text { text "Hello" }
Text(size: :sm, style: :secondary) { text "Muted text" }
Text(weight: :bold, color: :red) { text "Important" }
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
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'app/components/text_component.rb', line 16 def to_s has_fui_class = color || size_fui fui_classes = if has_fui_class class_names( "ui", color, size_fui, "text" ) end style_parts = [ (style && "text-#{style}"), (size_css && "font-size:#{size_css}"), (weight && "font-weight:#{weight_value}") ].compact opts = {} opts[:class] = fui_classes if fui_classes opts[:style] = style_parts.join(";") if style_parts.any? tag.span(**opts) { @content } end |