Giter VIP home page Giter VIP logo

Comments (5)

kobaltz avatar kobaltz commented on May 20, 2024 1

This is an ugly way of doing it, but you can make it into a helper like icon_right('angle-double-right','Next'), but the below does allow for the icon to show on the right.

<%= link_to "Next #{icon('angle-double-right')}".html_safe, "#", class: 'btn btn-default' %>

from font-awesome-sass.

andreykul avatar andreykul commented on May 20, 2024 1

The font-awesome-rails gem has similar functionality, implemented as follows:

= icon('arrow-right', 'Login', right: true) # Login <i class="fa fa-arrow-right"></i>

from font-awesome-sass.

rhnorment avatar rhnorment commented on May 20, 2024

bump

from font-awesome-sass.

kampeynco avatar kampeynco commented on May 20, 2024

I'm assuming there's been no resolution to this issue?

from font-awesome-sass.

CapDev avatar CapDev commented on May 20, 2024

I'm assuming there's been no resolution to this issue?

Looking at the font-awesome-rails helper as well as this gems helper.

The solution below is working as a replacement allowing you to add the option to position the icon to the right of any text.

fa_icon('fab', 'font-awesome', 'Font Awesome', id: 'my-icon', class: 'strong', right: true)
def fa_icon(style, name, text = nil, html_options = {})
  text, html_options = nil, text if text.is_a?(Hash)

  content_class = "#{style} fa-#{name}"
  content_class += " #{html_options[:class]}" if html_options.key?(:class)
  html_options[:class] = content_class

  icon = content_tag(:i, nil, html_options)
  right_icon = html_options.delete(:right)
  icon_join(icon, text, right_icon)
end
private

def icon_join(icon, text, reverse_order = false)
  return icon if text.blank?

  elements = [icon, ERB::Util.html_escape(text)]
  elements.reverse! if reverse_order
  safe_join(elements, ' ')
end

from font-awesome-sass.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.