class ERBLint::Linters::ArgumentMappers::Label

Maps classes in a label element to arguments for the Label component.

Constants

ATTRIBUTES
DEFAULT_TAG
SCHEME_MAPPINGS
VARIANT_MAPPINGS

Public Instance Methods

attribute_to_args(attribute) click to toggle source
# File lib/primer/view_components/linters/argument_mappers/label.rb, line 29
def attribute_to_args(attribute)
  { title: erb_helper.convert(attribute) }
end
classes_to_args(classes) click to toggle source
# File lib/primer/view_components/linters/argument_mappers/label.rb, line 33
def classes_to_args(classes)
  classes.each_with_object({ classes: [] }) do |class_name, acc|
    next if class_name == "Label"

    if SCHEME_MAPPINGS[class_name] && acc[:scheme].nil?
      acc[:scheme] = SCHEME_MAPPINGS[class_name]
    elsif VARIANT_MAPPINGS[class_name] && acc[:variant].nil?
      acc[:variant] = VARIANT_MAPPINGS[class_name]
    else
      acc[:classes] << class_name
    end
  end
end