Class: Anchor::BannerComponent

Inherits:
Component
  • Object
show all
Defined in:
app/components/anchor/banner_component.rb

Constant Summary collapse

VARIANT_DEFAULT =
:neutral
VARIANT_MAPPINGS =
{
  VARIANT_DEFAULT => "bg-neutral",
  :informational => "bg-informational-subdued",
  :success => "bg-success-subdued",
  :critical => "bg-critical-subdued",
  :warning => "bg-warning-subdued",
}.freeze
VARIANT_OPTIONS =
VARIANT_MAPPINGS.keys

Instance Method Summary collapse

Methods inherited from Component

generate_id

Methods included from ViewHelper

#text_prose

Methods included from FetchOrFallbackHelper

#fetch_or_fallback

Constructor Details

#initialize(variant: VARIANT_DEFAULT, classes: nil) ⇒ BannerComponent

Returns a new instance of BannerComponent.



13
14
15
16
17
18
19
20
# File 'app/components/anchor/banner_component.rb', line 13

def initialize(variant: VARIANT_DEFAULT, classes: nil)
  @variant = VARIANT_MAPPINGS[
    fetch_or_fallback(VARIANT_OPTIONS, variant, VARIANT_DEFAULT)
  ]
  @classes = classes

  super
end