Skip to content

Commit de584f9

Browse files
committed
feature/Restly like and comment button
1 parent 6cf8d4b commit de584f9

File tree

5 files changed

+30
-16
lines changed

5 files changed

+30
-16
lines changed

app/models/snippet.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ def visible_to?(user)
5656
end
5757
end
5858

59+
def comments?
60+
comments_count > 0
61+
end
62+
63+
def likes?
64+
likes_count > 0
65+
end
66+
5967
private
6068

6169
def owner_folder_presence
Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
1-
<%= link_to snippet_path(snippet, anchor: 'new-comment'), class: "no-underline flex items-center bg-gray-100 rounded-sm px-1 cursor-pointer hover:shadow-md transition" do %>
2-
<%= render partial: 'shared/icons/chat', locals: { width: 5, height: 5, color: 'text-gray-500 mr-1' } %>
1+
<%= link_to snippet_path(snippet, anchor: 'new-comment'), class: "no-underline flex items-center cursor-pointer transition" do %>
2+
<%= render partial: 'shared/icons/chat', locals: { width: 5, height: 5, color: 'text-gray-500' } %>
33
<span
44
data-controller='counts'
55
data-counts-count-value="<%= snippet.comments_count %>"
66
data-action='comment-created@window->counts#increment comment-deleted@window->counts#decrement'
77
data-counts-target="count"
8-
class="inline-block text-sm text-gray-500"
8+
class="inline-block text-sm text-gray-500 ml-1 -mb-0.5"
99
>
10-
<%= snippet.comments_count %>
10+
<% if snippet.comments? %>
11+
<%= snippet.comments_count %>
12+
<% end %>
1113
</span>
1214
<% end %>

app/views/shared/_like_button.html.erb

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<div
2-
class="rounded-sm h-full"
2+
class="relative h-full cursor-pointer transition"
33
<% if user_signed_in? %>
44
data-controller="like"
55
data-like-target="container"
@@ -11,10 +11,12 @@
1111
<% end %>
1212
>
1313
<div
14-
class="flex h-full items-center bg-gray-100 rounded-sm px-1 mr-2 cursor-pointer hover:shadow-md transition"
14+
class="flex h-full items-center mr-2"
1515
data-action="click->like#toggle"
1616
>
1717
<%= render partial: 'shared/icons/heart', locals: { width: 5, height: 5, color: color_for_like_status(snippet) } %>
18-
<span class="inline-block text-sm text-gray-500"><%= snippet.likes_count %></span>
18+
<% if snippet.likes? %>
19+
<span class="inline-block text-sm text-gray-500 ml-1 -mb-0.5"><%= snippet.likes_count %></span>
20+
<% end %>
1921
</div>
2022
</div>

app/views/shared/_nav_item.html.erb

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@
88
<% if path == notifications_path %>
99
<%= notification_counter(current_user) %>
1010
<% end %>
11+
12+
<% if false #temp don't display %>
13+
<div
14+
class="hidden shadow-sm transition px-2 absolute text-sm bg-white text-cyan transform rounded-sm m-auto -bottom-6 left-1/2 -translate-x-2/4"
15+
data-tooltip-target="tooltip"
16+
>
17+
<span><%= page_title %></span>
18+
</div>
19+
<% end %>
1120
12-
<div
13-
class="hidden shadow-sm transition px-2 absolute text-sm bg-white text-cyan transform rounded-sm m-auto -bottom-6 left-1/2 -translate-x-2/4"
14-
data-tooltip-target="tooltip"
15-
>
16-
<span><%= page_title %></span>
17-
</div>
18-
19-
<% if active %>
21+
<% if false #active %>
2022
<div data-controller="tooltip-listener" data-tooltip-listener-target="tooltip" data-action="hide-tooltip@window->tooltip-listener#hide display-tooltip@window->tooltip-listener#display" class="transition shadow-sm px-2 absolute text-sm bg-white text-cyan transform rounded-sm m-auto -bottom-6 left-1/2 -translate-x-2/4">
2123
<span><%= page_title %></span>
2224
</div>

app/views/shared/_topbar.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<%= render partial: 'shared/nav_item', locals: { path: connect_path, page_title: 'Connect', icon: 'connect' } %>
1717
<% end %>
1818

19-
<% if @page_title %>
19+
<% if false #@page_title %>
2020
<div data-controller="tooltip-listener" data-tooltip-listener-target="tooltip" data-action="hide-tooltip@window->tooltip-listener#hide display-tooltip@window->tooltip-listener#display" class="transition shadow-sm px-2 absolute text-sm bg-white text-cyan transform rounded-sm m-auto -bottom-2.5 left-1/2 -translate-x-2/4">
2121
<span><%= @page_title %></span>
2222
</div>

0 commit comments

Comments
 (0)