README.md in material_icons-2.2.1 vs README.md in material_icons-4.0.0
- old
+ new
@@ -1,30 +1,28 @@
-[](http://badge.fury.io/rb/material_icons) [](https://travis-ci.org/Angelmmiguel/material_icons) [](https://codeclimate.com/github/Angelmmiguel/material_icons) [](https://www.codacy.com/app/angelmm/material_icons) [](https://coveralls.io/github/Angelmmiguel/material_icons?branch=master)
+[](http://badge.fury.io/rb/material_icons) [](https://github.com/Angelmmiguel/material_icons/actions?query=workflow%3ARuby)

# Material Icons for Rails
-[Google Material Icons](https://google.github.io/material-design-icons/) is a +900 set of icons based on Material Design guidelines. With this gem you can add it easily to your Rails projects.
+[Material Design Icons](https://google.github.io/material-design-icons/) is a **+2500 set of icons** based on Material Design guidelines. You can check all the icons in the [official site](https://fonts.google.com/icons?selected=Material+Icons).
-## Google Material Icons v2.2.2
+**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 updates Material Icons to [v2.2.2](https://github.com/google/material-design-icons/releases/tag/2.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` file you need to reference material icons CSS. There are two versions: ligature or unicode (See [Compatibility](#compatibility) section for more info).
+In your `app/assets/stylesheets/application.css.erb` file you need to reference material icons CSS.
-Add this line at top of `application.css` to use ligature:
+Add this line at top of `application.css`:
```css
/*
*= require material_icons
*/
@@ -32,15 +30,107 @@
**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](http://guides.rubyonrails.org/asset_pipeline.html#manifest-files-and-directives) for more info.
These files provide multiple CSS classes to use in your views. Main classes are:
- .material-icons, .mi
+```
+.material-icons, .mi
+```
-Some CSS classes are provided too:
+## Upgrade from v2.X to 4.X
+The `v4.X` version changed how the icon shapes are set. Before, this gem used a `method_missing` approach (`mi.face`). Due to the amount of conflicting icon shape names, in `v4.X` I introduced the `shape` method to set the icon shape:
+
+```ruby
+# In v2.X
+mi.face
+
+# In v4.X
+mi.shape(:face)
```
+
+When upgrading to v4.X, you will need to update all the calls to the `mi` and `material_icon` helpers.
+
+## Other styles
+
+This gem supports the new Google Material Icons styles. They are imported as a different CSS stylesheet, so you can set only the icons that are required for your project. You can set just one style or several ones.
+
+Every CSS stylesheet includes everything you need to use that style. If you don't plan to use the regular style, feel free to include any of the next styles and remove the `*= require material_icons` line from your `application.css.erb` file.
+
+### Outlined
+
+```css
+/*
+*= require material_icons.outlined
+*/
+```
+
+Usage in your template:
+
+```
+<%= material_icon.shape(:face).outlined %>
+# <i class="material-icons outlined">face</i>
+```
+
+### Sharp
+
+```css
+/*
+*= require material_icons.sharp
+*/
+```
+
+Usage in your template:
+
+```
+<%= material_icon.shape(:face).sharp %>
+# <i class="material-icons sharp">face</i>
+```
+
+### Round
+
+```css
+/*
+*= require material_icons.round
+*/
+```
+
+Usage in your template:
+
+```
+<%= material_icon.shape(:face).round %>
+# <i class="material-icons round">face</i>
+```
+
+### Two Tone
+
+```css
+/*
+*= require material_icons.twotone
+*/
+```
+
+Usage in your template:
+
+```
+<%= material_icon.shape(:face).twotone %>
+# <i class="material-icons twotone">face</i>
+```
+
+## Helper classes
+
+This gem includes several helper sizes. To add them to your project, add the following stylesheet:
+
+```css
+/*
+*= require material_icons.helpers
+*/
+```
+
+After adding it, the following helpers will be available:
+
+```
/* Size */
.md-18
.md-24
.md-36
.md-48
@@ -68,29 +158,34 @@
```html
<i class="material-icons">face</i>
<i class="material-icons md-36">face</i>
```
-## Helpers
+## Ruby 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 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. **[Remember you first need to add the helpers stylesheet to use these helpers](#helper-classes)**.
+Using same example:
+
```
-<%= material_icon.face %>
+<%= material_icon.shape(:face) %>
# <i class="material-icons">face</i>
-<%= material_icon.face.md_36 %>
+<%= material_icon.shape(: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 %>
+# You can use string too
+<%= material_icon.shape('3d_rotation').md_36 %>
# <i class="material-icons md-36">3d_rotation</i>
# Rotation and custom css class
-<%= mi.face.r90.css_class('my_class') %>
+<%= mi.shape(:face).r90.css_class('my_class') %>
# <i class="material-icons r90 my_class">face</i>
+
+# Custom css and data attributes
+<%= mi.shape(:face).css_class('my_class').html(data: {id: 1}) %>
+# <i data-id="1" class="material-icons my_class">face</i>
```
Allowed methods are:
```
@@ -117,89 +212,69 @@
html({ data: { id: 1 } })
```
Remember this is a helper, you always can use HTML syntax ;).
-# Slim templating engine
-
-If you are using [Slim templating engine](http://slim-lang.com/) 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](https://github.com/rails/rails/blob/4-2-stable/actionview/lib/action_view/helpers/tag_helper.rb#L146)).
-
-```
-p.text
- == material_icon.search.md_18
-```
-
-Reference [#9](https://github.com/Angelmmiguel/material_icons/issues/9)
-
# Compatibility
Ligature feature requires a supported browser:
-Browser | Version
+Browser | Version
---- | ----
-Google Chrome | >= 11
-Mozilla Firefox | >= 3.5
-Apple Safari | >= 5
-Microsoft IE | >= 10
-Opera | >= 15
+Google Chrome | >= 11
+Mozilla Firefox | >= 3.5
+Apple Safari | >= 5
+Microsoft IE | >= 10
+Opera | >= 15
Apple MobileSafari | >= iOS 4.2
-Android Browser | >= 3.0
+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:
+You can find the current browser support in [_can I use?_](https://caniuse.com/kerning-pairs-ligatures).
-```css
-/*
-*= require material_icons_unicode
-*/
-```
+# Common issues
-**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](http://guides.rubyonrails.org/asset_pipeline.html#manifest-files-and-directives) for more info.
+## Slim templating engine
-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:
+If you are using [Slim templating engine](http://slim-lang.com/) 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](https://github.com/rails/rails/blob/4-2-stable/actionview/lib/action_view/helpers/tag_helper.rb#L146)).
-```ruby
-# Initialize material icons setup
-MaterialIcons.setup do |config|
- config.unicode = true
-end
```
+p.text
+ == material_icon.shape(:search).md_18
+```
-The [Helpers](#helpers) has the same syntax.
+Reference [#9](https://github.com/Angelmmiguel/material_icons/issues/9)
-Now, the text inside of HTML tag is the CSS class! CSS Icon classes use underscores.
+## Couldn't find file 'material_icons'
-```html
-<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>
```
+couldn't find file 'material_icons' with type 'application/javascript'
+```
-This version increase the size of the CSS file too. To see the difference, these are the size for uncompressed CSS files:
+This error is related with the asset compilation of Rails. To fix it, just follow these steps:
-File | Size
----- | ----
-material_icons.css.erb | 3 KB
-material_icons_unicode.css.erb | 68 KB
+* Confirm that you [required the Material Icons CSS in your main CSS file](#CSS)
+* Check and remove any similar line of code from `app/assets/javascripts/application.js.erb`
+* Restart your rails server.
+Reference [#10](https://github.com/Angelmmiguel/material_icons/issues/10)
+
# Tested on
-Tested with [Travis CI](https://travis-ci.org/Angelmmiguel/material_icons).
+Tested with [GitHub Actions](https://github.com/Angelmmiguel/material_icons/actions?query=workflow%3ARuby).
Ruby versions:
-* 2.3.1
-* 2.2.2
-* 2.1.2
+* 2.6
+* 2.7
+* 3.0
+* 3.1
Rails versions:
-* 3.2
-* 4.0
-* 4.1
-* 4.2
-* master
+* 6.0
+* 6.1
+* 7.0
# They are using Material icons for Rails :)
* [Materialup.com](http://www.materialup.com): a big community to share, discover and learn about Material Design.
* [Easy Bills](https://www.easybills.io): a free tool to manage your finances.
@@ -207,6 +282,6 @@
# License
Google Material Icons are under [Apache License v2.0](http://www.apache.org/licenses/LICENSE-2.0). _We'd love attribution in your app's about screen, but [it's not required](https://github.com/google/material-design-icons#license)_.
-Material Icons gem is released under the MIT license. Copyright [@Laux_es ;)](https://twitter.com/Laux_es)
+Material Icons gem is released under the MIT license. Copyright [Angel M Miguel](https://angel.kiwi)