Class: Daisy::DataInput::TextAreaComponent
- Inherits:
-
LocoMotion::BaseComponent
- Object
- ViewComponent::Base
- LocoMotion::BaseComponent
- Daisy::DataInput::TextAreaComponent
- Includes:
- LocoMotion::Concerns::AriableComponent
- Defined in:
- app/components/daisy/data_input/text_area_component.rb
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
Methods included from LocoMotion::Concerns::InspectableComponent
Constructor Details
#initialize(**kws) ⇒ TextAreaComponent
Instantiate a new TextArea component.
76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'app/components/daisy/data_input/text_area_component.rb', line 76 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.
48 49 50 |
# File 'app/components/daisy/data_input/text_area_component.rb', line 48 def cols @cols end |
#disabled ⇒ Object (readonly)
Returns the value of attribute disabled.
48 49 50 |
# File 'app/components/daisy/data_input/text_area_component.rb', line 48 def disabled @disabled end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
48 49 50 |
# File 'app/components/daisy/data_input/text_area_component.rb', line 48 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
48 49 50 |
# File 'app/components/daisy/data_input/text_area_component.rb', line 48 def name @name end |
#placeholder ⇒ Object (readonly)
Returns the value of attribute placeholder.
48 49 50 |
# File 'app/components/daisy/data_input/text_area_component.rb', line 48 def placeholder @placeholder end |
#readonly ⇒ Object (readonly)
Returns the value of attribute readonly.
48 49 50 |
# File 'app/components/daisy/data_input/text_area_component.rb', line 48 def readonly @readonly end |
#required ⇒ Object (readonly)
Returns the value of attribute required.
48 49 50 |
# File 'app/components/daisy/data_input/text_area_component.rb', line 48 def required @required end |
#rows ⇒ Object (readonly)
Returns the value of attribute rows.
48 49 50 |
# File 'app/components/daisy/data_input/text_area_component.rb', line 48 def rows @rows end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
48 49 50 |
# File 'app/components/daisy/data_input/text_area_component.rb', line 48 def value @value end |
Instance Method Details
#before_render ⇒ Object
Calls the #setup_component method before rendering the component.
93 94 95 96 97 |
# File 'app/components/daisy/data_input/text_area_component.rb', line 93 def before_render super setup_component end |
#call ⇒ Object
Renders the component with its value as content.
126 127 128 129 130 131 132 |
# File 'app/components/daisy/data_input/text_area_component.rb', line 126 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.
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'app/components/daisy/data_input/text_area_component.rb', line 106 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 |