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

@@ -7,6 +7,6 @@
<%= hidden_field_tag :random, params[:random] %>
<% end %>
<%= text_field_tag("tags", tags, :id => tags_dom_id, :"data-shortcut" => "q", :"data-autocomplete" => "tag-query") %>
<button id="search-box-submit" type="submit"><i class="fas fa-search"></i></button>
<button id="search-box-submit" type="submit"><%= search_icon %></button>
<% end %>
</section>

View File

@@ -2,7 +2,7 @@
<h2>Options</h2>
<ul>
<% if policy(SavedSearch).create? %>
<li><%= button_tag(tag.i(class: "fas fa-bookmark") + " Save search", id: "save-search", class: "ui-button ui-widget ui-corner-all sub") %></li>
<li><%= button_tag(bookmark_icon + " Save search", id: "save-search", class: "ui-button ui-widget ui-corner-all sub") %></li>
<% end %>
</ul>
</section>

View File

@@ -50,7 +50,9 @@
<%= f.label :tag_string, "Tags" %>
<span data-tag-counter data-for="#post_tag_string"></span>
<a href="javascript:void(0)"><i id="open-edit-dialog" class="fas fa-external-link-alt" title="detach" data-shortcut="shift+e"></i></a>
<a href="javascript:void(0)">
<%= external_link_icon(id: "open-edit-dialog", "data-shortcut": "shift+e") %>
</a>
</div>
<div>

View File

@@ -25,8 +25,8 @@
<% if policy(PostVote).create? %>
<%= tag.span id: "vote-links-for-post-#{post.id}", style: ("display: none;" if !@post.can_be_voted_by?(CurrentUser.user)) do %>
(vote
<%= link_to tag.i(class: "far fa-thumbs-up"), post_post_votes_path(post_id: post.id, score: "up"), remote: true, method: :post %>
<%= link_to tag.i(class: "far fa-thumbs-down"), post_post_votes_path(post_id: post.id, score: "down"), remote: true, method: :post %>)
<%= link_to upvote_icon, post_post_votes_path(post_id: post.id, score: "up"), remote: true, method: :post %>
<%= link_to downvote_icon, post_post_votes_path(post_id: post.id, score: "down"), remote: true, method: :post %>)
<% end %>
<%= tag.span id: "unvote-link-for-post-#{post.id}", style: ("display: none;" if @post.can_be_voted_by?(CurrentUser.user)) do %>
(<%= link_to "undo vote", post_post_votes_path(post), remote: true, method: :delete, class: "unvote-post-link" %>)

View File

@@ -3,18 +3,18 @@
<span class="post-tooltip-favorites post-tooltip-info">
<span><%= @post.fav_count %></span>
<i class="far fa-heart fa-xs"></i>
<%= favorite_icon(class: "fa-xs") %>
</span>
<span class="post-tooltip-score post-tooltip-info">
<span><%= @post.score %></span>
<i class="far fa-thumbs-up fa-xs"></i>
<%= upvote_icon(class: "fa-xs") %>
</span>
<% if @post.last_commented_at.present? %>
<span class="post-tooltip-comments post-tooltip-info">
<span><%= @post.comments.count %></span>
<i class="far fa-comments fa-xs"></i>
<%= comments_icon(class: "fa-xs") %>
</span>
<% end %>
@@ -32,7 +32,7 @@
<%= link_to "#{@post.image_width}x#{@post.image_height}", @post.file_url, class: "post-tooltip-dimensions post-tooltip-info" %>
<%= link_to "#", class: "post-tooltip-disable", title: "Disable enhanced tooltips" do %>
<i class="fas fa-times-circle"></i>
<%= close_icon %>
<% end %>
</div>

View File

@@ -52,11 +52,11 @@
<% if policy(Favorite).create? %>
<%= content_tag(:div, class: "fav-buttons fav-buttons-#{@post.favorited_by?(CurrentUser.user)}") do %>
<%= form_tag(favorites_path(post_id: @post.id), method: "post", id: "add-fav-button", "data-remote": true) do %>
<%= button_tag tag.i(class: "far fa-heart"), class: "ui-button ui-widget ui-corner-all", "data-disable-with": tag.i(class: "fas fa-spinner fa-spin") %>
<%= button_tag favorite_icon, class: "ui-button ui-widget ui-corner-all", "data-disable-with": spinner_icon %>
<% end %>
<%= form_tag(favorite_path(@post.id), method: "delete", id: "remove-fav-button", "data-remote": true) do %>
<%= button_tag tag.i(class: "fas fa-heart"), class: "ui-button ui-widget ui-corner-all", "data-disable-with": tag.i(class: "fas fa-spinner fa-spin") %>
<%= button_tag favorite_icon, class: "ui-button ui-widget ui-corner-all", "data-disable-with": spinner_icon %>
<% end %>
<% end %>
<% end %>