Class: Anchor::BannerComponent

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

Constant Summary collapse

VARIANT_DEFAULT =
:informational
VARIANT_MAPPINGS =
{
  VARIANT_DEFAULT => "bg-accent-subdued",
  :critical => "bg-critical-subdued",
  :success => "bg-success-subdued",
  :warning => "bg-warning-subdued",
}.freeze
VARIANT_OPTIONS =
VARIANT_MAPPINGS.keys
ICON_MAPPINGS =
{
  critical: "warning-triangle",
  informational: "info-circle",
  success: "check-circle",
  warning: "warning-circle",
}.freeze
ICON_VARIANT_MAPPINGS =
{
  critical: "text-critical",
  informational: "text-accent",
  success: "text-success",
  warning: "text-warning",
}.freeze

Constants included from ViewHelper

ViewHelper::ANCHOR_HELPERS

Instance Method Summary collapse

Methods inherited from Component

generate_id

Methods included from ViewHelper

#anchor_form_with, #anchor_svg, #deep_blank?, #merge_options, #popover_trigger_attributes

Methods included from FetchOrFallbackHelper

#fetch_or_fallback

Constructor Details

#initialize(variant: VARIANT_DEFAULT, **kwargs) ⇒ BannerComponent

Returns a new instance of BannerComponent.



37
38
39
40
41
42
# File 'app/components/anchor/banner_component.rb', line 37

def initialize(variant: VARIANT_DEFAULT, **kwargs)
  @icon = ICON_MAPPINGS[variant]
  @icon_variant = ICON_VARIANT_MAPPINGS[variant]

  super(variant:, **kwargs)
end