Sha256: 9c9f3de5b64b8484bdcad2c69b24dcfabd049be37294e786a461105cdb3227c0
Contents?: true
Size: 1.21 KB
Versions: 8
Compression:
Stored size: 1.21 KB
Contents
# frozen_string_literal: true module Primer class LabelComponent < Primer::Component SCHEME_MAPPINGS = { # gray gray: "Label--gray", dark_gray: "Label--gray-darker", # colored yellow: "Label--yellow", orange: "Label--orange", red: "Label--red", green: "Label--green", blue: "Label--blue", purple: "Label--purple", pink: "Label--pink", # Deprecated outline: "Label--outline", green_outline: "Label--outline-green", }.freeze SCHEME_OPTIONS = SCHEME_MAPPINGS.keys << nil VARIANT_MAPPINGS = { large: "Label--large", inline: "Label--inline", }.freeze VARIANT_OPTIONS = VARIANT_MAPPINGS.keys << nil def initialize(title:, scheme: nil, variant: nil, **kwargs) @kwargs = kwargs @kwargs[:bg] = :blue if scheme.nil? @kwargs[:tag] ||= :span @kwargs[:title] = title @kwargs[:classes] = class_names( "Label", kwargs[:classes], SCHEME_MAPPINGS[fetch_or_fallback(SCHEME_OPTIONS, scheme)], VARIANT_MAPPINGS[fetch_or_fallback(VARIANT_OPTIONS, variant)] ) end def call render(Primer::BaseComponent.new(**@kwargs)) { content } end end end
Version data entries
8 entries across 8 versions & 1 rubygems