Class: Anchor::IconComponent

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

Constant Summary collapse

SIZE_DEFAULT =
:large
SIZE_MAPPINGS =
{
  small: 16,
  medium: 20,
  SIZE_DEFAULT => 24,
}.freeze
SIZE_OPTIONS =
SIZE_MAPPINGS.keys

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(icon:, size: SIZE_DEFAULT, **kwargs) ⇒ IconComponent

Returns a new instance of IconComponent.



11
12
13
14
15
16
# File 'app/components/anchor/icon_component.rb', line 11

def initialize(icon:, size: SIZE_DEFAULT, **kwargs)
  @icon = icon
  @size = SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, SIZE_DEFAULT)]

  super(**kwargs)
end