font-awesome-sass icon indicating copy to clipboard operation
font-awesome-sass copied to clipboard

Helper#icon prepends fa- to given fa class string

Open nnattawat opened this issue 8 years ago • 3 comments

I made the improvement on the helper method. Now it can handle multiple fa- classes.

For example, to add fa-2x class we need to use icon('flag', class='fa-2x') which make more sense to use it as the following.

icon('flag 2x')
# => <i class="fa fa-flag fa-2x"></i>

nnattawat avatar Nov 12 '15 02:11 nnattawat

You should probably call to_s on icon before trying to split it. Before this change, a Symbol could be passed in, but now it requires a String, potentially causing existing usages to break.

nickpearson avatar Nov 12 '15 14:11 nickpearson

How about optional array instead?

icon([:flag, '2x', :fw], "Big Flag")
# => <i class="fa fa-flag fa-2x fa-fw"></i>

icon(:flag, 'Normal flag')
# => <i class="fa fa-flag"></i>

andreykul avatar Nov 12 '15 15:11 andreykul

@nickpearson and @andreykul good points guys. I have made it to support more formats.

icon(:flag)
# => <i class="fa fa-flag">
icon('flag')
# => <i class="fa fa-flag">
icon([:flag, :fw, '2x'])
# => <i class="fa fa-flag fa-fw fa-2x">
icon("flag fw 2x")
# => <i class="fa fa-flag fa-fw fa-2x">

nnattawat avatar Nov 12 '15 23:11 nnattawat