Method: ERBLint::Linters::ArgumentMappers::Button#attribute_to_args

Defined in:
lib/primer/view_components/linters/argument_mappers/button.rb

#attribute_to_args(attribute) ⇒ Object

[View source]

34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/primer/view_components/linters/argument_mappers/button.rb', line 34

def attribute_to_args(attribute)
  attr_name = attribute.name

  case attr_name
  when "disabled"
    { disabled: true }
  when "type"
    # button is the default type, so we don't need to do anything.
    return {} if attribute.value == "button"

    raise ConversionError, "Button component does not support type \"#{attribute.value}\"" unless TYPE_OPTIONS.include?(attribute.value)

    { type: ":#{attribute.value}" }
  else
    { attr_name.to_sym => erb_helper.convert(attribute) }
  end
end