From 168a790687d42454714b31defd8f5fa3948fc08d Mon Sep 17 00:00:00 2001 From: Jorge Manrubia Date: Thu, 10 Apr 2025 13:30:15 +0200 Subject: [PATCH] Add a rails helper for the new custom stream action --- app/views/cards/stagings/create.turbo_stream.erb | 4 ++-- lib/rails_ext/turbo_streams_action_helper.rb | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 lib/rails_ext/turbo_streams_action_helper.rb diff --git a/app/views/cards/stagings/create.turbo_stream.erb b/app/views/cards/stagings/create.turbo_stream.erb index 7b2668a2d..ca33c37bb 100644 --- a/app/views/cards/stagings/create.turbo_stream.erb +++ b/app/views/cards/stagings/create.turbo_stream.erb @@ -2,5 +2,5 @@ <%= render partial: "cards/stagings/stages", locals: { card: @card } %> <% end %> - - +<%= 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 %> diff --git a/lib/rails_ext/turbo_streams_action_helper.rb b/lib/rails_ext/turbo_streams_action_helper.rb new file mode 100644 index 000000000..001c9706e --- /dev/null +++ b/lib/rails_ext/turbo_streams_action_helper.rb @@ -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)