Class: Essence::StatusComponent
- Inherits:
-
ApplicationComponent
- Object
- ViewComponent::Base
- ApplicationComponent
- Essence::StatusComponent
- Defined in:
- app/components/essence/status_component.rb
Constant Summary collapse
- DEFAULT_VARIANT =
:outline
- VARIANT_MAPPINGS =
{ DEFAULT_VARIANT => 'status-outline', :todo => 'status-todo', :active => 'status-active', :danger => 'status-danger' }.freeze
- VARIANT_OPTIONS =
VARIANT_MAPPINGS.keys.freeze
- DEFAULT_BUBBLE =
nil
- BUBBLE_MAPPINGS =
{ DEFAULT_BUBBLE => '', :dotted => 'status-bubble-dotted', :outline => 'status-bubble-outline', :solid => 'status-bubble-solid' }.freeze
- BUBBLE_OPTIONS =
BUBBLE_MAPPINGS.keys.freeze
Constants included from FetchOrFallbackHelper
FetchOrFallbackHelper::InvalidValueError
Instance Attribute Summary collapse
-
#bubble ⇒ Object
readonly
Returns the value of attribute bubble.
-
#html_options ⇒ Object
readonly
Returns the value of attribute html_options.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
-
#initialize(text:, variant: DEFAULT_VARIANT, bubble: DEFAULT_BUBBLE, **html_options) ⇒ StatusComponent
constructor
A new instance of StatusComponent.
Methods inherited from ApplicationComponent
#assets_path, assets_path, images_directory
Methods included from Utils
Methods included from FetchOrFallbackHelper
#fetch_or_fallback, #fetch_or_fallback_boolean, #integer_or_fallback
Constructor Details
#initialize(text:, variant: DEFAULT_VARIANT, bubble: DEFAULT_BUBBLE, **html_options) ⇒ StatusComponent
Returns a new instance of StatusComponent.
29 30 31 32 33 34 35 36 37 |
# File 'app/components/essence/status_component.rb', line 29 def initialize(text:, variant: DEFAULT_VARIANT, bubble: DEFAULT_BUBBLE, **) @text = text&.to_s&.strip&.presence&.downcase @variant = fetch_or_fallback(VARIANT_OPTIONS, variant.to_sym, DEFAULT_VARIANT) @bubble = fetch_or_fallback(BUBBLE_OPTIONS, bubble&.to_sym, DEFAULT_BUBBLE) @html_options = end |
Instance Attribute Details
#bubble ⇒ Object (readonly)
Returns the value of attribute bubble.
5 6 7 |
# File 'app/components/essence/status_component.rb', line 5 def bubble @bubble end |
#html_options ⇒ Object (readonly)
Returns the value of attribute html_options.
5 6 7 |
# File 'app/components/essence/status_component.rb', line 5 def @html_options end |
#text ⇒ Object (readonly)
Returns the value of attribute text.
5 6 7 |
# File 'app/components/essence/status_component.rb', line 5 def text @text end |