Class: Maglev::Uikit::Form::ColorFieldComponent

Inherits:
ViewComponent::Base
  • Object
show all
Defined in:
app/components/maglev/uikit/form/color_field_component.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, options: {}, html_options: {}) ⇒ ColorFieldComponent

Returns a new instance of ColorFieldComponent.



9
10
11
12
13
# File 'app/components/maglev/uikit/form/color_field_component.rb', line 9

def initialize(name:, options: {}, html_options: {})
  @name = name
  @options = options
  @html_options = html_options
end

Instance Attribute Details

#html_optionsObject (readonly)

Returns the value of attribute html_options.



7
8
9
# File 'app/components/maglev/uikit/form/color_field_component.rb', line 7

def html_options
  @html_options
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'app/components/maglev/uikit/form/color_field_component.rb', line 7

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'app/components/maglev/uikit/form/color_field_component.rb', line 7

def options
  @options
end

Instance Method Details

#dom_idObject



15
16
17
# File 'app/components/maglev/uikit/form/color_field_component.rb', line 15

def dom_id
  name.to_s.parameterize.underscore
end

#errorObject



43
44
45
# File 'app/components/maglev/uikit/form/color_field_component.rb', line 43

def error
  options[:error]
end

#hintObject



39
40
41
# File 'app/components/maglev/uikit/form/color_field_component.rb', line 39

def hint
  options[:hint]
end

#input_actionObject



51
52
53
# File 'app/components/maglev/uikit/form/color_field_component.rb', line 51

def input_action
  @input_action ||= input_data.delete(:action) || {}
end

#input_dataObject



47
48
49
# File 'app/components/maglev/uikit/form/color_field_component.rb', line 47

def input_data
  @input_data ||= html_options.delete(:data) || {}
end

#labelObject



19
20
21
# File 'app/components/maglev/uikit/form/color_field_component.rb', line 19

def label
  options[:label] || name.humanize
end

#presetsObject



31
32
33
# File 'app/components/maglev/uikit/form/color_field_component.rb', line 31

def presets
  options[:presets]
end

#presets?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'app/components/maglev/uikit/form/color_field_component.rb', line 35

def presets?
  presets&.any?
end

#valueObject



23
24
25
# File 'app/components/maglev/uikit/form/color_field_component.rb', line 23

def value
  options[:value]
end

#value?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'app/components/maglev/uikit/form/color_field_component.rb', line 27

def value?
  value.present?
end