Class: Katalyst::Kpop::Turbo::TagBuilder
- Inherits:
-
Object
- Object
- Katalyst::Kpop::Turbo::TagBuilder
- Defined in:
- lib/katalyst/kpop/turbo.rb
Instance Method Summary collapse
-
#dismiss(id: "kpop") ⇒ Object
Render a turbo stream action that will dismiss any open kpop modal.
-
#initialize(builder) ⇒ TagBuilder
constructor
A new instance of TagBuilder.
-
#open(content = nil, id: "kpop") ⇒ Object
Open a modal in the kpop frame identified by
id
either thecontent
passed in or a rendering result determined by therendering
keyword arguments, the content in the block, or the rendering of the content as a record. -
#redirect_to(href, id: "kpop", action: "replace", target: nil) ⇒ Object
Renders a kpop redirect controller response that will escape the frame and navigate to the given URL.
Constructor Details
#initialize(builder) ⇒ TagBuilder
Returns a new instance of TagBuilder.
9 10 11 |
# File 'lib/katalyst/kpop/turbo.rb', line 9 def initialize(builder) @builder = builder end |
Instance Method Details
#dismiss(id: "kpop") ⇒ Object
Render a turbo stream action that will dismiss any open kpop modal.
29 30 31 |
# File 'lib/katalyst/kpop/turbo.rb', line 29 def dismiss(id: "kpop") turbo_stream_action_tag(:kpop_dismiss, target: id) end |
#open(content = nil, id: "kpop") ⇒ Object
Open a modal in the kpop frame identified by id
either the content
passed in or a rendering result determined by the rendering
keyword arguments, the content in the block, or the rendering of the content as a record. Examples:
<%= turbo_stream.kpop.open modal %>
<%= turbo_stream.kpop.open partial: "modals/modal", locals: { record: } %>
<%= turbo_stream.kpop.open do %>
<%= render Kpop::ModalComponent.new(title: "Example") do %>
...
<% end %>
<% end %>
24 25 26 |
# File 'lib/katalyst/kpop/turbo.rb', line 24 def open(content = nil, id: "kpop", **, &) action(:kpop_open, id, content, **, &) end |
#redirect_to(href, id: "kpop", action: "replace", target: nil) ⇒ Object
Renders a kpop redirect controller response that will escape the frame and navigate to the given URL. Note: turbo does not currently snapshot page history accurately when using “advance” (Oct 23).
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/katalyst/kpop/turbo.rb', line 35 def redirect_to(href, id: "kpop", action: "replace", target: nil) turbo_stream_action_tag( :kpop_redirect_to, target: id, href:, data: { turbo_action: action, turbo_frame: target, }, ) end |