Class: Flowbite::Input::Hint

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/flowbite/input/hint.rb

Constant Summary collapse

STATES =
[
  DEFAULT = :default
].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attribute:, form:, class: nil, options: {}) ⇒ Hint

Returns a new instance of Hint.



35
36
37
38
39
40
41
# File 'app/components/flowbite/input/hint.rb', line 35

def initialize(attribute:, form:, class: nil, options: {})
  @attribute = attribute
  @class = Array.wrap(binding.local_variable_get(:class))
  @form = form
  @options = options
  @object = form.object
end

Class Method Details

.classes(state: :default, style: :default) ⇒ Object



11
12
13
14
# File 'app/components/flowbite/input/hint.rb', line 11

def classes(state: :default, style: :default)
  style = styles.fetch(style)
  style.fetch(state)
end

.stylesObject



16
17
18
19
20
21
22
23
24
# File 'app/components/flowbite/input/hint.rb', line 16

def styles
  Flowbite::Styles.from_hash(
    {
      default: {
        default: ["mt-2.5", "text-sm", "text-body"]
      }
    }.freeze
  )
end

Instance Method Details

#callObject



27
28
29
30
31
32
33
# File 'app/components/flowbite/input/hint.rb', line 27

def call
  tag.p(
    content,
    class: classes,
    **@options
  )
end

#classesObject

Returns an array with the CSS classes to apply to the label element



44
45
46
# File 'app/components/flowbite/input/hint.rb', line 44

def classes
  self.class.classes(state: state) + @class
end