Class: Primer::FlashComponent
- Includes:
- ViewComponent::SlotableV2
- Defined in:
- app/components/primer/flash_component.rb
Overview
Use the Flash component to inform users of successful or pending actions.
Constant Summary collapse
- DEFAULT_VARIANT =
:default- VARIANT_MAPPINGS =
{ DEFAULT_VARIANT => "", :warning => "flash-warn", :danger => "flash-error", :success => "flash-success" }.freeze
Constants inherited from Component
Constants included from FetchOrFallbackHelper
Primer::FetchOrFallbackHelper::InvalidValueError
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(full: false, spacious: false, dismissible: false, icon: nil, variant: DEFAULT_VARIANT, **system_arguments) ⇒ FlashComponent
constructor
A new instance of FlashComponent.
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(full: false, spacious: false, dismissible: false, icon: nil, variant: DEFAULT_VARIANT, **system_arguments) ⇒ FlashComponent
Returns a new instance of FlashComponent.
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'app/components/primer/flash_component.rb', line 54 def initialize(full: false, spacious: false, dismissible: false, icon: nil, variant: DEFAULT_VARIANT, **system_arguments) @icon = icon @dismissible = dismissible @system_arguments = system_arguments @system_arguments[:tag] = :div @system_arguments[:classes] = class_names( @system_arguments[:classes], "flash", VARIANT_MAPPINGS[fetch_or_fallback(VARIANT_MAPPINGS.keys, variant, DEFAULT_VARIANT)], "flash-full": full ) @system_arguments[:mb] ||= spacious ? 4 : nil end |
Class Method Details
.status ⇒ Object
68 69 70 |
# File 'app/components/primer/flash_component.rb', line 68 def self.status Primer::Component::STATUSES[:beta] end |