Class: BetterUi::General::Field::Component

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/better_ui/general/field/component.rb

Constant Summary collapse

BASE_CLASSES =
"flex flex-col space-y-2"
LABEL_CLASSES =
"text-sm font-medium text-gray-700"
REQUIRED_CLASSES =
"text-red-500 ml-1"
ERROR_CLASSES =
"text-sm text-red-600 mt-1"
HELP_TEXT_CLASSES =
"text-sm text-gray-500 mt-1"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text:, name:, required: false, error: nil, help_text: nil, id: nil) ⇒ Component

Returns a new instance of Component.



17
18
19
20
21
22
23
24
25
# File 'app/components/better_ui/general/field/component.rb', line 17

def initialize(text:, name:, required: false, error: nil, help_text: nil, id: nil)
  @text = text
  @name = name
  @required = required
  @error = error
  @help_text = help_text
  @id = id
  super()
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



7
8
9
# File 'app/components/better_ui/general/field/component.rb', line 7

def error
  @error
end

#help_textObject (readonly)

Returns the value of attribute help_text.



7
8
9
# File 'app/components/better_ui/general/field/component.rb', line 7

def help_text
  @help_text
end

#idObject (readonly)

Returns the value of attribute id.



7
8
9
# File 'app/components/better_ui/general/field/component.rb', line 7

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'app/components/better_ui/general/field/component.rb', line 7

def name
  @name
end

#requiredObject (readonly)

Returns the value of attribute required.



7
8
9
# File 'app/components/better_ui/general/field/component.rb', line 7

def required
  @required
end

#textObject (readonly)

Returns the value of attribute text.



7
8
9
# File 'app/components/better_ui/general/field/component.rb', line 7

def text
  @text
end