Class: Anchor::ToastComponent
- Defined in:
- app/components/anchor/toast_component.rb
Constant Summary collapse
- VARIANT_DEFAULT =
:notice- VARIANT_MAPPINGS =
{ VARIANT_DEFAULT => "bg-gray-900 text-white", :success => "bg-green-700 text-white", :error => "bg-red-700 text-white", # TODO: Figma doesn’t provide a yellow ‘alert’ style :alert => "bg-yellow-600 text-white", }.freeze
- VARIANT_OPTIONS =
VARIANT_MAPPINGS.keys
Instance Method Summary collapse
-
#initialize(variant: VARIANT_DEFAULT) ⇒ ToastComponent
constructor
A new instance of ToastComponent.
Methods inherited from Component
Methods included from ViewHelper
Methods included from FetchOrFallbackHelper
Constructor Details
#initialize(variant: VARIANT_DEFAULT) ⇒ ToastComponent
Returns a new instance of ToastComponent.
17 18 19 20 21 22 23 24 |
# File 'app/components/anchor/toast_component.rb', line 17 def initialize(variant: VARIANT_DEFAULT) @variant = VARIANT_MAPPINGS[ fetch_or_fallback(VARIANT_OPTIONS, variant, VARIANT_DEFAULT) ] @id = self.class.generate_id super end |