Class: StimulusPlumbers::Components::Icon::Renderer

Inherits:
Plumber::Base
  • Object
show all
Defined in:
lib/stimulus_plumbers/components/icon/renderer.rb

Constant Summary collapse

ICONS =
{
  "arrow-left"  => "M10.5 19.5 3 12m0 0 7.5-7.5M3 12h18",
  "arrow-right" => "M13.5 4.5 21 12m0 0-7.5 7.5M21 12H3",
  "arrow-up"    => "M4.5 10.5 12 3m0 0 7.5 7.5M12 3v18",
  "arrow-down"  => "M19.5 13.5 12 21m0 0-7.5-7.5M12 21V3"
}.freeze

Instance Attribute Summary

Attributes inherited from Plumber::Base

#template

Instance Method Summary collapse

Methods inherited from Plumber::Base

#initialize, #theme

Methods included from Plumber::HtmlOptions

#merge_html_options, #merge_string_option, #normalize_part

Constructor Details

This class inherits a constructor from StimulusPlumbers::Components::Plumber::Base

Instance Method Details

#icon(name:, **kwargs) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/stimulus_plumbers/components/icon/renderer.rb', line 14

def icon(name:, **kwargs)
  html_options = merge_html_options(
    { classes: theme.resolve(:icon).fetch(:classes, "") },
    kwargs
  )

  if ICONS[name]
    svg_icon(ICONS[name], html_options)
  else
    template.(:span, nil, **html_options)
  end
end