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:, options: {}) ⇒ Hint

Returns a new instance of Hint.



33
34
35
36
37
38
# File 'app/components/flowbite/input/hint.rb', line 33

def initialize(attribute:, form:, options: {})
  @attribute = attribute
  @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
# File 'app/components/flowbite/input/hint.rb', line 16

def styles
  {
    default: Flowbite::Style.new(
      default: ["mt-2", "text-sm", "text-gray-500", "dark:text-gray-400"]
    )
  }.freeze
end

Instance Method Details

#callObject



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

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

#classesObject

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



41
42
43
# File 'app/components/flowbite/input/hint.rb', line 41

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