Coder Social home page Coder Social logo

tomkra / font_awesome5_rails Goto Github PK

View Code? Open in Web Editor NEW
158.0 158.0 26.0 13.01 MB

font_awesome_5_rails is font awesome 5 gem bundled for rails asset pipeline

Home Page: https://fontawesome.com/

License: MIT License

Ruby 37.16% JavaScript 0.96% CSS 0.62% HTML 4.30% SCSS 56.96%
font-awesome rails

font_awesome5_rails's People

Contributors

abevoelker avatar dasnixon avatar gaurav2728 avatar jnajera avatar moveson avatar parterburn avatar rbague avatar simmerz avatar sosodev avatar tomkra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

font_awesome5_rails's Issues

Icon name with symbol

Hi @tomkra.
Thanks for quick support for rails 5.2 !

In the previous version I used, I could use the symbol for the icon name, but I can not use it v0.3.1.

fa_icon(:global)
undefined method `split' for :globe:Symbol

font_awesome5_rails/lib/font_awesome5_rails/parsers/parse_methods.rb:22:in `arr_with_fa'
font_awesome5_rails/lib/font_awesome5_rails/parsers/fa_icon_parser.rb:29:in `get_all_classes'
font_awesome5_rails/lib/font_awesome5_rails/parsers/fa_icon_parser.rb:17:in `classes'
font_awesome5_rails/app/helpers/font_awesome5/rails/icon_helper.rb:12:in `fa_icon'

I think that it is a problem that only string are assumed below. Is it possible to support symbol?

  def arr_with_fa(array)
    array.split(" ").map{ |s| prepend_fa(s) }
  end

Rails 5.2.3 support

Hi!

I want to update my app to rails 5.2.3. However, I can't with the error below.

Bundler could not find compatible versions for gem "railties":
  In snapshot (Gemfile.lock):
    railties (= 5.2.3)

  In Gemfile:
    coffee-rails (~> 4.2) was resolved to 4.2.2, which depends on
      railties (>= 4.0.0)

    font-awesome5-rails (= 1.0.1) was resolved to 1.0.1, which depends on
      railties (>= 3.2, < 5.2)

    rails (~> 5.2.3) was resolved to 5.2.3, which depends on
      railties (= 5.2.3)

    sass-rails (~> 5.0) was resolved to 5.0.7, which depends on
      railties (>= 4.0.0, < 6)

    web-console (>= 3.3.0) was resolved to 3.7.0, which depends on
      railties (>= 5.0)

svg-with-js.min.css not included

I am using option 1 for installation "Install as SVG with JS". I have included @import 'font_awesome5'; in my application.scss but it does not import all the styles that are in svg-with-js.min.css. How can I import those styles as well?

Not all icons are displayed

Some icons not display. Such as 'whatsapp', 'instagram', 'cc-visa' and many others. I tried with pro package too. I think that this is not your problem, but I can't find a solution

name and future of gem

Hello to all using this gem. I've like to discuss two things related to this gem.

  1. Since FontAwesome is currently at version 5.9.0 It will not take to much time since they realease sixth version of their amazing font. For us that means that name of this gem will no longer be valid.

    I think that make new gem for every major release of Font Awesome would be waste of time so I propose to rename this gem to some more general name. I thought something like font_awesomeX_rails or font-awesomeX-rails.

    I would be grateful for any more ideas however If you propose same name, please make sure, that It is not already taken on rubygems.org.

  2. Secondly rails 6 will be prefering webpack over the asset pipeline. I'm not much familiar with it at the moment, however I would like to know If there is interest to keep this gem as asset-pipeline related project or to move to completely to webpack and focus on it with new realeases.

Thank you, please feel free to comment.

rails 5.2 support

Hi!

I want to update my app to rails 5.2.
However, I can not be updated with the error below.

Bundler could not find compatible versions for gem "railties":
  In Gemfile:
    font_awesome5_rails (~> 0.3) was resolved to 0.3.0, which depends on
      railties (< 5.2, >= 4.2)

    jquery-rails was resolved to 4.3.1, which depends on
      railties (>= 4.2.0)

    rails (~> 5.2.0) was resolved to 5.2.0, which depends on
      railties (= 5.2.0)

    rspec-rails (~> 3.7) was resolved to 3.7.2, which depends on
      railties (>= 3.0)

    sassc-rails (~> 1.3) was resolved to 1.3.0, which depends on
      railties (>= 4.0.0)

    web-console (>= 3.3.0) was resolved to 3.5.1, which depends on
      railties (>= 5.0)

I think that font_awesome5_rails of here is one cause. Am I wrong?

facebook / twitter icons not working

hello,
I have this problem,

it seems everything is working but the brand icons

= fa_icon 'twitter'
= fa_icon 'facebook'

will show the question mark

imported with

gem 'font_awesome5_rails', '~> 1.0'

//= require font_awesome5

@import "font_awesome5.css";

Screenshot 2020-02-09 at 14 34 46

Installation: "Old way" but with .scss?

Thanks a ton for the gem!

I started with the "recommended" installation, but I feel like the JavaScript conversion to SVG is interfering with some of my existing Javascript. I want to test by "downgrading" to the CSS only version, but I use .scss.

So in my application.js, I removed the
require font_awesome5

And in application.scss, I have:

@import 'font_awesome5';
@import 'font_awesome5_webfont';

Do I need both of these @imports? Only one? With this configuration, I'm seeing no icons at all.

why?

screenshot-2018-4-4 2gid

not show brand.
gem version 0.3.0
rails 5.2.0.rc2

and after update page with turbolinks icons disable.

Add option to put text to the right of icon

Using fa_icon, I can quickly create an element that combines a span with text and an icon. But the icon always appears first (on the left) with the text on the right.

I would like to have an option that puts the text on the left with the icon on the right. Following the syntax of other FA gems, it might look like this:

fa_icon 'arrow-right', text: 'Continue', right: true

I'm Getting a Missing icon_header Error After Updating to Version 0.7.0

I was successfully running version 0.6.0. I did a bundle update like I usually do when getting ready to update my applications. I currently run Rails 5.2.3 with Ruby 2.5.2. Now when I run 0.7.0 or 0.6.0, I get the following error:

ActionController::RoutingError (Couldn't find FontAwesome5::Rails::IconHelper, expected it to be defined in helpers/font_awesome5/rails/icon_helper.rb)

When it was working a few months ago I used *= require font_awesome5_webfont. I tried this along with @import 'font_awesome5_webfont'; in my stylesheet. Regardless, I get the above error. The file exists. I don't know where to look to try and find out if the problem is on my end.

UPDATE: 8 AM July 30, 2019 - I just tried upgrading to Ruby 2.6.3 running version 0.7.0. I got the same error. I'm using @import "font_awesome5_webfont"; in my stylesheet.

undefined method `fa_icon' for Class

Getting an undefined method when trying to call the helper using version 1.0.0 on Rails 5.2.2.1.

Assets are being loaded as expected as I can manually include the <i class="fab fa-accessible-icon"></i> tags, however, when trying to use the helper method- I get an undefined version from above.

Bundle install and restarting server does not solve this issue.

Page flicker problem after rendering

While navigating between pages, as soon as the page is rendered by rails, I notice the progress bar of turbolinks and the page flickers (like a white flash). If I remove the icon from page, the rendering is smooth again like how it should be.

After doing more research on this issue, I found: FortAwesome/Font-Awesome#11924

The solution (FortAwesome/Font-Awesome#11924 (comment)) works as well. The solution is a bit of a hack to fontawesome js but I can confirm that it works.

In short,

  1. Remove following from fontawesome-all.min.js
m.requestAnimationFrame||
  1. Replace turbolinks load hack with
document.addEventListener("turbolinks:before-render", function(event) {
    FontAwesome.dom.i2svg({
        node: event.data.newBody
    });
});

I think it would be nice if you can check it out and figure out a best possible solution.

Automatically add fa- to classes

Hi!
In the previous gem, when you add fw in the classes, it automatically added fa- prefix. For instance:

fa_icon('circle fw')

would return:

<i class="fa fa-home fa-fw"></i>

Here, it returns:

<i class="fas fa-circle fw"></i>

I was wondering if it was done on purpose?

Many thanks for your help!

Webfont scss require

If I do @import 'font_awesome5_webfont'; in my .scss file I get the following output in my CSS.

/*
 *= require fontawesome-all
*/
/* line 5, ../../.rvm/gems/ruby-2.5.1@beam/gems/font_awesome5_rails-0.3.5/app/assets/stylesheets/font_awesome5_webfont.css */
.fa5-text {
  padding-left: 5px;
}

If I just do @import 'fontawesome-all'; it works.

Icons not generated properly

If I type for example:

= fa_icon('youtube', type: :fab)

The result I get is:

<i type="fab" class="fa fa-youtube"></i>

While, reading from the documentation, the result should be:

<i class="fab fa-youtube"></i>

I also have gem 'font-awesome-rails', '~> 4.4.0' installed. So I wonder if the issue is some conflict with that gem.

Getting 'Cant find stylesheet to import' after new JSBundling Rails 7 install

In the "Install with webpack" section could you please clarify the sentence on the README "Next import font in your app/javascript/packs/application.js. You can find more about import in FA pages."

(Please note that I am actually attempting to install this with JSBundling, not webpacker)

Alternatively, please add a section for "Install with JSBundling" instead of webpack.

I searched the (very large and general) FA docs and can find nothing that seems to fit for Rails. Specifically, if you follow the README instructions for a JSBundling app, I get this result:

Screen Shot 2022-11-25 at 10 04 29 PM

my app/assets/stylesheets/application.scss has this:

@import 'bootstrap/scss/bootstrap';
@import 'bootstrap-icons/font/bootstrap-icons';
@import 'font_awesome5_webfont';

The readme says "Next import font in your app/javascript/packs/application.js" (note that in Rails 7 the location is now app/javascript/application.js). This is the part that I'm stuck on. I tried various ways to import font awesome here but I couldn't get any to work.

Can you please clarify the documentation here?

I would suggest removing the link to the general docs because the link only goes to the general docs home page and the information to solve this setup step is not easily identifiable or accessible if you don't already know it.

Using Pro

Dear Tomkra,

would this be an idea?:

FontAwesome5.configure do |config|
  config.source_config_folder = true
end

and then your gem would drag the sources from config/fontawesome/ instead from the gem-folder?
Then i would be able to put my downloaded pro-icons there.
necessary would be a little tutorial about the directory-structure

reasons:

  • i'm not happy with the kit because i want to have no dependencies to outside (yearly licences, ..).
  • I dont want to blow up my asset-pipeline with thousands of icons.
  • the developer would not be misled to put the licenced icons into the public-folder

Thanks,
Christian

Missing icons compared to the 'Free' pack

Hi,

A quick grep shows there are about 708 icons in the gem, but https://fontawesome.com/icons?d=gallery&m=free shows 1609 free icons.

For my specific case, I'm trying to use 'creative-commons-nc' which is listed under https://fontawesome.com/icons?d=gallery&q=creative-commons&m=free but all I get is the flashing ?! icon, like the icon didn't exist (note, all my other icons work fine).

Am I missing something? Or is it just a case of adding the missing icons? Which I don't know how to do...

Font-awesome 6

Hi,

Thanks for your work on this ๐Ÿ‘

I was wondering if there are plans to update this gem to support font-awesome 6? Or perhaps a new gem?

fix blink problem with turbolinks

Hello
I am trying to add font awesome 5 on my rails 5.2 project.
but it is showing the following errors.
FontAwesome.config.mutateApproach = 'sync'; // fix blink problem with turbolinks
i have notice that, only <%= fa_icon('user') %> this tag is showing, but <%= far_icon('camera-retro') %> this is not working.
how can i solve this problem?
Thank you

Add option in fa_icon to return actual SVG or file reference

I'd like some option in fa_icon to return the underlying svg data. I don't care exactly how to request it, but it could be (for example) "direct: true". E.g., given this call:

fa_icon('camera-retro', type: :solid, direct: true)

It would return something like this:

<svg class="svg-inline--fa fa-camera-retro fa-w-16" aria-hidden="true" data-fa-i2svg="" data-prefix="fas" data-icon="camera-retro" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
  <path fill="currentColor" d="M48 32C21.5 32 0 53.5 0 80v352c0 26.5 21.5 48 48 48h416c26.5 0 48-21.5 48-48V80c0-26.5-21.5-48-48-48H48zm0 32h106c3.3 0 6 2.7 6 6v20c0 3.3-2.7 6-6 6H38c-3.3 0-6-2.7-6-6V80c0-8.8 7.2-16 16-16zm426 96H38c-3.3 0-6-2.7-6-6v-36c0-3.3 2.7-6 6-6h138l30.2-45.3c1.1-1.7 3-2.7 5-2.7H464c8.8 0 16 7.2 16 16v74c0 3.3-2.7 6-6 6zM256 424c-66.2 0-120-53.8-120-120s53.8-120 120-120 120 53.8 120 120-53.8 120-120 120zm0-208c-48.5 0-88 39.5-88 88s39.5 88 88 88 88-39.5 88-88-39.5-88-88-88zm-48 104c-8.8 0-16-7.2-16-16 0-35.3 28.7-64 64-64 8.8 0 16 7.2 16 16s-7.2 16-16 16c-17.6 0-32 14.4-32 32 0 8.8-7.2 16-16 16z"></path>
</svg>

In addition, or instead, it'd nice to have an img src="..." or at least the filename, so that I could simply refer to the asset filename (using the usual asset pipeline), and then user clients could cache it for later.

The first approach provides immediate display (but can't be cached on the user side easily), while the second one may cause a little delay but can be easily cached on the user side.

Rationale: I don't want JavaScript to always walk through HTML DOM just to figure out how to replace the "i"s with SVGs. It's slow on the client, and it doesn't work when users disable JavaScript (yes, I have such users).

Thanks!

font_awesome5.css not loading in production environment

We're getting the following error in our production environment:
Failed to load resource: the server responded with a status of 404: font_awesome5.css
It also shows in our production logs as
ActionController::RoutingError (No route matches [GET] "/assets/font_awesome5.css"

Our icons are loading correctly, but for some reason we still get this error in the dev tools console. We think it may be increasing the load on our server so we need to get it fixed.

I can confirm we have the @import 'font_awesome5.css' line in our application.sass

When looking for font_awesome5.css on our production instance, it isn't there. However in staging and development environments, the file is correctly under assets and the above error is not encountered.

Have you any idea what may be causing our issue?

cannot load such file -- sassc

  • rails 7 app
  • installed gem with bundle add font_awesome5_rails
  • ran bundle install
  • ran bundle
  • added *= require font_awesome5_webfont to application.css
  • restarted server
  • added <%= fa_icon "fa_guitar" %> to .html.erb view
  • navigated to page and received the following error:
Screen Shot 2023-10-28 at 9 09 14 PM

stack trace:

bootsnap (1.16.0) lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:17:in `require'
bootsnap (1.16.0) lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:17:in `require'
zeitwerk (2.6.12) lib/zeitwerk/kernel.rb:38:in `require'
sprockets (4.2.1) lib/sprockets/autoload/sassc.rb:2:in `<main>'
bootsnap (1.16.0) lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
bootsnap (1.16.0) lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
zeitwerk (2.6.12) lib/zeitwerk/kernel.rb:38:in `require'
sprockets (4.2.1) lib/sprockets/sassc_processor.rb:42:in `initialize'
sprockets (4.2.1) lib/sprockets/sassc_processor.rb:27:in `new'
sprockets (4.2.1) lib/sprockets/sassc_processor.rb:27:in `instance'
sprockets (4.2.1) lib/sprockets/sassc_processor.rb:31:in `call'
sprockets (4.2.1) lib/sprockets/processor_utils.rb:84:in `call_processor'
sprockets (4.2.1) lib/sprockets/processor_utils.rb:66:in `block in call_processors'
sprockets (4.2.1) lib/sprockets/processor_utils.rb:65:in `reverse_each'
sprockets (4.2.1) lib/sprockets/processor_utils.rb:65:in `call_processors'
sprockets (4.2.1) lib/sprockets/processor_utils.rb:22:in `block in <class:CompositeProcessor>'
sprockets (4.2.1) lib/sprockets/processor_utils.rb:33:in `call'
sprockets (4.2.1) lib/sprockets/processor_utils.rb:84:in `call_processor'
sprockets (4.2.1) lib/sprockets/processor_utils.rb:66:in `block in call_processors'
sprockets (4.2.1) lib/sprockets/processor_utils.rb:65:in `reverse_each'
sprockets (4.2.1) lib/sprockets/processor_utils.rb:65:in `call_processors'
sprockets (4.2.1) lib/sprockets/loader.rb:184:in `load_from_unloaded'
sprockets (4.2.1) lib/sprockets/loader.rb:59:in `block in load'
sprockets (4.2.1) lib/sprockets/loader.rb:339:in `fetch_asset_from_dependency_cache'
sprockets (4.2.1) lib/sprockets/loader.rb:43:in `load'
sprockets (4.2.1) lib/sprockets/cached_environment.rb:44:in `block in load'
concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/map.rb:207:in `block in fetch_or_store'
concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/map.rb:187:in `fetch'
concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/map.rb:206:in `fetch_or_store'
sprockets (4.2.1) lib/sprockets/cached_environment.rb:44:in `load'
sprockets (4.2.1) lib/sprockets/bundle.rb:41:in `block in call'
sprockets (4.2.1) lib/sprockets/utils.rb:175:in `dfs'
sprockets (4.2.1) lib/sprockets/bundle.rb:42:in `call' 
sprockets (4.2.1) lib/sprockets/processor_utils.rb:84:in `call_processor'
sprockets (4.2.1) lib/sprockets/processor_utils.rb:66:in `block in call_processors'
sprockets (4.2.1) lib/sprockets/processor_utils.rb:65:in `reverse_each'
sprockets (4.2.1) lib/sprockets/processor_utils.rb:65:in `call_processors'
sprockets (4.2.1) lib/sprockets/loader.rb:184:in `load_from_unloaded'
sprockets (4.2.1) lib/sprockets/loader.rb:59:in `block in load'
sprockets (4.2.1) lib/sprockets/loader.rb:339:in `fetch_asset_from_dependency_cache'
sprockets (4.2.1) lib/sprockets/loader.rb:43:in `load'
sprockets (4.2.1) lib/sprockets/cached_environment.rb:44:in `block in load'
concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/map.rb:207:in `block in fetch_or_store'
concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/map.rb:187:in `fetch'
concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/map.rb:206:in `fetch_or_store'
sprockets (4.2.1) lib/sprockets/cached_environment.rb:44:in `load'
sprockets (4.2.1) lib/sprockets/bundle.rb:32:in `block in call'
/Users/michaelmarchand/.rbenv/versions/3.1.4/lib/ruby/3.1.0/set.rb:511:in `each_key'
/Users/michaelmarchand/.rbenv/versions/3.1.4/lib/ruby/3.1.0/set.rb:511:in `each'
sprockets (4.2.1) lib/sprockets/bundle.rb:31:in `call'
sprockets (4.2.1) lib/sprockets/processor_utils.rb:84:in `call_processor'
sprockets (4.2.1) lib/sprockets/processor_utils.rb:66:in `block in call_processors'
sprockets (4.2.1) lib/sprockets/processor_utils.rb:65:in `reverse_each'
sprockets (4.2.1) lib/sprockets/processor_utils.rb:65:in `call_processors'
sprockets (4.2.1) lib/sprockets/loader.rb:184:in `load_from_unloaded'
sprockets (4.2.1) lib/sprockets/loader.rb:59:in `block in load'
sprockets (4.2.1) lib/sprockets/loader.rb:339:in `fetch_asset_from_dependency_cache'
sprockets (4.2.1) lib/sprockets/loader.rb:43:in `load'
sprockets (4.2.1) lib/sprockets/cached_environment.rb:44:in `block in load'
concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/map.rb:207:in `block in fetch_or_store'
concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/map.rb:187:in `fetch'
concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/map.rb:206:in `fetch_or_store'
sprockets (4.2.1) lib/sprockets/cached_environment.rb:44:in `load'
sprockets (4.2.1) lib/sprockets/base.rb:81:in `find_asset'
sprockets (4.2.1) lib/sprockets/base.rb:88:in `find_all_linked_assets'
sprockets (4.2.1) lib/sprockets/manifest.rb:125:in `each'
sprockets (4.2.1) lib/sprockets/manifest.rb:125:in `to_a'
sprockets (4.2.1) lib/sprockets/manifest.rb:125:in `block (2 levels) in find'
concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/executor/safe_task_executor.rb:24:in `block in execute'
concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:48:in `block in synchronize'
concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:48:in `synchronize'
concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/synchronization/mutex_lockable_object.rb:48:in `synchronize'
concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/executor/safe_task_executor.rb:22:in `execute'
concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/promise.rb:564:in `block in realize' 
concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:352:in `run_task'
concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:343:in `block (3 levels) in create_worker'
concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:334:in `loop'
concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:334:in `block (2 levels) in create_worker'
concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:333:in `catch'
concurrent-ruby (1.2.2) lib/concurrent-ruby/concurrent/executor/ruby_thread_pool_executor.rb:333:in `block in create_worker' 

FYSA: am using tailwindcss

Issue with missing icons

It seems that this gem clashes with other gems that use the old syntax for font-awesome. Test the 'wysiwyg-rails' gem (froala) for further inspection. Is there anyway to keep compatibility issues to a bare minimum? I tried to put @import "font-awesome" and "font-awesome-sprockets" above @import "font-awesome5" but certain icons are missing on the froalaEditor interface.

Thanks

Allow use of icons as inline svg

I currently have a helper that does this (instead of letting the JS do stuff):

module FontawesomeHelper
  def fa_inline_icon(name, style:, size: nil, **options)
    file = read_file(fa_inline_asset_path(name, style))

    size ||= 'w-5 h-5'

    doc = Nokogiri::XML(file)
    svg = doc.root
    svg[:fill] = 'currentColor'
    classes = [size, options[:class], svg[:class]].flatten.compact.join ' '
    svg[:class] = classes if classes
    ActiveSupport::SafeBuffer.new(svg.to_s)
  end

  def fa_inline_asset_path(name, style)
    URI.parse(Rails.application.assets.resolve("fa5/#{style}/#{name}.svg").first).path
  end
end

Would be great to get something like this into the gem. Would you be open to a pull request? This helper is specific to tailwind, but I guess I could make it more generic (not set the size as a separate option).

Prevent Chrome from jumping to the top of the page on remote forms

Rails version: 5.2.2
Google Chrome version on Windows 10: 79.0.3945.88 (Official Build) (64-bit)

Whenever I submit a remote form that manipulates the DOM and contains an icon from Font Awesome, the page jumps to the top on Google Chrome. I am not using Turbolinks, so I presume the jump is because it's trying to refresh the page. This Stack Overflow post I wrote describes the issue with some code snippets.

I've tried changing the mutateApproach configuration setting at the end of application.js like so:

FontAwesome.config.mutateApproach = 'async';

However, this has not fixed the issue. One alternative for me is to install using webfonts, but I would prefer not to lose the ability to use animations or layered icons.

Do you have any suggestions for how to solve the issue? This jump creates a poor user experience on my site, which has a large percentage of Google Chrome users.

Support Fontawesome 5.0.13

First of all, thanks for this great gem!

I'd like to use some icons from FA 5.0.11, so an update would be appreciated - I'm not in too much of an hurry- just wanted to let you know.

Cheers!

Set type option for each stacked icon

There should be a way to define type for each stacked icon.

For example,

<%= fa_stacked_icon "terminal inverse", base: "square", type: "fas", class: "fa-4x" %>

The above works perfectly fine.

But what if I want the terminal icon to be "fas" and the square icon to be "far". Is there already a way to define it? I couldn't find it in the documentation.

Change displayed fonts after page load

I'm looking to display an animated spinner font on user click, using the SVG + JS option.

I'm finding the font isn't displaying though. I'm guessing it's because the JS has to be ran and only runs on page load. Is there anyway to call that JS when you add a font to the DOM after page load?

couldn't find file 'font_awesome5' with type 'text/css'

I'm getting the following error using version 0.2.4.

My pages render correctly. The error only occurs in my tests.

Error:
Admin::SearchesControllerTest#test_0003_#index - filter by ip_province:
ActionView::Template::Error: couldn't find file 'font_awesome5' with type 'text/css'
Checked in these paths: 
  /Users/henry/mrkey/development/mrkey/app/assets/config
  /Users/henry/mrkey/development/mrkey/app/assets/images
  /Users/henry/mrkey/development/mrkey/app/assets/javascripts
  /Users/henry/mrkey/development/mrkey/app/assets/stylesheets
  /Users/henry/mrkey/development/mrkey/lib/assets/billing
  /Users/henry/mrkey/development/mrkey/lib/assets/import
  /Users/henry/.rvm/gems/ruby-2.4.1/gems/mrkey-selectize-1.3.0/app/assets/javascripts
  /Users/henry/.rvm/gems/ruby-2.4.1/gems/jquery-ui-rails-6.0.1/app/assets/images
  /Users/henry/.rvm/gems/ruby-2.4.1/gems/jquery-ui-rails-6.0.1/app/assets/javascripts
  /Users/henry/.rvm/gems/ruby-2.4.1/gems/jquery-ui-rails-6.0.1/app/assets/stylesheets
  /Users/henry/.rvm/gems/ruby-2.4.1/gems/jquery-rails-4.3.1/vendor/assets/javascripts
  /Users/henry/.rvm/gems/ruby-2.4.1/gems/font-awesome-rails-4.7.0.3/app/assets/fonts
  /Users/henry/.rvm/gems/ruby-2.4.1/gems/font-awesome-rails-4.7.0.3/app/assets/stylesheets
  /Users/henry/.rvm/gems/ruby-2.4.1/gems/cloudinary-1.8.2/vendor/assets/html
  /Users/henry/.rvm/gems/ruby-2.4.1/gems/cloudinary-1.8.2/vendor/assets/javascripts
  /Users/henry/.rvm/gems/ruby-2.4.1/gems/chartkick-2.2.5/app/assets/javascripts
  /Users/henry/.rvm/gems/ruby-2.4.1/gems/chartkick-2.2.5/vendor/assets/javascripts
  /Users/henry/.rvm/gems/ruby-2.4.1/gems/coffee-rails-4.2.2/lib/assets/javascripts
  /Users/henry/.rvm/gems/ruby-2.4.1/gems/actioncable-5.1.4/lib/assets/compiled
  /Users/henry/.rvm/gems/ruby-2.4.1/gems/actionview-5.1.4/lib/assets/compiled
  /Users/henry/.rvm/gems/ruby-2.4.1/gems/turbolinks-source-5.1.0/lib/assets/javascripts
  /Users/henry/mrkey/development/mrkey/node_modules
  /Users/henry/.rvm/gems/ruby-2.4.1/gems/popper_js-1.12.9/assets/javascripts
  /Users/henry/.rvm/gems/ruby-2.4.1/gems/bootstrap-4.0.0/assets/stylesheets
  /Users/henry/.rvm/gems/ruby-2.4.1/gems/bootstrap-4.0.0/assets/javascripts
    app/assets/stylesheets/application.scss:16
    app/views/layouts/admin.html.erb:7:in `_app_views_layouts_admin_html_erb__2129801279448301864_70212484526020'
    app/controllers/application_controller.rb:36:in `render'
    test/controllers/admin/searches_controller_test.rb:23:in `block in <class:SearchesControllerTest>'

Any suggestions?

Pro icons not working

I've been trying to use the pro icons but can't make it work.
I download de SVG files, save them in app/assets/svg folder.

Add this line to config/initializers/assets.rb
Rails.application.config.assets.precompile += %w( svg/* )

Try using icons with both the HTML and GEM Helpers:
<%= fa_icon('analytics', type: :fas) %> <i class="fas fa-analytics"></i>

Restarted my server, not working!. What am I missing?

Fonts don't load after AJAX call

When I attempt to add new items from a collection, using AJAX [Get]. The fonts begin showing question marks. Its a strange bug that I've only had while calling font awesome assets with JS. I am using the tags to optimize the resource throughput. But, still - I don't know why AJAX isn't retrieving the fonts. When I load the view in a normal situation, as in refreshing the page - it works without issue. Do you know why font awesome resources might not be loading for AJAX requests?

Gem not installed in rails 4.1.8, i got gem dependency

Bundler could not find compatible versions for gem "railties":
  In snapshot (Gemfile.lock):
    railties (= 4.1.8)

  In Gemfile:
    ....
    ....
    font_awesome5_rails (>= 0) ruby depends on
      railties (< 5.2, >= 4.2) ruby

Running `bundle update` will rebuild your snapshot from scratch, using only
the gems in your Gemfile, which may resolve the conflict.

I am not able to install this gem in my machine, can any explain me what i will going to do?

Constants don't load properly in Rails 6.1

I've been using font_awesome5_rails for years with no problems. Recently I upgraded my app to Rails 6.1. There are no problems on initial load of the server, but if I make changes anywhere in the code without restarting the server, I get this error:

uninitialized constant FontAwesome5::Rails::IconHelper::FaIconParser

This is the case even if the code I change has nothing to do with this gem.

I'm guessing there's an incompatibility with zeitwerk somewhere in the gem, but I'm not sure how to fix it.

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.