# frozen_string_literal: true
module FComponents
module IconsHelper
# Public: Creates a icon tag
# Examples:
#
# fa_icon('eye')
# #=>
#
# fa_icon('eye', prefix: 'far')
#
#
# fa_icon('eye', class: 'strong space-x-2')
# #=>
#
# fa_icon('eye', class: 'strong space-x-2', text: 'my text')
# #=> my text
def fa_icon(name, options = {})
fa_prefix = options.delete(:prefix) { 'fas' }
icon_name = "fa-#{name}"
custom_classes = options[:class].presence
options[:class] = [fa_prefix, icon_name, custom_classes].compact.join(' ')
f_icon(options)
end
def f_icon(options)
text = options.delete(:text)
tag = content_tag(:i, nil, options)
tag << " #{text}" if text.present?
tag
end
end
end