Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

anyicon

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

anyicon

  • 1.0.2
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Anyicon

Gem Version

Anyicon provides Ruby on Rails view helpers for rendering icons from various collections hosted on GitHub.

How does it work

Anyicon simplifies the process of integrating and using SVG icons from various collections in your Rails application. Here's a breakdown of how it works:

  1. Configuration: You can set up the icon collections you want to use in a Rails initializer (config/initializers/anyicon.rb) or you can use the already defined collections. Each collection is defined by specifying the GitHub repository, the path within the repository where the icons are located, and the branch to use.

  2. Icon Rendering: When you call the anyicon helper in your views, it uses the Anyicon::Icon class to render the SVG content. The helper takes the icon name in the format collection:icon_name and optionally additional HTML properties.

  3. Fetching Icons: If the requested icon is not already cached locally, the gem will fetch the SVG file from the specified GitHub repository. It uses the configuration settings to construct the URL, download the file, and store it in your application's app/assets/images/icons directory. Attention to the license agreement of each collection

  4. Caching: Once downloaded, icons are cached locally to avoid repeated network requests. This ensures that your application remains performant and reduces dependency on external network availability.

  5. Helper Methods: The anyicon helper method simplifies the process of including icons in your views by managing the rendering and fetching process transparently. You can also pass additional HTML attributes to customize the rendered SVG element.

Installation

Add this line to your application's Gemfile:

gem 'anyicon'

And then execute:

bundle install

Or install it yourself as:

gem install anyicon

Usage

You can just use the anyicon helper in your views:

<%= anyicon icon: 'fontawesome_regular:address-book' %>

Configuration

You can configure the icon collections in an initializer:

# config/initializers/anyicon.rb
Anyicon.configure do |config|
  config.collections = {
    my_custom_collection: { repo: 'user/repo', path: 'path/to/icons', branch: 'main' }
  }
end

Collections Available

CollectionGithub ListExampleQuantityLicense
Font-Awesomefontawesome_regularfontawesome_regular:address-book136License
fontawesome_solidfontawesome_solid:award1,392
fontawesome_brandsfontawesome_brands:readme490
Heroiconsheroicons_outlineheroicons_outline:check296MIT
heroicons_solidheroicons_solid:cube296
Tabler Iconstabler_icons_filledtabler_icons_filled:alarm675MIT
tabler_icons_outlinetabler_icons_outline:article4,615
Mage Iconsmage_icons_fillmage_icons_fill:Book449Apache 2.0
mage_icons_strokemage_icons_stroke:Archive545
mage_icons_social_bwmage_icons_social_bw:Github50
mage_icons_social_colormage_icons_social_color:Youtube50
Line Awesomeline_awesomeline_awesome:film1,554MIT/Good Boy License
@carbon/iconscarboncarbon:arrow--left2,212Apache 2.0
IonIconsioniconsionicons:add-sharp1,356MIT
Feather Iconsfeather_iconsfeather_icons:airplay287MIT

Please, read the license before using any of these collections. This gem does not maintain or keep any of those files in it's repository. However, when you use any of the icons they will be automatically saved in /app/assets/images/icons/ folder.

Fell free to add your own collection to this list.

Development

To get started with development:

git clone https://github.com/arthurmolina/anyicon.git
cd heroicon
bundle install
bundle exec rake test

Contributing

Anyone is encouraged to help improve this project. Here are a few ways you can help:

License

The gem is available as open source under the terms of the MIT License.

FAQs

Package last updated on 29 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc