Class: Primer::StateComponent
- Defined in:
- app/components/primer/state_component.rb
Overview
Use ‘State` for rendering the status of an item.
Constant Summary collapse
- SCHEME_DEFAULT =
:default- NEW_SCHEME_MAPPINGS =
{ open: "State--open", closed: "State--closed", merged: "State--merged" }.freeze
- DEPRECATED_SCHEME_MAPPINGS =
{ SCHEME_DEFAULT => "", :green => "State--open", :red => "State--closed", :purple => "State--merged" }.freeze
- SCHEME_MAPPINGS =
NEW_SCHEME_MAPPINGS.merge(DEPRECATED_SCHEME_MAPPINGS)
- SCHEME_OPTIONS =
SCHEME_MAPPINGS.keys
- SIZE_DEFAULT =
:default- SIZE_MAPPINGS =
{ SIZE_DEFAULT => "", :small => "State--small" }.freeze
- SIZE_OPTIONS =
SIZE_MAPPINGS.keys
- TAG_DEFAULT =
:span- TAG_OPTIONS =
[TAG_DEFAULT, :div].freeze
Constants inherited from Component
Component::INVALID_ARIA_LABEL_TAGS
Constants included from Primer::Status::Dsl
Constants included from ViewHelper
Constants included from TestSelectorHelper
TestSelectorHelper::TEST_SELECTOR_TAG
Constants included from FetchOrFallbackHelper
FetchOrFallbackHelper::InvalidValueError
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(title:, scheme: SCHEME_DEFAULT, tag: TAG_DEFAULT, size: SIZE_DEFAULT, **system_arguments) ⇒ StateComponent
constructor
A new instance of StateComponent.
Methods included from JoinStyleArgumentsHelper
Methods included from TestSelectorHelper
Methods included from FetchOrFallbackHelper
#fetch_or_fallback, #fetch_or_fallback_boolean, #silence_deprecations?
Methods included from ClassNameHelper
Constructor Details
#initialize(title:, scheme: SCHEME_DEFAULT, tag: TAG_DEFAULT, size: SIZE_DEFAULT, **system_arguments) ⇒ StateComponent
Returns a new instance of StateComponent.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'app/components/primer/state_component.rb', line 52 def initialize( title:, scheme: SCHEME_DEFAULT, tag: TAG_DEFAULT, size: SIZE_DEFAULT, **system_arguments ) @system_arguments = system_arguments @system_arguments[:title] = title @system_arguments[:tag] = fetch_or_fallback(TAG_OPTIONS, tag, TAG_DEFAULT) @system_arguments[:classes] = class_names( @system_arguments[:classes], "State", SCHEME_MAPPINGS[fetch_or_fallback(SCHEME_OPTIONS, scheme, SCHEME_DEFAULT)], SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, SIZE_DEFAULT)] ) end |
Instance Method Details
#call ⇒ Object
70 71 72 |
# File 'app/components/primer/state_component.rb', line 70 def call render(Primer::BaseComponent.new(**@system_arguments)) { content } end |