Created
March 1, 2022 16:38
-
-
Save jmarsh24/175f68dc7d8e0828e68f6753acb61f9e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div | |
<% unless user_signed_in? %> | |
data-controller="popper" | |
<% end %> | |
> | |
<%= content_tag "div", { id: "downvote-#{video.id}", | |
data: { "popper-target": "element", | |
action: "click->popper#show click@window->popper#hide" } } do %> | |
<%= button_to downvote_video_path(video), method: :patch, | |
style: "display: flex; justify-content: center; align-items: center;" do %> | |
<% if user_signed_in? %> | |
<% if current_user.voted_down_on? video %> | |
<%= fa_icon "thumbs-down solid", text: "Dislike", | |
style: "font-size: 30px; margin: 0 10px;" %> | |
<% else %> | |
<%= fa_icon "thumbs-down regular", text: "Dislike", | |
style: "font-size: 30px; margin: 0 10px;" %> | |
<% end %> | |
<% else %> | |
<%= fa_icon "thumbs-down solid", text: "Dislike", | |
style: "font-size: 30px; margin: 0 10px;" %> | |
<% end %> | |
<% end %> | |
<% end %> | |
<div id="tooltip" role="tooltip" data-popper-target="tooltip"> | |
Dislike this video? <br> | |
Sign in to make your opinion count. <br> | |
<br> | |
<%= link_to "Login", new_user_session_path, { "data-turbo-frame": "_top" } %> | |
<div id="arrow" data-popper-arrow></div> | |
</div> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div | |
<% unless user_signed_in? %> | |
data-controller="popper" | |
<% end %> | |
> | |
<%= content_tag "div", { id: "upvote-#{video.id}", data: { "popper-target": "element", action: "click->popper#show click@window->popper#hide" } } do %> | |
<%= button_to upvote_video_path(video), method: :patch, | |
style: "display: flex; justify-content: center; align-items: center;" do %> | |
<% if user_signed_in? %> | |
<% if current_user.voted_up_on? video %> | |
<%= fa_icon "thumbs-up solid", style: "font-size: 30px; margin: 0 10px;" %> | |
<% else %> | |
<%= fa_icon "thumbs-up regular", style: "font-size: 30px; margin: 0 10px;" %> | |
<% end %> | |
<% else %> | |
<%= fa_icon "thumbs-up solid", style: "font-size: 30px; margin: 0 10px;" %> | |
<% end %> | |
<% end %> | |
<% end %> | |
<div id="tooltip" role="tooltip" data-popper-target="tooltip"> | |
Like this video? <br> | |
Sign in to make your opinion count. <br> | |
<br> | |
<%= link_to "Login", new_user_session_path, { "data-turbo-frame": "_top" } %> | |
<div id="arrow" data-popper-arrow></div> | |
</div> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= render "videos/show/like_count", video: @video %> | |
<%= render "videos/show/downvote_link", video: @video %> | |
<%= render "videos/show/upvote_link", video: @video %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="like-buttons"> | |
<%= turbo_frame_tag "#{dom_id(@video)}_vote" do %> | |
<%= render 'videos/show/vote', video: @video %> | |
<% end %> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def upvote | |
@video = Video.find(params[:id]) | |
if current_user.voted_up_on? @video | |
@video.unvote_by current_user | |
else | |
@video.upvote_by current_user | |
end | |
render "videos/show/vote" | |
end | |
def downvote | |
@video = Video.find(params[:id]) | |
if current_user.voted_down_on? @video | |
@video.unvote_by current_user | |
else | |
@video.downvote_by current_user | |
end | |
render "videos/show/vote" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment