Class: Primer::LabelComponent
- Defined in:
- app/components/primer/label_component.rb
Overview
Use labels to add contextual metadata to a design.
Constant Summary collapse
- SCHEME_MAPPINGS =
{ primary: "Label--primary", secondary: "Label--secondary", info: "Label--info", success: "Label--success", warning: "Label--warning", danger: "Label--danger", # deprecated orange: "Label--orange", purple: "Label--purple" }.freeze
- SCHEME_OPTIONS =
SCHEME_MAPPINGS.keys << nil
- VARIANT_MAPPINGS =
{ large: "Label--large", inline: "Label--inline" }.freeze
- VARIANT_OPTIONS =
VARIANT_MAPPINGS.keys << nil
Constants inherited from Component
Constants included from FetchOrFallbackHelper
FetchOrFallbackHelper::InvalidValueError
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(title:, scheme: nil, variant: nil, **system_arguments) ⇒ LabelComponent
constructor
A new instance of LabelComponent.
Methods included from ViewHelper
Methods included from JoinStyleArgumentsHelper
Methods included from FetchOrFallbackHelper
#fetch_or_fallback, #fetch_or_fallback_boolean
Methods included from ClassNameHelper
Constructor Details
#initialize(title:, scheme: nil, variant: nil, **system_arguments) ⇒ LabelComponent
Returns a new instance of LabelComponent.
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'app/components/primer/label_component.rb', line 46 def initialize(title:, scheme: nil, variant: nil, **system_arguments) @system_arguments = system_arguments @system_arguments[:bg] = :blue if scheme.nil? @system_arguments[:tag] ||= :span @system_arguments[:title] = title @system_arguments[:classes] = class_names( "Label", system_arguments[:classes], SCHEME_MAPPINGS[fetch_or_fallback(SCHEME_OPTIONS, scheme)], VARIANT_MAPPINGS[fetch_or_fallback(VARIANT_OPTIONS, variant)] ) end |
Class Method Details
.status ⇒ Object
63 64 65 |
# File 'app/components/primer/label_component.rb', line 63 def self.status Primer::Component::STATUSES[:beta] end |
Instance Method Details
#call ⇒ Object
59 60 61 |
# File 'app/components/primer/label_component.rb', line 59 def call render(Primer::BaseComponent.new(**@system_arguments)) { content } end |