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:
evazion
2021-01-21 04:12:13 -06:00
parent 748fcdddcf
commit 63e3b4b447
29 changed files with 199 additions and 73 deletions

View File

@@ -2,7 +2,7 @@
class CommentComponent < ApplicationComponent
attr_reader :comment, :context, :dtext_data, :current_user
delegate :link_to_user, :time_ago_in_words_tagged, :format_text, to: :helpers
delegate :link_to_user, :time_ago_in_words_tagged, :format_text, :edit_icon, :delete_icon, :undelete_icon, :flag_icon, to: :helpers
def initialize(comment:, current_user:, context: nil, dtext_data: nil)
@comment = comment

View File

@@ -89,21 +89,18 @@
<% if policy(comment).update? %>
<%= menu.item do %>
<%= link_to edit_comment_path(comment.id), id: "edit_comment_link_#{comment.id}", class: "edit_comment_link" do %>
<i class="icon fas fa-edit"></i>
Edit
<%= edit_icon %> Edit
<% end %>
<% end %>
<%= menu.item do %>
<% if comment.is_deleted? %>
<%= link_to undelete_comment_path(comment.id), method: :post, remote: true do %>
<i class="icon fas fa-trash-restore-alt"></i>
Undelete
<%= undelete_icon %> Undelete
<% end %>
<% else %>
<%= link_to comment_path(comment.id), "data-confirm": "Are you sure you want to delete this comment?", method: :delete, remote: true do %>
<i class="icon fas fa-trash-alt"></i>
Delete
<%= delete_icon %> Delete
<% end %>
<% end %>
<% end %>
@@ -112,8 +109,7 @@
<% if policy(comment).reportable? %>
<%= menu.item do %>
<%= link_to new_moderation_report_path(moderation_report: { model_type: "Comment", model_id: comment.id }), remote: true do %>
<i class="icon fas fa-flag"></i>
Report
<%= flag_icon %> Report
<% end %>
<% end %>
<% end %>

View File

@@ -2,6 +2,7 @@
class PopupMenuComponent < ApplicationComponent
include ViewComponent::SlotableV2
delegate :ellipsis_icon, to: :helpers
renders_many :items
end

View File

@@ -1,6 +1,6 @@
<div class="popup-menu">
<a class="popup-menu-button" href="javascript:void(0)">
<i class="fas fa-ellipsis-h"></i>
<%= ellipsis_icon %>
</a>
<ul class="popup-menu-content">

View File

@@ -4,7 +4,7 @@ class PostPreviewComponent < ApplicationComponent
with_collection_parameter :post
attr_reader :post, :tags, :show_deleted, :show_cropped, :link_target, :pool, :pool_id, :favgroup_id, :similarity, :recommended, :compact, :size, :current_user, :options
delegate :external_link_to, :time_ago_in_words_tagged, to: :helpers
delegate :external_link_to, :time_ago_in_words_tagged, :favorite_icon, to: :helpers
def initialize(post:, tags: "", show_deleted: false, show_cropped: true, link_target: post, pool: nil, pool_id: nil, favgroup_id: nil, similarity: nil, recommended: nil, compact: nil, size: nil, current_user: CurrentUser.user, **options)
@post = post

View File

@@ -38,7 +38,7 @@
<%= link_to recommended_posts_path(search: { post_id: post.id }), class: "more-recommended-posts", "data-post-id": post.id do %>
<%= post.fav_count %>
<i class="far fa-heart fa-xs"></i>
<%= favorite_icon(class: "fa-xs") %>
<br>more »
<% end %>