Class: Yattho::Beta::State
- Defined in:
- app/components/yattho/beta/state.rb
Overview
Use ‘State` for rendering the status of an item.
Direct Known Subclasses
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
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
Constructor Details
#initialize(title:, scheme: SCHEME_DEFAULT, tag: TAG_DEFAULT, size: SIZE_DEFAULT, **system_arguments) ⇒ State
Returns a new instance of State.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'app/components/yattho/beta/state.rb', line 53 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
71 72 73 |
# File 'app/components/yattho/beta/state.rb', line 71 def call render(Yattho::BaseComponent.new(**@system_arguments)) { content } end |