Sha256: 31de2dc57f811ef10f9fab2ecdb942a495e3af8a98f4d3208cf8ea7bbb4829df
Contents?: true
Size: 1.64 KB
Versions: 2
Compression:
Stored size: 1.64 KB
Contents
# frozen_string_literal: true require_relative "base" module ERBLint module Linters module ArgumentMappers # Maps classes in a label element to arguments for the Label component. class Label < Base SCHEME_MAPPINGS = Yattho::ViewComponents::Constants.get( component: "Yattho::Beta::Label", constant: "SCHEME_MAPPINGS", symbolize: true ).freeze SIZE_MAPPINGS = Yattho::ViewComponents::Constants.get( component: "Yattho::Beta::Label", constant: "SIZE_MAPPINGS", symbolize: true ).freeze DEFAULT_TAG = Yattho::ViewComponents::Constants.get( component: "Yattho::Beta::Label", constant: "DEFAULT_TAG" ).freeze INLINE_CLASS = Yattho::ViewComponents::Constants.get( component: "Yattho::Beta::Label", constant: "INLINE_CLASS" ).freeze ATTRIBUTES = %w[title].freeze def attribute_to_args(attribute) { title: erb_helper.convert(attribute) } end 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 SIZE_MAPPINGS[class_name] && acc[:size].nil? acc[:size] = SIZE_MAPPINGS[class_name] elsif class_name == INLINE_CLASS && acc[:inline].nil? acc[:inline] = true else acc[:classes] << class_name end end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
yattho_view_components-0.1.1 | lib/yattho/view_components/linters/argument_mappers/label.rb |
yattho_view_components-0.0.1 | lib/yattho/view_components/linters/argument_mappers/label.rb |