module BMC::FontAwesomeHelper def fa_s(id, **options) _bmc_fa_icon(id, fa_style: "fas", **options) end def fa_r(id, **options) _bmc_fa_icon(id, fa_style: "far", **options) end def fa_b(id, **options) _bmc_fa_icon(id, fa_style: "fab", **options) 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