Sha256: b24a3c25e6459022dffc7bc61d2ffd6e48da64a37c26ea1c2aff9d8634cd770c

Contents?: true

Size: 673 Bytes

Versions: 2

Compression:

Stored size: 673 Bytes

Contents

module BMC::FontAwesomeHelper
  def fa_s(id, **)
    _bmc_fa_icon(id, fa_style: "fas", **)
  end

  def fa_r(id, **)
    _bmc_fa_icon(id, fa_style: "far", **)
  end

  def fa_b(id, **)
    _bmc_fa_icon(id, fa_style: "fab", **)
  end

  def _bmc_fa_icon(id, fa_style: nil, size: nil, spin: false, **options)
    id = id.to_s.tr("_", "-").to_sym

    css_classes = options.delete(:class).to_s.split
    css_classes << "icon"
    css_classes << "fa-#{id}"
    css_classes << fa_style
    css_classes << "fa-#{size}" if size
    css_classes << "fa-spin" if spin

    attributes = options.merge(class: css_classes.sort.join(" ")).sort.to_h

    tag.span(**attributes)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bmc-1.6.1 app/helpers/bmc/font_awesome_helper.rb
bmc-1.6.0 app/helpers/bmc/font_awesome_helper.rb