views: factor out FontAwesome icons.
Factor out FontAwesome icons into a set of helpers. This is so that it's easier to keep track of which icons we're using and easier to change icons globally.
This commit is contained in:
@@ -20,4 +20,14 @@ module ForumTopicsHelper
|
||||
:rejected
|
||||
end
|
||||
end
|
||||
|
||||
def forum_post_vote_icon(vote)
|
||||
if vote.score == 1
|
||||
upvote_icon
|
||||
elsif vote.score == -1
|
||||
downvote_icon
|
||||
else
|
||||
meh_icon
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
130
app/helpers/icon_helper.rb
Normal file
130
app/helpers/icon_helper.rb
Normal file
@@ -0,0 +1,130 @@
|
||||
module IconHelper
|
||||
def icon_tag(icon_class, class: nil, **options)
|
||||
klass = binding.local_variable_get(:class)
|
||||
tag.i(class: "icon #{icon_class} #{klass}", **options)
|
||||
end
|
||||
|
||||
def upvote_icon(**options)
|
||||
icon_tag("far fa-thumbs-up", **options)
|
||||
end
|
||||
|
||||
def downvote_icon(**options)
|
||||
icon_tag("far fa-thumbs-down", **options)
|
||||
end
|
||||
|
||||
def sticky_icon(**options)
|
||||
icon_tag("fas fa-thumbtack", **options)
|
||||
end
|
||||
|
||||
def lock_icon(**options)
|
||||
icon_tag("fas fa-lock", **options)
|
||||
end
|
||||
|
||||
def delete_icon(**options)
|
||||
icon_tag("fas fa-trash-alt", **options)
|
||||
end
|
||||
|
||||
def undelete_icon(**options)
|
||||
icon_tag("fas fa-trash-restore_alt", **options)
|
||||
end
|
||||
|
||||
def private_icon(**options)
|
||||
icon_tag("fas fa-hand-paper", **options)
|
||||
end
|
||||
|
||||
def menu_icon(**options)
|
||||
icon_tag("fas fa-bars", **options)
|
||||
end
|
||||
|
||||
def close_icon(**options)
|
||||
icon_tag("fas fa-times", **options)
|
||||
end
|
||||
|
||||
def search_icon(**options)
|
||||
icon_tag("fas fa-search", **options)
|
||||
end
|
||||
|
||||
def bookmark_icon(**options)
|
||||
icon_tag("fas fa-bookmark", **options)
|
||||
end
|
||||
|
||||
def favorite_icon(**options)
|
||||
icon_tag("far fa-heart", **options)
|
||||
end
|
||||
|
||||
def comments_icon(**options)
|
||||
icon_tag("far fa-comments", **options)
|
||||
end
|
||||
|
||||
def spinner_icon(**options)
|
||||
icon_tag("fas fa-spinner fa-spin", **options)
|
||||
end
|
||||
|
||||
def external_link_icon(**options)
|
||||
icon_tag("fas fa-external-link-alt", **options)
|
||||
end
|
||||
|
||||
def checkmark_icon(**options)
|
||||
icon_tag("fas fa-check-circle", **options)
|
||||
end
|
||||
|
||||
def exclamation_icon(**options)
|
||||
icon_tag("fas fa-exclamation-triangle", **options)
|
||||
end
|
||||
|
||||
def meh_icon(**options)
|
||||
icon_tag("far fa-meh", **options)
|
||||
end
|
||||
|
||||
def avatar_icon(**options)
|
||||
icon_tag("fas fa-user-circle", **options)
|
||||
end
|
||||
|
||||
def medal_icon(**options)
|
||||
icon_tag("fas fa-medal", **options)
|
||||
end
|
||||
|
||||
def negative_icon(**options)
|
||||
icon_tag("fas fa-times-circle", **options)
|
||||
end
|
||||
|
||||
def message_icon(**options)
|
||||
icon_tag("far fa-envelope", **options)
|
||||
end
|
||||
|
||||
def gift_icon(**options)
|
||||
icon_tag("fas fa-gift", **options)
|
||||
end
|
||||
|
||||
def feedback_icon(**options)
|
||||
icon_tag("fas fa-file-signature", **options)
|
||||
end
|
||||
|
||||
def promotion_icon(**options)
|
||||
icon_tag("fas fa-user-plus", **options)
|
||||
end
|
||||
|
||||
def ban_icon(**options)
|
||||
icon_tag("fas fa-user-slash", **options)
|
||||
end
|
||||
|
||||
def chevron_left_icon(**options)
|
||||
icon_tag("fas fa-chevron-left", **options)
|
||||
end
|
||||
|
||||
def chevron_right_icon(**options)
|
||||
icon_tag("fas fa-chevron-right", **options)
|
||||
end
|
||||
|
||||
def ellipsis_icon(**options)
|
||||
icon_tag("fas fa-ellipsis-h", **options)
|
||||
end
|
||||
|
||||
def edit_icon(**options)
|
||||
icon_tag("fas fa-edit", **options)
|
||||
end
|
||||
|
||||
def flag_icon(**options)
|
||||
icon_tag("fas fa-flag", **options)
|
||||
end
|
||||
end
|
||||
@@ -29,9 +29,9 @@ module PaginationHelper
|
||||
window = 4
|
||||
|
||||
if records.current_page >= 2
|
||||
html << "<li class='arrow'>" + link_to(content_tag(:i, nil, class: "fas fa-chevron-left"), nav_params_for(records.current_page - 1), rel: "prev", id: "paginator-prev", "data-shortcut": "a left") + "</li>"
|
||||
html << "<li class='arrow'>" + link_to(chevron_left_icon, nav_params_for(records.current_page - 1), rel: "prev", id: "paginator-prev", "data-shortcut": "a left") + "</li>"
|
||||
else
|
||||
html << "<li class='arrow'><span>" + content_tag(:i, nil, class: "fas fa-chevron-left") + "</span></li>"
|
||||
html << "<li class='arrow'><span>" + chevron_left_icon + "</span></li>"
|
||||
end
|
||||
|
||||
if records.total_pages <= (window * 2) + 5
|
||||
@@ -69,9 +69,9 @@ module PaginationHelper
|
||||
end
|
||||
|
||||
if records.current_page < records.total_pages && records.present?
|
||||
html << "<li class='arrow'>" + link_to(content_tag(:i, nil, class: "fas fa-chevron-right"), nav_params_for(records.current_page + 1), rel: "next", id: "paginator-next", "data-shortcut": "d right") + "</li>"
|
||||
html << "<li class='arrow'>" + link_to(chevron_right_icon, nav_params_for(records.current_page + 1), rel: "next", id: "paginator-next", "data-shortcut": "d right") + "</li>"
|
||||
else
|
||||
html << "<li class='arrow'><span>" + content_tag(:i, nil, class: "fas fa-chevron-right") + "</span></li>"
|
||||
html << "<li class='arrow'><span>" + chevron_right_icon + "</span></li>"
|
||||
end
|
||||
|
||||
html << "</menu></div>"
|
||||
@@ -92,7 +92,7 @@ module PaginationHelper
|
||||
html = []
|
||||
if page == "..."
|
||||
html << "<li class='more'>"
|
||||
html << content_tag(:i, nil, class: "fas fa-ellipsis-h")
|
||||
html << ellipsis_icon
|
||||
html << "</li>"
|
||||
elsif page == current_page
|
||||
html << "<li class='current-page'>"
|
||||
|
||||
Reference in New Issue
Block a user