-
-
Save multiplegeorges/4289123 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def icon(name, options = {}) | |
# icon("camera-retro") | |
# <i class="icon-camera-retro"></i> | |
# | |
# icon('cogs', :class => 'large nav-item', :size => 1.5) | |
# <i class='icon-cogs large nav-item', style='font-size:1.5em'></i> | |
classes = ['icon-'+name] | |
classes << options[:class].split(' ') if options[:class].present? | |
classes = classes.flatten.join(' ') | |
size = options[:size] | |
html = "<i class='#{classes}' " | |
html << "style='font-size:#{size}em' " if size.present? | |
html << "></i>" | |
html.html_safe | |
end | |
def button_icon(text, url, name, size=1.5, *options) | |
#button_icon("Camera Retro button", "#","refresh",1) | |
#<a class="button refresh" href="#"><i style="font-size:1.5em" class="icon-refresh"></i> Camera Retro button</a> | |
class_to_add = "button #{name}" | |
options.each { |opt| class_to_add += " #{opt}" } if !options.empty? | |
link_to(url, html_options = { :class => class_to_add }) {icon(name, 1.5) + " " + text} | |
end | |
def link_icon(text, url, name, size=1, *options) | |
#link_icon("Camera Retro button", "#","refresh",1) | |
# <a class="refresh" href="#"><i style="font-size:1.5em" class="icon-refresh"></i> Camera Retro button</a> | |
class_to_add = "#{name}" | |
options.each { |opt| class_to_add += " #{opt}" } if !options.empty? | |
link_to(url, html_options = { :class => class_to_add }) {icon(name, size) + " " + text} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment