Module: FComponents::IconsHelper

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

Instance Method Summary collapse

Instance Method Details

#f_icon(options) ⇒ Object



27
28
29
30
31
32
# File 'app/helpers/f_components/icons_helper.rb', line 27

def f_icon(options)
  text = options.delete(:text)
  tag = (:i, nil, options)
  tag << " #{text}" if text.present?
  tag
end

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

Public: Creates a icon tag Examples:

fa_icon(‘eye’) #=> <i class=“fas fa-eye”></i>

fa_icon(‘eye’, prefix: ‘far’) <i class=“far fa-eye”></i>

fa_icon(‘eye’, class: ‘strong space-x-2’) #=> <i class=“fas fa-eye strong space-x-2”></i>

fa_icon(‘eye’, class: ‘strong space-x-2’, text: ‘my text’) #=> <i class=“fas fa-eye strong space-x-2”></i> my text



19
20
21
22
23
24
25
# File 'app/helpers/f_components/icons_helper.rb', line 19

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