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.

It raises under strict_icons for the same reason icon_for does, and the reason is sharper here: a component asking for an icon the engine does not ship renders nothing, and no host-app override can rescue it. That is how the dropdown and combobox triggers shipped without their chevrons.



29
30
31
32
33
34
35
36
37
38
39
# File 'app/helpers/maquina_components/icons_helper.rb', line 29

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

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

  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



41
42
# File 'app/helpers/maquina_components/icons_helper.rb', line 41

def main_icon_svg_for(name)
end