Sha256: 403273d91ea5c5fde34295811117ab752f943f0ac749c5c5fbc90b818826add0
Contents?: true
Size: 949 Bytes
Versions: 3
Compression:
Stored size: 949 Bytes
Contents
# frozen_string_literal: true module FComponents module IconsHelper # 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 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
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
f_components-1.0.0 | app/helpers/f_components/icons_helper.rb |
f_components-0.3.0 | app/helpers/f_components/icons_helper.rb |
f_components-0.2.1 | app/helpers/f_components/icons_helper.rb |