Class: Uchi::Flowbite::Input::ValidationError

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/uchi/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.



27
28
29
# File 'app/components/uchi/flowbite/input/validation_error.rb', line 27

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/uchi/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
# File 'app/components/uchi/flowbite/input/validation_error.rb', line 13

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

Instance Method Details

#callObject



23
24
25
# File 'app/components/uchi/flowbite/input/validation_error.rb', line 23

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