Extract helper

This commit is contained in:
David Heinemeier Hansson
2025-10-29 18:27:07 +01:00
parent b0d697d6dc
commit 7877ab286f
2 changed files with 7 additions and 6 deletions
+6
View File
@@ -40,4 +40,10 @@ module CardsHelper
tag.meta(property: "og:image", content: @card.image.attached? ? "#{request.base_url}#{url_for(@card.image)}" : "#{request.base_url}/app-icon.png") +
tag.meta(property: "og:url", content: card_url(@card))
end
def button_to_remove_card_image(card)
button_to(card_image_path(card), method: :delete, class: "btn", data: { controller: "tooltip" }) do
icon_tag("trash") + tag.span("Remove background image", class: "for-screen-reader")
end
end
end
+1 -6
View File
@@ -21,11 +21,6 @@
<%= render "cards/messages", card: @card if @card.published? || @card.drafted? %>
<%= render "layouts/lightbox" do %>
<% if @card.image.attached? %>
<%= button_to card_image_path(@card), method: :delete, class: "btn", data: { controller: "tooltip" } do %>
<%= icon_tag "trash" %>
<span class="for-screen-reader">Remove background image</span>
<% end %>
<% end %>
<%= button_to_remove_card_image(@card) if @card.image.attached? %>
<% end %>
</div>