Module: Thredded::IconHelper
- Included in:
- ApplicationHelper
- Defined in:
- app/helpers/thredded/icon_helper.rb
Instance Method Summary collapse
- #define_svg_icons(*filenames) ⇒ Object
- #inline_svg_once(filename, id:, **transform_params) ⇒ Object
- #shared_inline_svg(filename, **args) ⇒ Object
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? content_tag :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 = content_tag :svg, **args do content_tag :use, '', 'xlink:href' => "##{thredded_icon_id(filename)}" end if (definition = define_svg_icons(filename)) definition + svg else svg end end |