42
42
</ p >
43
43
44
44
< div class ="btn-group ">
45
- < div class ="me-2 ">
45
+ < div class ="me-2 mt-2 ">
46
46
<%= @likes_count %> <%= Like . model_name . human ( count : @likes_count ) %>
47
47
</ div >
48
48
<% if @liked %>
49
- <%= button_to 'Descurtir' , post_like_path ( @post , @liked ) , method : :delete , class : 'btn btn-danger btn-sm' %>
49
+ <%= button_to post_like_path ( @post , @liked ) , method : :delete , class : 'btn btn-sm' , id : 'unlike' do %>
50
+ <%= image_tag 'thumbs-up-solid' , width : '20rem' %>
51
+ <% end %>
50
52
<% else %>
51
- <%= button_to 'Curtir' , post_likes_path ( @post ) , method : :post , class : 'btn btn-primary btn-sm' %>
53
+ <%= button_to post_likes_path ( @post ) , method : :post , class : 'btn btn-sm' , id : 'like' do %>
54
+ <%= image_tag 'thumbs-up-regular' , width : '20rem' %>
55
+ <% end %>
52
56
<% end %>
53
57
</ div >
54
58
</ div >
65
69
<%= @post . comments . count %> <%= Comment . model_name . human ( count : @post . comments . count ) %>
66
70
</ div >
67
71
<% @post . comments . each do |comment | %>
68
- < div class ="card-body " id ="comment- <%= comment . id %> ">
72
+ < div class ="card-body " id ="<%= dom_id ( comment ) %> ">
69
73
< blockquote class ="blockquote mb-0 ">
70
74
< p > <%= comment . message %> </ p >
71
75
< footer class ="blockquote-footer ">
74
78
</ blockquote >
75
79
76
80
<% if comment . user . deleted_at . nil? %>
77
- < div class ="btn-group ">
78
- < div class ="me-2 ">
79
- <%= comment . likes . count %> <%= Like . model_name . human ( count : comment . likes . count ) %>
80
- </ div >
81
+ < div class ="btn-group flex-column ">
82
+ < div class ="d-flex ">
83
+ < div class ="mt-2 me-2 ">
84
+ <%= comment . likes . count %> <%= Like . model_name . human ( count : comment . likes . count ) %>
85
+ </ div >
81
86
82
- < div class ="me-2 ">
83
- <% if user_signed_in? && comment . likes . where ( user_id : current_user . id ) . any? %>
84
- <% like = comment . likes . find_by ( user_id : current_user . id ) %>
85
- <%= button_to 'Descurtir' , comment_like_path ( comment , like ) , method : :delete , class : 'btn btn-danger btn-sm' %>
86
- <% else %>
87
- <%= button_to 'Curtir' , comment_likes_path ( comment ) , method : :post , class : 'btn btn-primary btn-sm' %>
88
- <% end %>
89
- </ div >
87
+ < div class ="me-2 ">
88
+ <% if user_signed_in? && comment . likes . where ( user_id : current_user . id ) . any? %>
89
+ <% like = comment . likes . find_by ( user_id : current_user . id ) %>
90
+ <%= button_to comment_like_path ( comment , like ) , method : :delete , class : 'btn btn-sm' , id : 'unlike' do %>
91
+ <%= image_tag 'thumbs-up-solid' , width : '20rem' , class : 'mb-4' %>
92
+ <% end %>
93
+ <% else %>
94
+ <%= button_to comment_likes_path ( comment ) , method : :post , class : 'btn btn-sm' , id : 'like' do %>
95
+ <%= image_tag 'thumbs-up-regular' , width : '20rem' , class : 'mb-2' %>
96
+ <% end %>
97
+ <% end %>
98
+ </ div >
99
+ </ div >
90
100
91
101
<% if current_user != comment . user %>
92
102
< div class ="report-link-wrapper ">
97
107
<% end %>
98
108
</ div >
99
109
<% end %>
100
- </ div >
110
+ </ div >
111
+
112
+ < script >
113
+ document . addEventListener ( 'turbo:load' , ( ) => {
114
+ if ( window . location . pathname === "/posts/<%= @post . id %> " ) {
115
+ const anchor_tag = window . location . hash ;
116
+ if ( anchor_tag ) {
117
+ const comment = document . querySelector ( anchor_tag ) ;
118
+ if ( comment ) {
119
+ comment . classList . add ( 'highlighted' ) ;
120
+ setTimeout ( function ( ) {
121
+ comment . classList . remove ( 'highlighted' ) ;
122
+ } , 4000 ) ;
123
+ }
124
+ }
125
+ } ;
126
+ } ) ;
127
+ </ script >
0 commit comments