Class: Pulse::Icon

Inherits:
Component
  • Object
show all
Defined in:
app/components/pulse/icon.rb

Overview

Render icons from the images/pulse_view_components/icons directory.

Constant Summary collapse

SIZE_DEFAULT =
:sm
SIZE_MAPPINGS =
{
  xs: 12,
  sm: 16,
  md: 24
}.freeze
SIZE_OPTIONS =
SIZE_MAPPINGS.keys

Instance Method Summary collapse

Constructor Details

#initialize(icon: nil, size: SIZE_DEFAULT, **system_arguments) ⇒ Icon

Returns a new instance of Icon.



14
15
16
17
18
19
20
21
22
23
24
# File 'app/components/pulse/icon.rb', line 14

def initialize(icon: nil, size: SIZE_DEFAULT, **system_arguments)
  @icon = "pulse_view_components/icons/#{icon}"

  @system_arguments = system_arguments
  @system_arguments[:class] = class_names(
    'pulse-icon',
    system_arguments[:classes]
  )
  @system_arguments[:height] ||=
    SIZE_MAPPINGS[fetch_or_fallback(SIZE_OPTIONS, size, SIZE_DEFAULT)]
end

Instance Method Details

#callObject



26
27
28
# File 'app/components/pulse/icon.rb', line 26

def call
  render_svg(@icon, **@system_arguments)
end