-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhint.rb
More file actions
65 lines (57 loc) · 1.44 KB
/
hint.rb
File metadata and controls
65 lines (57 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# frozen_string_literal: true
module Flowbite
class Input
# A hint element for input fields.
#
# Provides additional context or instructions for the user.
#
# See https://flowbite.com/docs/forms/input-field/#helper-text
class Hint < ViewComponent::Base
STATES = [
DEFAULT = :default
].freeze
class << self
def classes(state: :default, style: :default)
style = styles.fetch(style)
style.fetch(state)
end
def styles
Flowbite::Styles.from_hash(
{
default: {
default: ["mt-2.5", "text-sm", "text-body"]
}
}.freeze
)
end
end
def call
tag.p(
content,
class: classes,
**@options
)
end
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
# Returns an array with the CSS classes to apply to the label element
def classes
self.class.classes(state: state) + @class
end
protected
# Returns the state of the label.
#
# See the STATES constant for valid values.
#
# @return [Symbol] the state of the label
def state
DEFAULT
end
end
end
end