Class: Anchor::BadgeComponent

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

Constant Summary collapse

VARIANT_DEFAULT =
:neutral
VARIANT_MAPPINGS =
{
  VARIANT_DEFAULT => "bg-neutral text-base",
  :informational => "bg-informational-subdued text-base",
  :success => "bg-success-subdued text-base",
  :critical => "bg-critical-subdued text-base",
  :warning => "bg-warning-subdued text-base",
}.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) ⇒ BadgeComponent

Returns a new instance of BadgeComponent.



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

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

  super
end