Add a rails helper for the new custom stream action

This commit is contained in:
Jorge Manrubia
2025-04-10 13:30:15 +02:00
parent 468bbf1388
commit 168a790687
2 changed files with 9 additions and 2 deletions
@@ -2,5 +2,5 @@
<%= render partial: "cards/stagings/stages", locals: { card: @card } %>
<% end %>
<turbo-stream action="set_css_variable" target="<%= dom_id(@card, :card_container) %>" name="--card-color" value="<%= @card.color %>"></turbo-stream>
<turbo-stream action="set_css_variable" target="<%= dom_id(@card, :ticket) %>" name="--card-color" value="<%= @card.color %>"></turbo-stream>
<%= turbo_stream.set_css_variable dom_id(@card, :card_container), name: "--card-color", value: @card.color %>
<%= turbo_stream.set_css_variable dom_id(@card, :ticket), name: "--card-color", value: @card.color %>
@@ -0,0 +1,7 @@
module TurboStreamsActionsHelper
def set_css_variable(target, name:, value:)
tag.turbo_stream target: target, action: "set_css_variable", name:, value:
end
end
Turbo::Streams::TagBuilder.prepend(TurboStreamsActionsHelper)