Module: Thredded::IconHelper

Included in:
ApplicationHelper
Defined in:
app/helpers/thredded/icon_helper.rb

Instance Method Summary collapse

Instance Method Details

#define_svg_icons(*filenames) ⇒ Object


16
17
18
19
20
21
22
23
# File 'app/helpers/thredded/icon_helper.rb', line 16

def define_svg_icons(*filenames)
  return if filenames.blank?
  sb = filenames.map do |filename|
    inline_svg_once(filename, id: thredded_icon_id(filename))
  end
  return if sb.compact.blank?
   :div, safe_join(sb), class: 'thredded--svg-definitions'
end

#inline_svg_once(filename, id:, **transform_params) ⇒ Object


25
26
27
28
29
# File 'app/helpers/thredded/icon_helper.rb', line 25

def inline_svg_once(filename, id:, **transform_params)
  return if @already_inlined_svg_ids&.include?(id)
  record_already_inlined_svg(filename, id)
  inline_svg_tag(filename, id: id, **transform_params)
end

#shared_inline_svg(filename, **args) ⇒ Object


5
6
7
8
9
10
11
12
13
14
# File 'app/helpers/thredded/icon_helper.rb', line 5

def shared_inline_svg(filename, **args)
  svg =  :svg, **args do
     :use, '', 'xlink:href' => "##{thredded_icon_id(filename)}"
  end
  if (definition = define_svg_icons(filename))
    definition + svg
  else
    svg
  end
end