fix vote buttons.

This commit is contained in:
evazion
2021-03-31 23:15:38 -05:00
parent fff68e1d16
commit a0b6047d00
6 changed files with 43 additions and 11 deletions

View File

@@ -48,7 +48,7 @@
<% if current_user.is_anonymous? %>
<%= link_to upvote_icon, login_path(url: request.fullpath), class: "comment-upvote-link inactive-link" %>
<% elsif upvoted? %>
<%= link_to upvote_icon, comment_vote_path(current_vote), class: "comment-upvote-link comment-unvote-link active-link", method: :delete, remote: true %>
<%= link_to upvote_icon(active: true), comment_vote_path(current_vote), class: "comment-upvote-link comment-unvote-link active-link", method: :delete, remote: true %>
<% else %>
<%= link_to upvote_icon, comment_comment_votes_path(comment_id: comment.id, score: "1"), class: "comment-upvote-link inactive-link", method: :post, remote: true %>
<% end %>
@@ -64,7 +64,7 @@
<% if current_user.is_anonymous? %>
<%= link_to downvote_icon, login_path(url: request.fullpath), class: "comment-downvote-link inactive-link" %>
<% elsif downvoted? %>
<%= link_to downvote_icon, comment_vote_path(current_vote), class: "comment-downvote-link comment-unvote-link active-link", method: :delete, remote: true %>
<%= link_to downvote_icon(active: true), comment_vote_path(current_vote), class: "comment-downvote-link comment-unvote-link active-link", method: :delete, remote: true %>
<% else %>
<%= link_to downvote_icon, comment_comment_votes_path(comment_id: comment.id, score: "-1"), class: "comment-downvote-link inactive-link", method: :post, remote: true %>
<% end %>

View File

@@ -48,3 +48,7 @@ article.comment {
height: 1.5em;
}
}
.comment-section img {
border: none !important;
}

View File

@@ -1,7 +1,7 @@
<span class="post-votes" data-id="<%= post.id %>">
<% if can_vote? %>
<% if upvoted? %>
<%= link_to upvote_icon, post_post_votes_path(post_id: post.id), class: "post-upvote-link post-unvote-link active-link", method: :delete, remote: true %>
<%= link_to upvote_icon(active: true, post: post), post_post_votes_path(post_id: post.id), class: "post-upvote-link post-unvote-link active-link", method: :delete, remote: true %>
<% else %>
<%= link_to upvote_icon, post_post_votes_path(post_id: post.id, score: 1), class: "post-upvote-link inactive-link", method: :post, remote: true %>
<% end %>
@@ -11,7 +11,7 @@
<% if can_vote? %>
<% if downvoted? %>
<%= link_to downvote_icon, post_post_votes_path(post_id: post.id), class: "post-downvote-link post-unvote-link active-link", method: :delete, remote: true %>
<%= link_to downvote_icon(active: true, post: post), post_post_votes_path(post_id: post.id), class: "post-downvote-link post-unvote-link active-link", method: :delete, remote: true %>
<% else %>
<%= link_to downvote_icon, post_post_votes_path(post_id: post.id, score: -1), class: "post-downvote-link inactive-link", method: :post, remote: true %>
<% end %>

View File

@@ -25,9 +25,9 @@ module ForumTopicsHelper
def forum_post_vote_icon(vote)
if vote.score == 1
upvote_icon
tag.img(src: "https://cdn.discordapp.com/emojis/814623669392375809.png?v=1", width: 24, height: 24)
elsif vote.score == -1
downvote_icon
tag.img(src: "https://cdn.discordapp.com/emojis/814335138376056843.png?v=1", width: 24, height: 24)
else
meh_icon
end

View File

@@ -17,13 +17,41 @@ module IconHelper
end
# fontawesome.com/icons/arrow-alt-up
def upvote_icon(**options)
svg_icon_tag("upvote-icon", "M272 480h-96c-13.3 0-24-10.7-24-24V256H48.2c-21.4 0-32.1-25.8-17-41L207 39c9.4-9.4 24.6-9.4 34 0l175.8 176c15.1 15.1 4.4 41-17 41H296v200c0 13.3-10.7 24-24 24z", **options)
def upvote_icon(active: false, post: nil, **options)
if !active
svg_icon_tag("upvote-icon", "M272 480h-96c-13.3 0-24-10.7-24-24V256H48.2c-21.4 0-32.1-25.8-17-41L207 39c9.4-9.4 24.6-9.4 34 0l175.8 176c15.1 15.1 4.4 41-17 41H296v200c0 13.3-10.7 24-24 24z", **options)
elsif post&.has_tag?("fate/grand_order")
tag.img(src: "https://cdn.discordapp.com/emojis/653748516224761908.gif?v=1", height: 24)
elsif post&.has_tag?("touhou")
tag.img(src: "https://cdn.discordapp.com/emojis/827033081197101066.png?v=1", height: 24)
elsif post&.has_tag?("kantai_collection")
tag.img(src: "https://cdn.discordapp.com/emojis/733153966917156866.png?v=1", height: 24)
elsif post&.has_tag?("azur_lane") && post.rating != "s"
tag.img(src: "https://cdn.discordapp.com/emojis/801657092439277569.png?v=1", height: 24)
elsif post&.has_tag?("hololive") && post.rating == "s"
tag.img(src: "https://cdn.discordapp.com/emojis/772303879051149312.png?v=1", height: 24)
elsif post&.has_tag?("hololive") && post.rating != "s"
tag.img(src: "https://cdn.discordapp.com/emojis/759597982176903212.gif?v=1", height: 24)
elsif post&.has_tag?("arknights")
tag.img(src: "https://cdn.discordapp.com/emojis/701113445713445004.gif?v=1", height: 24)
elsif post&.has_tag?("fire_emblem")
tag.img(src: "https://cdn.discordapp.com/emojis/625999795882033163.png?v=1", height: 24)
elsif post&.has_tag?("foot_focus")
tag.img(src: "https://cdn.discordapp.com/emojis/795007213919928361.png?v=1", height: 24)
elsif post&.has_tag?("albert_yi")
tag.img(src: "https://cdn.discordapp.com/emojis/380454608096722956.png?v=1", height: 24)
else
tag.img(src: "https://cdn.discordapp.com/emojis/688562186930618391.png?v=1", class: "prov", height: 20)
end
end
# fontawesome.com/icons/arrow-alt-down
def downvote_icon(**options)
svg_icon_tag("downvote-icon", "M176 32h96c13.3 0 24 10.7 24 24v200h103.8c21.4 0 32.1 25.8 17 41L241 473c-9.4 9.4-24.6 9.4-34 0L31.3 297c-15.1-15.1-4.4-41 17-41H152V56c0-13.3 10.7-24 24-24z", **options)
def downvote_icon(active: false, post: nil, **options)
if !active
svg_icon_tag("downvote-icon", "M176 32h96c13.3 0 24 10.7 24 24v200h103.8c21.4 0 32.1 25.8 17 41L241 473c-9.4 9.4-24.6 9.4-34 0L31.3 297c-15.1-15.1-4.4-41 17-41H152V56c0-13.3 10.7-24 24-24z", **options)
else
tag.img(src: "https://cdn.discordapp.com/emojis/769954192050618439.png?v=1", class: "prov", height: 20)
end
end
def sticky_icon(**options)

View File

@@ -5,7 +5,7 @@ import 'tippy.js/dist/tippy.css';
let PostTooltip = {};
PostTooltip.POST_SELECTOR = "*:not(.ui-sortable-handle) > .post-preview img, .dtext-post-id-link";
PostTooltip.POST_SELECTOR = "*:not(.ui-sortable-handle) > .post-preview img:not(.prov), .dtext-post-id-link";
PostTooltip.SHOW_DELAY = 500;
PostTooltip.HIDE_DELAY = 125;
PostTooltip.DURATION = 250;