Class: ViewComponent::InputComponent::InputMobileComponent
- Inherits:
-
InputTextComponent
- Object
- InputTextComponent
- ViewComponent::InputComponent::InputMobileComponent
- Defined in:
- app/helpers/view_component/input_component/input_mobile_component.rb
Constant Summary collapse
- CODE_WIDTH =
{ md: 'w-16', lg: 'w-20' }.freeze
- CODE_SELECT_WIDTH =
{ md: 'w-20', lg: 'w-24' }.freeze
- CODE_TEXT =
{ md: 'mobile-code-md', lg: 'mobile-code-lg' }.freeze
Constants inherited from InputTextComponent
ViewComponent::InputComponent::InputTextComponent::ICON_SIZE, ViewComponent::InputComponent::InputTextComponent::INPUT_SIZE_STYLE, ViewComponent::InputComponent::InputTextComponent::INPUT_WRAPPER_STYLES, ViewComponent::InputComponent::InputTextComponent::LABEL_STYLES, ViewComponent::InputComponent::InputTextComponent::SUBTEXT_SIZE
Instance Attribute Summary collapse
-
#code_name ⇒ Object
Returns the value of attribute code_name.
-
#code_value ⇒ Object
Returns the value of attribute code_value.
-
#disabled ⇒ Object
Returns the value of attribute disabled.
-
#error ⇒ Object
Returns the value of attribute error.
-
#form ⇒ Object
Returns the value of attribute form.
-
#html_options ⇒ Object
Returns the value of attribute html_options.
-
#icon_name ⇒ Object
Returns the value of attribute icon_name.
-
#icon_position ⇒ Object
Returns the value of attribute icon_position.
-
#label ⇒ Object
Returns the value of attribute label.
-
#name ⇒ Object
Returns the value of attribute name.
-
#size ⇒ Object
Returns the value of attribute size.
-
#subtext ⇒ Object
Returns the value of attribute subtext.
-
#type ⇒ Object
Returns the value of attribute type.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #code_selectable? ⇒ Boolean
- #code_wrapper_style ⇒ Object
- #error_style ⇒ Object
-
#initialize(form:, name:, label:, type:, placeholder:, code_value:, value:, subtext:, error:, icon_name:, icon_position:, disabled:, size:, html_options:) ⇒ InputMobileComponent
constructor
A new instance of InputMobileComponent.
- #normal_style ⇒ Object
Methods inherited from InputTextComponent
#icon_size, #icon_style, #input_style, #input_wrapper_style, #label_style, #placeholder, #placeholder=, #subtext_style
Methods included from ComponentHelper
Constructor Details
#initialize(form:, name:, label:, type:, placeholder:, code_value:, value:, subtext:, error:, icon_name:, icon_position:, disabled:, size:, html_options:) ⇒ InputMobileComponent
Returns a new instance of InputMobileComponent.
24 25 26 27 28 29 30 |
# File 'app/helpers/view_component/input_component/input_mobile_component.rb', line 24 def initialize(form:, name:, label:, type:, placeholder:, code_value:, value:, subtext:, error:, icon_name:, icon_position:, disabled:, size:, html_options:) super(form:, name:, label:, type:, placeholder:, value:, subtext:, error:, icon_name:, icon_position:, disabled:, size:, html_options:) self.code_value = code_value self.code_name = name.present? ? "#{name}_code" : 'code' end |
Instance Attribute Details
#code_name ⇒ Object
Returns the value of attribute code_name.
21 22 23 |
# File 'app/helpers/view_component/input_component/input_mobile_component.rb', line 21 def code_name @code_name end |
#code_value ⇒ Object
Returns the value of attribute code_value.
21 22 23 |
# File 'app/helpers/view_component/input_component/input_mobile_component.rb', line 21 def code_value @code_value end |
#disabled ⇒ Object
Returns the value of attribute disabled.
21 22 23 |
# File 'app/helpers/view_component/input_component/input_mobile_component.rb', line 21 def disabled @disabled end |
#error ⇒ Object
Returns the value of attribute error.
21 22 23 |
# File 'app/helpers/view_component/input_component/input_mobile_component.rb', line 21 def error @error end |
#form ⇒ Object
Returns the value of attribute form.
21 22 23 |
# File 'app/helpers/view_component/input_component/input_mobile_component.rb', line 21 def form @form end |
#html_options ⇒ Object
Returns the value of attribute html_options.
21 22 23 |
# File 'app/helpers/view_component/input_component/input_mobile_component.rb', line 21 def end |
#icon_name ⇒ Object
Returns the value of attribute icon_name.
21 22 23 |
# File 'app/helpers/view_component/input_component/input_mobile_component.rb', line 21 def icon_name @icon_name end |
#icon_position ⇒ Object
Returns the value of attribute icon_position.
21 22 23 |
# File 'app/helpers/view_component/input_component/input_mobile_component.rb', line 21 def icon_position @icon_position end |
#label ⇒ Object
Returns the value of attribute label.
21 22 23 |
# File 'app/helpers/view_component/input_component/input_mobile_component.rb', line 21 def label @label end |
#name ⇒ Object
Returns the value of attribute name.
21 22 23 |
# File 'app/helpers/view_component/input_component/input_mobile_component.rb', line 21 def name @name end |
#size ⇒ Object
Returns the value of attribute size.
21 22 23 |
# File 'app/helpers/view_component/input_component/input_mobile_component.rb', line 21 def size @size end |
#subtext ⇒ Object
Returns the value of attribute subtext.
21 22 23 |
# File 'app/helpers/view_component/input_component/input_mobile_component.rb', line 21 def subtext @subtext end |
#type ⇒ Object
Returns the value of attribute type.
21 22 23 |
# File 'app/helpers/view_component/input_component/input_mobile_component.rb', line 21 def type @type end |
#value ⇒ Object
Returns the value of attribute value.
21 22 23 |
# File 'app/helpers/view_component/input_component/input_mobile_component.rb', line 21 def value @value end |
Instance Method Details
#code_selectable? ⇒ Boolean
32 33 34 |
# File 'app/helpers/view_component/input_component/input_mobile_component.rb', line 32 def code_selectable? code_value.blank? end |
#code_wrapper_style ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'app/helpers/view_component/input_component/input_mobile_component.rb', line 49 def code_wrapper_style base = ['mobile-code-base'] color_style = if disabled 'border-disabled-color' elsif error.present? error_style elsif code_selectable? 'border-slate-grey-50 group-focus:ring-primary group-focus:border-primary' else 'border-slate-grey-50 group-focus-within:border-primary' end size_style = INPUT_WRAPPER_STYLES[size.to_sym] code_width = code_selectable? ? CODE_SELECT_WIDTH[size.to_sym] : CODE_WIDTH[size.to_sym] code_text = CODE_TEXT[size.to_sym] [class_list(base, size_style, color_style), code_width, code_text].join(' ') end |
#error_style ⇒ Object
36 37 38 39 40 41 |
# File 'app/helpers/view_component/input_component/input_mobile_component.rb', line 36 def error_style base = ['text-danger border-danger-dark', 'group-focus-within:ring-danger-dark group-focus-within:border-danger-dark'] base << 'group-focus-within:ring-1' unless code_selectable? base.join(' ') end |
#normal_style ⇒ Object
43 44 45 46 47 |
# File 'app/helpers/view_component/input_component/input_mobile_component.rb', line 43 def normal_style base = ['border-slate-grey-50 group-focus-within:border-primary'] base << 'group-focus-within:ring-primary' if code_selectable? base.join(' ') end |