Class: Daisy::DataInput::TextAreaComponent
- Inherits:
-
LocoMotion::BaseComponent
- Object
- ViewComponent::Base
- LocoMotion::BaseComponent
- Daisy::DataInput::TextAreaComponent
- Defined in:
- app/components/daisy/data_input/text_area_component.rb
Overview
Text areas have a border by default. Use ‘textarea-ghost` to remove the border.
The TextArea component renders a DaisyUI styled textarea field. It can be used standalone or with a form builder, and supports various styling options and states.
Constant Summary
Constants inherited from LocoMotion::BaseComponent
LocoMotion::BaseComponent::EMPTY_PART_IGNORED_TAGS, LocoMotion::BaseComponent::SELF_CLOSING_TAGS
Instance Attribute Summary collapse
-
#cols ⇒ Object
readonly
Returns the value of attribute cols.
-
#disabled ⇒ Object
readonly
Returns the value of attribute disabled.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#placeholder ⇒ Object
readonly
Returns the value of attribute placeholder.
-
#readonly ⇒ Object
readonly
Returns the value of attribute readonly.
-
#required ⇒ Object
readonly
Returns the value of attribute required.
-
#rows ⇒ Object
readonly
Returns the value of attribute rows.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Attributes inherited from LocoMotion::BaseComponent
Instance Method Summary collapse
-
#before_render ⇒ Object
Calls the #setup_component method before rendering the component.
-
#call ⇒ Object
Renders the component with its value as content.
-
#initialize(**kws) ⇒ TextAreaComponent
constructor
Instantiate a new TextArea component.
-
#setup_component ⇒ Object
Sets up the component by configuring the tag name, CSS classes, and HTML attributes.
Methods inherited from LocoMotion::BaseComponent
build, #component_ref, #config_option, #cssify, define_modifier, define_modifiers, define_part, define_parts, define_size, define_sizes, #empty_part_content, #inspect, #part, register_component_initializer, register_component_setup, #rendered_css, #rendered_data, #rendered_html, #rendered_stimulus_controllers, #rendered_tag_name, renders_many, renders_one, set_component_name, #set_loco_parent, #strip_spaces
Constructor Details
#initialize(**kws) ⇒ TextAreaComponent
Instantiate a new TextArea component.
72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'app/components/daisy/data_input/text_area_component.rb', line 72 def initialize(**kws) super @name = config_option(:name) @id = config_option(:id) @value = config_option(:value, nil) @placeholder = config_option(:placeholder, nil) @rows = config_option(:rows, 4) @cols = config_option(:cols, nil) @disabled = config_option(:disabled, false) @required = config_option(:required, false) @readonly = config_option(:readonly, false) end |
Instance Attribute Details
#cols ⇒ Object (readonly)
Returns the value of attribute cols.
44 45 46 |
# File 'app/components/daisy/data_input/text_area_component.rb', line 44 def cols @cols end |
#disabled ⇒ Object (readonly)
Returns the value of attribute disabled.
44 45 46 |
# File 'app/components/daisy/data_input/text_area_component.rb', line 44 def disabled @disabled end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
44 45 46 |
# File 'app/components/daisy/data_input/text_area_component.rb', line 44 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
44 45 46 |
# File 'app/components/daisy/data_input/text_area_component.rb', line 44 def name @name end |
#placeholder ⇒ Object (readonly)
Returns the value of attribute placeholder.
44 45 46 |
# File 'app/components/daisy/data_input/text_area_component.rb', line 44 def placeholder @placeholder end |
#readonly ⇒ Object (readonly)
Returns the value of attribute readonly.
44 45 46 |
# File 'app/components/daisy/data_input/text_area_component.rb', line 44 def readonly @readonly end |
#required ⇒ Object (readonly)
Returns the value of attribute required.
44 45 46 |
# File 'app/components/daisy/data_input/text_area_component.rb', line 44 def required @required end |
#rows ⇒ Object (readonly)
Returns the value of attribute rows.
44 45 46 |
# File 'app/components/daisy/data_input/text_area_component.rb', line 44 def rows @rows end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
44 45 46 |
# File 'app/components/daisy/data_input/text_area_component.rb', line 44 def value @value end |
Instance Method Details
#before_render ⇒ Object
Calls the #setup_component method before rendering the component.
89 90 91 |
# File 'app/components/daisy/data_input/text_area_component.rb', line 89 def before_render setup_component end |
#call ⇒ Object
Renders the component with its value as content.
120 121 122 123 124 125 126 |
# File 'app/components/daisy/data_input/text_area_component.rb', line 120 def call if @value part(:component) { @value } else part(:component) end end |
#setup_component ⇒ Object
Sets up the component by configuring the tag name, CSS classes, and HTML attributes. Sets the tag to textarea and adds the ‘textarea’ CSS class.
This configures various attributes of the textarea including name, id, value, placeholder, rows, cols, and states like disabled, required, and readonly.
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'app/components/daisy/data_input/text_area_component.rb', line 100 def setup_component set_tag_name(:component, :textarea) add_css(:component, "textarea") add_html(:component, { name: @name, id: @id, placeholder: @placeholder, rows: @rows, cols: @cols, disabled: @disabled, required: @required, readonly: @readonly }) end |