Class: Fluxbit::TextComponent
- Includes:
- Config::TextComponent
- Defined in:
- app/components/fluxbit/text_component.rb
Overview
The ‘Fluxbit::TextComponent` is a component for rendering customizable text elements. It extends `Fluxbit::Component` and provides options for configuring the text’s appearance and behavior. You can control the text’s tag, styles, and other attributes. The text can be rendered as different HTML tags (e.g., span, div) and can have various styles applied based on the provided properties.
Constant Summary
Constants inherited from Component
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(**props) ⇒ TextComponent
constructor
Initializes the text component with the given properties.
Methods inherited from Component
#add, #add_popover_or_tooltip, #anyicon, #element_name, #fx_id, #options, #random_id, #remove_class, #render_popover_or_tooltip, #target
Constructor Details
#initialize(**props) ⇒ TextComponent
Initializes the text component with the given properties.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'app/components/fluxbit/text_component.rb', line 16 def initialize(**props) super @props = props.compact @as = @props.delete(:as) || :span styles.each do |style_type, style_values| if @props.key?(style_type) element = @props.delete(style_type) if style_values.is_a?(Array) add(class: style_values[element.to_i], to: @props) else add(class: style_values[element.to_sym], to: @props) if style_values.key?(element.to_sym) end end end end |
Instance Method Details
#call ⇒ Object
33 34 35 |
# File 'app/components/fluxbit/text_component.rb', line 33 def call content_tag @as, content, @props end |