Move github source to private server
This commit is contained in:
9
app/views/comments/_comment.html.erb
Normal file
9
app/views/comments/_comment.html.erb
Normal file
@@ -0,0 +1,9 @@
|
||||
<div class="comment" id="comment_<%= comment.id %>">
|
||||
<div class="comment-header">
|
||||
<span class="comment-user"><%= comment.user.name %></span>
|
||||
<span class="comment-date"><%= time_ago_in_words(comment.created_at) %> ago</span>
|
||||
</div>
|
||||
<div class="comment-content">
|
||||
<%= simple_format(comment.content) %>
|
||||
</div>
|
||||
</div>
|
||||
8
app/views/comments/_form.html.erb
Normal file
8
app/views/comments/_form.html.erb
Normal file
@@ -0,0 +1,8 @@
|
||||
<%= form_with(model: [task, comment], local: false, class: "comment-form") do |f| %>
|
||||
<div class="field">
|
||||
<%= f.text_area :content, placeholder: "Add a comment...", class: "comment-textarea", required: true %>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<%= f.submit "Post Comment", class: "submit-btn" %>
|
||||
</div>
|
||||
<% end %>
|
||||
16
app/views/comments/create.js.erb
Normal file
16
app/views/comments/create.js.erb
Normal file
@@ -0,0 +1,16 @@
|
||||
var commentsList = document.getElementById('comments-list');
|
||||
var commentForm = document.querySelector('.comment-form');
|
||||
|
||||
if (commentsList && <%= @comment.persisted? %>) {
|
||||
var newComment = '<%= j render partial: "comments/comment", locals: { comment: @comment } %>';
|
||||
commentsList.insertAdjacentHTML('afterbegin', newComment);
|
||||
commentForm.reset();
|
||||
|
||||
// Optional: add a small animation
|
||||
var commentElement = document.getElementById('comment_<%= @comment.id %>');
|
||||
commentElement.style.opacity = '0';
|
||||
commentElement.style.transition = 'opacity 0.5s';
|
||||
setTimeout(function() {
|
||||
commentElement.style.opacity = '1';
|
||||
}, 10);
|
||||
}
|
||||
Reference in New Issue
Block a user