Module: Georgia::UiHelper
- Defined in:
- app/helpers/georgia/ui_helper.rb
Instance Method Summary collapse
- #avatar_url(email, options = {}) ⇒ Object
- #caret_tag ⇒ Object
- #icon_tag(icon_name, options = {}) ⇒ Object
- #link_to_back(url = :back) ⇒ Object
-
#link_to_close ⇒ Object
Link to close modal box.
- #link_to_delete(url, options = {}) ⇒ Object
- #spinner_tag(options = {}) ⇒ Object
- #tooltip_tag(icon, tooltip, options = {}) ⇒ Object
- #welcomed? ⇒ Boolean
Instance Method Details
#avatar_url(email, options = {}) ⇒ Object
4 5 6 7 8 |
# File 'app/helpers/georgia/ui_helper.rb', line 4 def avatar_url(email, ={}) gravatar_id = Digest::MD5.hexdigest(email.try(:downcase)) size = .fetch(:size, '32') "http://gravatar.com/avatar/#{gravatar_id}.png?s=#{size}&d=mm" end |
#caret_tag ⇒ Object
16 17 18 |
# File 'app/helpers/georgia/ui_helper.rb', line 16 def caret_tag content_tag :span, nil, class: 'caret' end |
#icon_tag(icon_name, options = {}) ⇒ Object
10 11 12 13 14 |
# File 'app/helpers/georgia/ui_helper.rb', line 10 def icon_tag icon_name, ={} [:class] ||= '' [:class] << "fa fa-#{icon_name}" content_tag :i, nil, end |
#link_to_back(url = :back) ⇒ Object
25 26 27 |
# File 'app/helpers/georgia/ui_helper.rb', line 25 def link_to_back url=:back link_to icon_tag('level-up fa-rotate-270'), url, class: 'btn btn-back' end |
#link_to_close ⇒ Object
Link to close modal box
35 36 37 |
# File 'app/helpers/georgia/ui_helper.rb', line 35 def link_to_close content_tag :button, icon_tag('times'), class: 'close', data: {dismiss: 'modal'}, aria: {hidden: true}, type: 'button' end |
#link_to_delete(url, options = {}) ⇒ Object
29 30 31 32 |
# File 'app/helpers/georgia/ui_helper.rb', line 29 def link_to_delete url, ={} text = .delete(:text) { "#{icon_tag('trash-o')} Delete".html_safe } link_to text, url, .reverse_merge(data: {confirm: 'Are you sure?'}, method: :delete, class: 'btn btn-danger') end |
#spinner_tag(options = {}) ⇒ Object
20 21 22 23 |
# File 'app/helpers/georgia/ui_helper.rb', line 20 def spinner_tag ={} [:class] = .fetch(:class, 'spinner') content_tag :div, icon_tag('spinner fa-spin fa-4x'), end |
#tooltip_tag(icon, tooltip, options = {}) ⇒ Object
39 40 41 |
# File 'app/helpers/georgia/ui_helper.rb', line 39 def tooltip_tag icon, tooltip, ={} content_tag(:span, icon, .reverse_merge(title: tooltip, class: 'js-tooltip', data: {placement: 'right'})) end |
#welcomed? ⇒ Boolean
43 44 45 |
# File 'app/helpers/georgia/ui_helper.rb', line 43 def welcomed? session[:welcomed] || !(session[:welcomed] = true) end |