Class: Primer::Forms::Button

Inherits:
BaseComponent show all
Defined in:
lib/primer/forms/button.rb

Overview

:nodoc:

Defined Under Namespace

Modules: ButtonAttributeGenerator

Instance Attribute Summary

Attributes included from ActsAsComponent

#template_root_path

Instance Method Summary collapse

Methods inherited from BaseComponent

#content, inherited, #input?, #perform_render, #render?, #to_component, #type

Methods included from ActsAsComponent

#compile!, extended, #renders_templates

Methods included from ClassNameHelper

#class_names

Constructor Details

#initialize(input:, type: :button) ⇒ Button

Returns a new instance of Button.



33
34
35
36
37
38
39
40
41
42
# File 'lib/primer/forms/button.rb', line 33

def initialize(input:, type: :button)
  @input = input
  @type = type

  @input.add_input_classes("FormField-input flex-self-start")
  @input.merge_input_arguments!(tag_attributes.deep_symbolize_keys)

  # rails uses a string for this, but PVC wants a symbol
  @input.merge_input_arguments!(type: type.to_sym)
end

Instance Method Details

#input_argumentsObject



44
45
46
47
48
49
50
51
52
# File 'lib/primer/forms/button.rb', line 44

def input_arguments
  @input_arguments ||= @input.input_arguments.deep_dup.tap do |args|
    # rails uses :class but PVC wants :classes
    args[:classes] = class_names(
      args[:classes],
      args.delete(:class)
    )
  end
end