Module: Facades::SassExtensions::Icons
- Defined in:
- lib/facades/sass_extensions/icons.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#icon_entity(name, set = 'facades') ⇒ Object
Creates a entity representation of the unicode character.
-
#icon_font_name(name) ⇒ Object
Maps a “pack” name to a font name.
-
#icon_font_url(name, type, extra = '') ⇒ Object
Get the url for the icon font file, based on type.
-
#icon_glyph(name, set = 'facades') ⇒ Object
Creates a unicode entity for use in a content: description in css.
-
#icon_names(set = "facades") ⇒ Object
Create a sass list of icon names from an icon pack.
-
#icon_version(set = 'facades') ⇒ Object
Shows relevant version information on an icon pack.
Class Method Details
.glyph_sets ⇒ Object
6 7 8 |
# File 'lib/facades/sass_extensions/icons.rb', line 6 def glyph_sets @glyph_sets ||= {} end |
Instance Method Details
#icon_entity(name, set = 'facades') ⇒ Object
Creates a entity representation of the unicode character. Used in IE7/legacy support.
24 25 26 |
# File 'lib/facades/sass_extensions/icons.rb', line 24 def icon_entity(name, set = 'facades') Sass::Script::String.new("#{icon_glyph_value(name, set)}; ") end |
#icon_font_name(name) ⇒ Object
Maps a “pack” name to a font name.
32 33 34 35 36 37 |
# File 'lib/facades/sass_extensions/icons.rb', line 32 def icon_font_name(name) Sass::Script::String.new({ 'facades' => 'FacadesRegular', 'font-awesome' => 'FontAwesome' }[name]) end |
#icon_font_url(name, type, extra = '') ⇒ Object
Get the url for the icon font file, based on type. Only works if the font author has provided a cdn ( such as font awesome )
45 46 47 48 49 50 51 52 |
# File 'lib/facades/sass_extensions/icons.rb', line 45 def icon_font_url(name, type, extra = '') name = name.value if name.respond_to?(:value) type = type.value if type.respond_to?(:value) fonts = icon_data(name)['fonts'] url = fonts[type.to_s].to_s ::Rails.logger.info(url.inspect) Sass::Script::String.new(url) end |
#icon_glyph(name, set = 'facades') ⇒ Object
Creates a unicode entity for use in a content: description in css.
15 16 17 |
# File 'lib/facades/sass_extensions/icons.rb', line 15 def icon_glyph(name, set = 'facades') Sass::Script::String.new("\\#{icon_glyph_value(name, set)}") end |
#icon_names(set = "facades") ⇒ Object
Create a sass list of icon names from an icon pack.
58 59 60 61 62 63 |
# File 'lib/facades/sass_extensions/icons.rb', line 58 def icon_names(set = "facades") listing = icon_translations(set) keys = (listing.keys || []) keys = keys.collect{ |k| Sass::Script::String.new(k) } Sass::Script::List.new(keys, ',') end |
#icon_version(set = 'facades') ⇒ Object
Shows relevant version information on an icon pack
69 70 71 72 |
# File 'lib/facades/sass_extensions/icons.rb', line 69 def icon_version(set = 'facades') set = set.value if set.respond_to?(:value) Sass::Script::String.new(icon_data(set)['version']) end |