Class: Flowbite::Input::ValidationError

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

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(class: nil) ⇒ ValidationError

Returns a new instance of ValidationError.



29
30
31
# File 'app/components/flowbite/input/validation_error.rb', line 29

def initialize(class: nil)
  @class = Array.wrap(binding.local_variable_get(:class))
end

Class Method Details

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



7
8
9
10
# File 'app/components/flowbite/input/validation_error.rb', line 7

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

.stylesObject

rubocop:disable Layout/LineLength



13
14
15
16
17
18
19
20
21
# File 'app/components/flowbite/input/validation_error.rb', line 13

def styles
  Flowbite::Styles.from_hash(
    {
      default: {
        default: ["mt-2", "text-sm", "text-red-600", "dark:text-red-500"]
      }
    }.freeze
  )
end

Instance Method Details

#callObject



25
26
27
# File 'app/components/flowbite/input/validation_error.rb', line 25

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