Class: Fluxbit::Form::HelpTextComponent

Inherits:
Component
  • Object
show all
Includes:
Config::Form::HelpTextComponent
Defined in:
app/components/fluxbit/form/help_text_component.rb

Overview

The ‘Fluxbit::HelpTextComponent` is a component for rendering customizable helper text elements. It extends `Fluxbit::Component` and provides options for configuring the helper text’s appearance and behavior. You can control the helper text’s color and other attributes. The helper text can have various styles applied based on the provided properties.

Examples:

Basic usage

= render Fluxbit::Form::HelpTextComponent.new { "Your password must be at least 8 characters." }

See Also:

  • For detailed documentation and examples.

Instance Method Summary collapse

Constructor Details

#initialize(color: nil, **props) ⇒ HelpTextComponent

Initializes the helper text component with the given properties.

Parameters:

  • color (Symbol) (defaults to: nil)

    (:default) The color of the helper text.

  • props (Hash)

    The properties to customize the helper text.

Options Hash (**props):

  • **props (Hash)

    Remaining options declared as HTML attributes, applied to the helper text element.



20
21
22
23
24
25
# File 'app/components/fluxbit/form/help_text_component.rb', line 20

def initialize(color: nil, **props)
  super
  @props = props
  color = @@color unless color.in? %i[info default success failure warning]
  add class: style(color), to: @props, first_element: true
end

Instance Method Details

#callObject



31
32
33
# File 'app/components/fluxbit/form/help_text_component.rb', line 31

def call
   :p, content, @props
end

#style(color) ⇒ Object



27
28
29
# File 'app/components/fluxbit/form/help_text_component.rb', line 27

def style(color)
  styles[:base] + styles[:colors][color]
end