Sha256: 86ebc216215626d7d6a67e07ba667a34d5e5636d5433c4ecd4db9c671b1fe0e4

Contents?: true

Size: 890 Bytes

Versions: 29

Compression:

Stored size: 890 Bytes

Contents

# frozen_string_literal: true

require_relative "base"

module ERBLint
  module Linters
    module ArgumentMappers
      # Maps classes in a flash element to arguments for the Flash component.
      class Flash < Base
        SCHEME_MAPPINGS = Primer::ViewComponents::Constants.get(
          component: "Primer::Beta::Flash",
          constant: "SCHEME_MAPPINGS",
          symbolize: true
        ).freeze

        def classes_to_args(classes)
          classes.each_with_object({ classes: [] }) do |class_name, acc|
            next if class_name == "flash"

            if SCHEME_MAPPINGS[class_name] && acc[:scheme].nil?
              acc[:scheme] = SCHEME_MAPPINGS[class_name]
            elsif class_name == "flash-full"
              acc[:full] = true
            else
              acc[:classes] << class_name
            end
          end
        end
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
primer_view_components-0.0.105 lib/primer/view_components/linters/argument_mappers/flash.rb
primer_view_components-0.0.104 lib/primer/view_components/linters/argument_mappers/flash.rb
primer_view_components-0.0.103 lib/primer/view_components/linters/argument_mappers/flash.rb
primer_view_components-0.0.102 lib/primer/view_components/linters/argument_mappers/flash.rb
primer_view_components-0.0.101 lib/primer/view_components/linters/argument_mappers/flash.rb
primer_view_components-0.0.100 lib/primer/view_components/linters/argument_mappers/flash.rb
primer_view_components-0.0.99 lib/primer/view_components/linters/argument_mappers/flash.rb
primer_view_components-0.0.98 lib/primer/view_components/linters/argument_mappers/flash.rb
primer_view_components-0.0.97 lib/primer/view_components/linters/argument_mappers/flash.rb
primer_view_components-0.0.96 lib/primer/view_components/linters/argument_mappers/flash.rb
primer_view_components-0.0.95 lib/primer/view_components/linters/argument_mappers/flash.rb
primer_view_components-0.0.94 lib/primer/view_components/linters/argument_mappers/flash.rb
primer_view_components-0.0.93 lib/primer/view_components/linters/argument_mappers/flash.rb
primer_view_components-0.0.92 lib/primer/view_components/linters/argument_mappers/flash.rb
primer_view_components-0.0.91 lib/primer/view_components/linters/argument_mappers/flash.rb
primer_view_components-0.0.90 lib/primer/view_components/linters/argument_mappers/flash.rb
primer_view_components-0.0.89 lib/primer/view_components/linters/argument_mappers/flash.rb
primer_view_components-0.0.88 lib/primer/view_components/linters/argument_mappers/flash.rb
primer_view_components-0.0.87 lib/primer/view_components/linters/argument_mappers/flash.rb
primer_view_components-0.0.86 lib/primer/view_components/linters/argument_mappers/flash.rb