Module: Interage::FontAwesomeHelper

Included in:
ApplicationHelper
Defined in:
lib/interage/font_awesome_helper.rb

Constant Summary collapse

FA_ICON_TEXT_CLASS =
'text'

Instance Method Summary collapse

Instance Method Details

#fa_classes(icon, options = {}) ⇒ Object



28
29
30
31
32
# File 'lib/interage/font_awesome_helper.rb', line 28

def fa_classes(icon, options = {})
  icon_classes = icon.to_s.split.uniq.join(' fa-')

  "fa fa-#{icon_classes} #{options[:class]}".strip
end

#fa_fw_icon(icon, options = {}) ⇒ Object



17
18
19
# File 'lib/interage/font_awesome_helper.rb', line 17

def fa_fw_icon(icon, options = {})
  fa_icon("fw #{icon}", options)
end

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



11
12
13
14
15
# File 'lib/interage/font_awesome_helper.rb', line 11

def fa_icon(icon, options = {})
  icon_html_options = options.merge(class: fa_classes(icon, options))

  (:i, nil, icon_html_options)
end

#fa_icon_text(icon, text, options = {}) ⇒ Object



21
22
23
24
25
26
# File 'lib/interage/font_awesome_helper.rb', line 21

def fa_icon_text(icon, text, options = {})
   :span do
    concat fa_fw_icon(icon, options)
    concat (:span, text, class: FA_ICON_TEXT_CLASS)
  end
end

#fa_iconsObject



7
8
9
# File 'lib/interage/font_awesome_helper.rb', line 7

def fa_icons
  t('icons_alias', default: {}).keys
end