Class: Primer::Beta::State
- Defined in:
- app/components/primer/beta/state.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 Status::Dsl
Constants included from ViewHelper
Constants included from TestSelectorHelper
TestSelectorHelper::TEST_SELECTOR_TAG
Constants included from FetchOrFallbackHelper
FetchOrFallbackHelper::InvalidValueError
Constants included from AttributesHelper
AttributesHelper::PLURAL_ARIA_ATTRIBUTES, AttributesHelper::PLURAL_DATA_ATTRIBUTES
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(title:, scheme: SCHEME_DEFAULT, tag: TAG_DEFAULT, size: SIZE_DEFAULT, **system_arguments) ⇒ State
constructor
A new instance of State.
Methods inherited from Component
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
Methods included from AttributesHelper
#aria, #data, #extract_data, #merge_aria, #merge_data, #merge_prefixed_attribute_hashes
Methods included from ExperimentalSlotHelpers
Methods included from ExperimentalRenderHelpers
Constructor Details
#initialize(title:, scheme: SCHEME_DEFAULT, tag: TAG_DEFAULT, size: SIZE_DEFAULT, **system_arguments) ⇒ State
Returns a new instance of State.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/components/primer/beta/state.rb', line 40 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
58 59 60 |
# File 'app/components/primer/beta/state.rb', line 58 def call render(Primer::BaseComponent.new(**@system_arguments)) { content } end |