From a0b6047d007b36fd91dbe9e4cdfbfd7de9803b21 Mon Sep 17 00:00:00 2001 From: evazion Date: Wed, 31 Mar 2021 23:15:38 -0500 Subject: [PATCH] fix vote buttons. --- .../comment_component.html.erb | 4 +-- .../comment_component/comment_component.scss | 4 +++ .../post_votes_component.html.erb | 4 +-- app/helpers/forum_topics_helper.rb | 4 +-- app/helpers/icon_helper.rb | 36 ++++++++++++++++--- .../src/javascripts/post_tooltips.js | 2 +- 6 files changed, 43 insertions(+), 11 deletions(-) diff --git a/app/components/comment_component/comment_component.html.erb b/app/components/comment_component/comment_component.html.erb index bf29ec764..65e97ae42 100644 --- a/app/components/comment_component/comment_component.html.erb +++ b/app/components/comment_component/comment_component.html.erb @@ -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 %> diff --git a/app/components/comment_component/comment_component.scss b/app/components/comment_component/comment_component.scss index d50b8ca61..1ffa376cb 100644 --- a/app/components/comment_component/comment_component.scss +++ b/app/components/comment_component/comment_component.scss @@ -48,3 +48,7 @@ article.comment { height: 1.5em; } } + +.comment-section img { + border: none !important; +} diff --git a/app/components/post_votes_component/post_votes_component.html.erb b/app/components/post_votes_component/post_votes_component.html.erb index f9186994a..bcee17807 100644 --- a/app/components/post_votes_component/post_votes_component.html.erb +++ b/app/components/post_votes_component/post_votes_component.html.erb @@ -1,7 +1,7 @@ <% 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 %> diff --git a/app/helpers/forum_topics_helper.rb b/app/helpers/forum_topics_helper.rb index efdb9e5b0..0816286fd 100644 --- a/app/helpers/forum_topics_helper.rb +++ b/app/helpers/forum_topics_helper.rb @@ -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 diff --git a/app/helpers/icon_helper.rb b/app/helpers/icon_helper.rb index 4b13dea8c..579f1d400 100644 --- a/app/helpers/icon_helper.rb +++ b/app/helpers/icon_helper.rb @@ -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) diff --git a/app/javascript/src/javascripts/post_tooltips.js b/app/javascript/src/javascripts/post_tooltips.js index 33a2e0037..d2b1a79ae 100644 --- a/app/javascript/src/javascripts/post_tooltips.js +++ b/app/javascript/src/javascripts/post_tooltips.js @@ -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;