Class: Anchor::InputComponent
- Defined in:
- app/components/anchor/input_component.rb
Constant Summary collapse
- ICON_CLASSES =
%w( absolute top-1/2 -translate-y-1/2 text-secondary pointer-events-none ).freeze
- INPUT_CLASSES =
%w( form-input text-base min-h-[40px] resize-none block w-full rounded border ).freeze
Constants included from ViewHelper
Instance Attribute Summary collapse
-
#attribute ⇒ Object
readonly
Returns the value of attribute attribute.
-
#ending_icon ⇒ Object
readonly
Returns the value of attribute ending_icon.
-
#starting_icon ⇒ Object
readonly
Returns the value of attribute starting_icon.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(form_builder:, attribute:, type:, starting_icon: nil, ending_icon: nil, **kwargs) ⇒ InputComponent
constructor
A new instance of InputComponent.
- #options ⇒ Object
Methods inherited from Component
Methods included from ViewHelper
#anchor_form_with, #anchor_svg, #deep_blank?, #merge_options, #popover_trigger_attributes
Methods included from FetchOrFallbackHelper
Constructor Details
#initialize(form_builder:, attribute:, type:, starting_icon: nil, ending_icon: nil, **kwargs) ⇒ InputComponent
Returns a new instance of InputComponent.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/components/anchor/input_component.rb', line 22 def initialize( form_builder:, attribute:, type:, starting_icon: nil, ending_icon: nil, **kwargs ) @form_builder = form_builder @attribute = attribute @type = type @starting_icon = starting_icon @ending_icon = ending_icon super(**kwargs) end |
Instance Attribute Details
#attribute ⇒ Object (readonly)
Returns the value of attribute attribute.
39 40 41 |
# File 'app/components/anchor/input_component.rb', line 39 def attribute @attribute end |
#ending_icon ⇒ Object (readonly)
Returns the value of attribute ending_icon.
39 40 41 |
# File 'app/components/anchor/input_component.rb', line 39 def ending_icon @ending_icon end |
#starting_icon ⇒ Object (readonly)
Returns the value of attribute starting_icon.
39 40 41 |
# File 'app/components/anchor/input_component.rb', line 39 def starting_icon @starting_icon end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
39 40 41 |
# File 'app/components/anchor/input_component.rb', line 39 def type @type end |
Instance Method Details
#options ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'app/components/anchor/input_component.rb', line 41 def { class: class_names( INPUT_CLASSES, "pl-11" => starting_icon?, "pr-11" => ending_icon? ), data: { testid: }, } end |