Module: MaquinaComponents::IconsHelper

Defined in:
app/helpers/maquina_components/icons_helper.rb

Instance Method Summary collapse

Instance Method Details

#builtin_icon_for(name, options = {}) ⇒ Object

Internal icon helper for engine components. Always uses built-in SVGs so components work reliably regardless of the app's icon configuration.



24
25
26
27
28
29
30
31
# File 'app/helpers/maquina_components/icons_helper.rb', line 24

def builtin_icon_for(name, options = {})
  return nil unless name

  svg = icon_svg_for(name.to_sym)
  return nil unless svg

  apply_icon_options(svg, options)
end

#icon_for(name, options = {}) ⇒ Object

Renders an icon by name, preferring the host app's main_icon_svg_for override and falling back to the engine's built-in set.

An unknown name used to render nothing at all, which is invisible in review and in production. When MaquinaComponents.strict_icons is on (development and test by default) it raises instead; production keeps the nil so a typo can never take a page down.



10
11
12
13
14
15
16
17
18
19
20
# File 'app/helpers/maquina_components/icons_helper.rb', line 10

def icon_for(name, options = {})
  return nil unless name

  svg = main_icon_svg_for(name.to_sym) || icon_svg_for(name.to_sym)
  unless svg
    raise MaquinaComponents::UnknownIconError, unknown_icon_message(name) if MaquinaComponents.strict_icons?
    return nil
  end

  apply_icon_options(svg, options)
end

#main_icon_svg_for(name) ⇒ Object



33
34
# File 'app/helpers/maquina_components/icons_helper.rb', line 33

def main_icon_svg_for(name)
end