Class: ViewComponent::InputComponent::DatePickerComponent
- Inherits:
-
Object
- Object
- ViewComponent::InputComponent::DatePickerComponent
- Includes:
- ComponentHelper
- Defined in:
- app/helpers/view_component/input_component/date_picker_component.rb
Constant Summary collapse
- DATE_PICKER_SIZES =
%w[md lg].freeze
- DATE_PICKER_SIZE_STYLE =
{ md: 'input-text-div-base-md main-text-md-normal', lg: 'input-text-div-base-lg main-text-lg-medium' }.freeze
- LABEL_STYLES =
{ md: 'input-text-label-md general-text-sm-normal', lg: 'input-text-label-lg general-text-md-normal' }.freeze
- SUPPORT_TEXT_STYLES =
{ md: 'input-text-subtext-md general-text-sm-normal', lg: 'input-text-subtext-lg general-text-md-normal' }.freeze
- ICON_SIZE =
{ md: 'input-text-icon-md', lg: 'input-text-icon-lg' }.freeze
Instance Attribute Summary collapse
-
#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.
-
#label ⇒ Object
Returns the value of attribute label.
-
#name ⇒ Object
Returns the value of attribute name.
-
#placeholder ⇒ Object
Returns the value of attribute placeholder.
-
#size ⇒ Object
Returns the value of attribute size.
-
#support_text ⇒ Object
Returns the value of attribute support_text.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
- #date_picker_style ⇒ Object
- #icon_style ⇒ Object
- #icon_wrapper_style ⇒ Object
-
#initialize(form:, name:, label:, value:, placeholder:, size:, support_text:, error:, disabled:, html_options:) ⇒ DatePickerComponent
constructor
A new instance of DatePickerComponent.
- #label_style ⇒ Object
- #support_text_style ⇒ Object
Methods included from ComponentHelper
Constructor Details
#initialize(form:, name:, label:, value:, placeholder:, size:, support_text:, error:, disabled:, html_options:) ⇒ DatePickerComponent
Returns a new instance of DatePickerComponent.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'app/helpers/view_component/input_component/date_picker_component.rb', line 33 def initialize(form:, name:, label:, value:, placeholder:, size:, support_text:, error:, disabled:, html_options:) raise "Incorrect date picker size: #{size}" unless DATE_PICKER_SIZES.include?(size) = resolve_error(form, name, error) self.form = form self.name = name self.label = label self.value = value self.placeholder = placeholder self.size = size self.support_text = (.presence || support_text) self.error = self.disabled = disabled self. = self.[:disabled] = true if disabled self.[:class] = date_picker_style end |
Instance Attribute Details
#disabled ⇒ Object
Returns the value of attribute disabled.
30 31 32 |
# File 'app/helpers/view_component/input_component/date_picker_component.rb', line 30 def disabled @disabled end |
#error ⇒ Object
Returns the value of attribute error.
30 31 32 |
# File 'app/helpers/view_component/input_component/date_picker_component.rb', line 30 def error @error end |
#form ⇒ Object
Returns the value of attribute form.
30 31 32 |
# File 'app/helpers/view_component/input_component/date_picker_component.rb', line 30 def form @form end |
#html_options ⇒ Object
Returns the value of attribute html_options.
30 31 32 |
# File 'app/helpers/view_component/input_component/date_picker_component.rb', line 30 def end |
#label ⇒ Object
Returns the value of attribute label.
30 31 32 |
# File 'app/helpers/view_component/input_component/date_picker_component.rb', line 30 def label @label end |
#name ⇒ Object
Returns the value of attribute name.
30 31 32 |
# File 'app/helpers/view_component/input_component/date_picker_component.rb', line 30 def name @name end |
#placeholder ⇒ Object
Returns the value of attribute placeholder.
30 31 32 |
# File 'app/helpers/view_component/input_component/date_picker_component.rb', line 30 def placeholder @placeholder end |
#size ⇒ Object
Returns the value of attribute size.
30 31 32 |
# File 'app/helpers/view_component/input_component/date_picker_component.rb', line 30 def size @size end |
#support_text ⇒ Object
Returns the value of attribute support_text.
30 31 32 |
# File 'app/helpers/view_component/input_component/date_picker_component.rb', line 30 def support_text @support_text end |
#value ⇒ Object
Returns the value of attribute value.
30 31 32 |
# File 'app/helpers/view_component/input_component/date_picker_component.rb', line 30 def value @value end |
Instance Method Details
#date_picker_style ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'app/helpers/view_component/input_component/date_picker_component.rb', line 53 def date_picker_style base = ['w-full border'] size_style = DATE_PICKER_SIZE_STYLE[size.to_sym] color_style = if disabled 'border-disabled-color text-disabled-color placeholder-disabled-color' elsif error.present? 'text-danger focus:text-danger-dark border-danger focus:border-danger focus:ring-danger' else 'text-letter-color-light border-slate-grey-50 focus:ring-primary' end class_list(base, size_style, color_style) end |
#icon_style ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'app/helpers/view_component/input_component/date_picker_component.rb', line 112 def icon_style size_style = ICON_SIZE[size.to_sym] color_style = if disabled 'text-disabled-color' elsif error.present? 'text-danger' else 'text-letter-color-light hover:text-primary' end class_list([], size_style, color_style) end |
#icon_wrapper_style ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'app/helpers/view_component/input_component/date_picker_component.rb', line 99 def icon_wrapper_style base = ['date-picker-icon-wrapper'] disabled_style = if disabled 'date-picker-icon-wrapper-disabled' else '' end class_list(base, disabled_style) end |
#label_style ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'app/helpers/view_component/input_component/date_picker_component.rb', line 69 def label_style size_style = LABEL_STYLES[size.to_sym] color_style = if disabled 'text-disabled-color' elsif error.present? 'text-danger-dark' else 'text-letter-color-light group-focus-within:text-primary' end class_list([], size_style, color_style) end |
#support_text_style ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'app/helpers/view_component/input_component/date_picker_component.rb', line 84 def support_text_style size_style = SUPPORT_TEXT_STYLES[size.to_sym] color_style = if disabled 'text-disabled-color' elsif error.present? 'text-danger-dark' else 'text-letter-color-light' end class_list([], size_style, color_style) end |