Pull out new_comment_placeholder helper

This commit is contained in:
Jose Farias
2024-10-28 10:23:40 -06:00
parent 404755c9d9
commit 79869858da
2 changed files with 13 additions and 7 deletions
+8
View File
@@ -3,4 +3,12 @@ module CommentsHelper
tag.div id: dom_id(comment), class: "comment flex align-start full-width",
data: { creator_id: comment.creator_id, created_by_current_user_target: "creation" }, &
end
def new_comment_placeholder(bubble)
if bubble.creator == Current.user && bubble.messages.comments.empty?
"Add some notes…"
else
"Type your comment…"
end
end
end
+5 -7
View File
@@ -7,14 +7,12 @@
</div>
<div class="comment__body txt-align-start margin-block-start-half">
<%= form_with model: Comment.new, url: bucket_bubble_comments_path(bubble.bucket, bubble), class: "flex flex-column gap full-width", data: { controller: "form", action: "keydown.meta+enter->form#submit" } do |form| %>
<%= form.text_area :body, class: "input", required: true, rows: 4,
placeholder: (bubble.messages.comments.empty? && bubble.creator == Current.user) ? "Add some notes…" : "Type your comment…" %>
<%= form.button class: "btn btn--reversed center" do %>
<%= image_tag "check.svg", aria: { hidden: "true" }, size: 24 %>
<span class="for-screen-reader">Save</span>
<%= form.text_area :body, class: "input", required: true, rows: 4, placeholder: new_comment_placeholder(bubble) %>
<%= form.button class: "btn btn--reversed center" do %>
<%= image_tag "check.svg", aria: { hidden: "true" }, size: 24 %>
<span class="for-screen-reader">Save</span>
<% end %>
<% end %>
<% end %>
</div>
</div>
</div>