Fatcow
This adds some basic helpers to rails that let you use the Fatcow icon set in all of it's early-2010s glory.
You can browse the icons via wikimedia.
Installation
To install, simply add it to your gemfile,
gem 'fatcow'
then add the (optional) stylesheet to your template:
<%= stylesheet_link_tag 'fatcow/application', "data-turbo-track": "reload" %>
and you're good to go!
How to use
In any view, just use the fci
helper to place an arbitrary icon.
<%= fci :note %>
You can also include a status, which is a small icon placed in the bottom left hand corner of the icon.
<%= fci :note, :add %>
Use with models
You can also assign an icon to a model,
which will then be displayable with a status reflecting the current state of the record.
Add the has_icon
macro into your model definition, and you're good to go.
class Alert < ActiveRecord
has_icon :bell
end
There are some default statuses (:add
for new records, :edit
for persisted records in a form, etc.)
but you can include + overwrite statues using the same macro.
Provide show
statuses to be used with record.show_icon
and form
statuses to be used with record.form_icon
.
Include the name of the status as the key, and the value should be a Proc
that returns true/false,
and is executed in the context of the record instance.
class Alert < ActiveRecord
has_icon :bell, show: { attach: -> { has_attachment? } }, form: { warning: -> { invalid? } }
end
Then, to show your icon in a view, just call either #show_icon
(when showing the resource) or #form_icon
(when
displaying a form) on a record instance, and pass it to fci
.
You cannot do this on collections, though that may be coming later.
<%= fci @alert.show_icon %>
All Icons
Licensing
FatCow web icons are licensed under a Creative Commons Attribution 3.0 License. This library has opted to do the same because I'm not a lawyer and I have no idea what I'm doing.
All icons are attributed to FatCow, who formerly hosted the icons at http://www.fatcow.com/free-icons. (Archive)