All Projects → Angelmmiguel → Material_icons

Angelmmiguel / Material_icons

Licence: other
A simple Rails wrapper for Google Material Icons

Projects that are alternatives of or similar to Material icons

Tabler Rubygem
Rubygem for https://tabler.github.io
Stars: ✭ 77 (-71.05%)
Mutual labels:  rails-engine, rails, gem
Spotlight
Spotlight enables librarians, curators, and others who are responsible for digital collections to create attractive, feature-rich websites that highlight these collections.
Stars: ✭ 137 (-48.5%)
Mutual labels:  rails-engine, rails
Rails server timings
Server Timing headers for Rails apps
Stars: ✭ 112 (-57.89%)
Mutual labels:  rails-engine, rails
Workflow core
[Deprecated, use flor_core instead] A Rails engine which providing essential infrastructure of workflow. It's based on Workflow Nets.
Stars: ✭ 171 (-35.71%)
Mutual labels:  rails-engine, rails
Sudo rails
🔒 Sudo mode for your Rails controllers
Stars: ✭ 66 (-75.19%)
Mutual labels:  rails-engine, rails
Thredded
The best Rails forums engine ever.
Stars: ✭ 1,263 (+374.81%)
Mutual labels:  rails-engine, rails
Flipflop
Flipflop lets you declare and manage feature flags in your Rails application.
Stars: ✭ 165 (-37.97%)
Mutual labels:  rails-engine, rails
Maily
📫 Rails Engine to preview emails in the browser
Stars: ✭ 502 (+88.72%)
Mutual labels:  rails-engine, rails
Comfortable Mexican Sofa
ComfortableMexicanSofa is a powerful Ruby on Rails 5.2+ CMS (Content Management System) Engine
Stars: ✭ 2,707 (+917.67%)
Mutual labels:  rails-engine, rails
slackify
Build Slackbot on Rails using Slack Event API
Stars: ✭ 20 (-92.48%)
Mutual labels:  gem, rails-engine
exception hunter
Crash reporting engine to hunt down bugs 🐞
Stars: ✭ 78 (-70.68%)
Mutual labels:  gem, rails-engine
Fae
CMS for Rails. For Reals.
Stars: ✭ 701 (+163.53%)
Mutual labels:  rails-engine, rails
webpay rails
WebpayRails is an easy solution for integrate Transbank Webpay in Rails applications
Stars: ✭ 16 (-93.98%)
Mutual labels:  gem, rails-engine
Comfy Blog
Blog Engine for ComfortableMexicanSofa (Rails 5.2+)
Stars: ✭ 98 (-63.16%)
Mutual labels:  rails-engine, rails
Rails email preview
Preview and edit app mailer templates in Rails.
Stars: ✭ 524 (+96.99%)
Mutual labels:  rails-engine, rails
Redis web manager
Manage your Redis instance (see keys, memory used, connected client, etc...)
Stars: ✭ 139 (-47.74%)
Mutual labels:  rails-engine, rails
Forest Rails
🌱 Rails Liana for Forest Admin
Stars: ✭ 247 (-7.14%)
Mutual labels:  rails, gem
Stitches
Create a Microservice in Rails with minimal ceremony
Stars: ✭ 371 (+39.47%)
Mutual labels:  rails-engine, gem
Form core
A Rails engine providing ability to generate dynamic form.
Stars: ✭ 175 (-34.21%)
Mutual labels:  rails-engine, rails
multi-tenancy-devise
mtdevise adds basecamp style user logins to your ruby on rails application.
Stars: ✭ 27 (-89.85%)
Mutual labels:  gem, rails-engine

Gem Version Build Status Code Climate Codacy Badge Coverage Status Month donations

Material Icons for Rails

Material Icons for Rails

Material Design Icons is a +900 set of icons based on Material Design guidelines. You can check all the icons in the official site.

This gem helps you to add this fantastic icon collection to your Rails projects easily. I keep the gem updated so you always will have the latest icons in your project.

Google Material Icons v2.2.2

Google updates Material Icons to v2.2.2. It's include 41 new icons!

Installation

To install the gem, add this line to your Gemfile:

gem 'material_icons'

Then, execute bundle install.

CSS

In your app/assets/stylesheets/application.css.erb file you need to reference material icons CSS. There are two versions: ligature or unicode (See Compatibility section for more info).

Add this line at top of application.css to use ligature:

/*
*= require material_icons
*/

NOTE: Depending on the comment style of application.css, you may need to add //= require material_icons instead of the previous line. See Rails Asset Pipeline for more info.

These files provide multiple CSS classes to use in your views. Main classes are:

.material-icons, .mi

Some CSS classes are provided too:

/* Size */
.md-18
.md-24
.md-36
.md-48

/* Color */
.md-dark
.md-light

/* Rotation */
.r90
.r180
.r270
.flip-horizontal
.flip-vertical

Don't forget to see material_icons.css.erb ;).

Views

Google Material Icons uses a feature called ligatures. We can define the icon in the text of the HTML tag. Go to Google Guide to get more info.

An example of icon is:

<i class="material-icons">face</i>
<i class="material-icons md-36">face</i>

Helpers

Material Icons provide two helpers to build the HTML code of icons. The methods are material_icon and mi. These helpers use cascade style to set the icon and options. Using same example:

<%= material_icon.face %>
# <i class="material-icons">face</i>

<%= material_icon.face.md_36 %>
# <i class="material-icons md-36">face</i>

# This is a special case because the icon name starts with a number. Only
# 3d_rotation has this trouble.
<%= material_icon.three_d_rotation.md_36 %>
# <i class="material-icons md-36">3d_rotation</i>

# Rotation and custom css class
<%= mi.face.r90.css_class('my_class') %>
# <i class="material-icons r90 my_class">face</i>

# Custom css and data attributes
<%= mi.face.css_class('my_class').html(data: {id: 1}) %>
# <i data-id="1" class="material-icons my_class">face</i>

Allowed methods are:

# Rotation methods
r90
r180
r270
flip_horizontal
flip_vertical

# Size methods
md_18
md_24
md_36
md_48

# Add some classes to the icon
css_class('classes')

# Add style to the icon
style('margin-top: 5px;')

# Add some HTML attributes to an icon. This method receive a Hash
html({ data: { id: 1 } })

Remember this is a helper, you always can use HTML syntax ;).

Compatibility

Ligature feature requires a supported browser:

Browser Version
Google Chrome >= 11
Mozilla Firefox >= 3.5
Apple Safari >= 5
Microsoft IE >= 10
Opera >= 15
Apple MobileSafari >= iOS 4.2
Android Browser >= 3.0

To increase compatibility you can use Unicode version of the library. To set Unicode icons, you need to change the line to load ligature CSS file on app/assets/stylesheets/application.css (*= require material_icons) to this line:

/*
*= require material_icons_unicode
*/

NOTE: Depending on the comment style of application.css, you may need to add //= require material_icons_unicode instead of the previous line. See Rails Asset Pipeline for more info.

Next, you need to specify the helper to use unicode because it uses ligatures by default. Create an initializer file on config/initializers/material_icons.rb and set this content:

# Initialize material icons setup
MaterialIcons.setup do |config|
  config.unicode = true
end

The Helpers has the same syntax.

Now, the text inside of HTML tag is the CSS class! CSS Icon classes use underscores.

<i class="material-icons face"></i>
<i class="mi md-36 face"></i>
<i class="mi add_box"></i>
<i class="mi three_d_rotation"></i>

This version increase the size of the CSS file too. To see the difference, these are the size for uncompressed CSS files:

File Size
material_icons.css.erb 3 KB
material_icons_unicode.css.erb 68 KB

Common issues

Slim templating engine

If you are using Slim templating engine in your Rails application, use double equal == method to render icons or the content won't be marked as HTML safe. We are working on this issue, because we use content_tag and it sets the text as HTML safe (see ActionView::Helpers::TagHelper line 146).

p.text
  == material_icon.search.md_18

Reference #9

Couldn't find file 'material_icons'

couldn't find file 'material_icons' with type 'application/javascript'

This error is related with the asset compilation of Rails. To fix it, just follow these steps:

Reference #10

Tested on

Tested with Travis CI.

Ruby versions:

  • 2.5.0
  • 2.4.3
  • 2.3.6
  • 2.2.9
  • 2.1.10

Rails versions:

  • 3.2
  • 4.0
  • 4.1
  • 4.2
  • 5.0
  • master

They are using Material icons for Rails :)

  • Materialup.com: a big community to share, discover and learn about Material Design.
  • Easy Bills: a free tool to manage your finances.
  • Notebook.ai: your digital notebook is here. Notebook.ai grows with your ideas and collaborates back with you.

License

Google Material Icons are under Apache License v2.0. We'd love attribution in your app's about screen, but it's not required.

Material Icons gem is released under the MIT license. Copyright @Laux_es ;)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].