app/helpers/kpop_helper.rb in katalyst-kpop-2.0.9 vs app/helpers/kpop_helper.rb in katalyst-kpop-3.0.0.beta.1
- old
+ new
@@ -1,55 +1,32 @@
# frozen_string_literal: true
module KpopHelper
- # Render a modal dialog. Intended for use inside a kpop turbo frame tag.
- # See builder for options.
- def render_kpop(options = {}, &block)
- Kpop::Modal.new(self).render(options, &block)
- end
+ using HTMLAttributesUtils
- # Render a turbo stream action that will dismiss any open kpop modals.
- def dismiss_kpop
- turbo_stream.update("kpop", "")
- end
-
- # Render a turbo frame tag that can be targeted for rendering kpop modals.
- def kpop_frame_tag(**html_attributes, &block)
- html_attributes[:class] ||= "kpop-container"
- html_attributes[:data] ||= {}
- html_attributes[:data][:controller] = "kpop"
- html_attributes[:data][:action] = "scrim:hide@window->kpop#dismiss"
-
- turbo_frame_tag("kpop", **html_attributes) do
- capture(&block) if block
- end
- end
-
# Renders a link that will navigate the kpop turbo frame to the given URL.
# The URL should render a modal response inside a kpop frame tag.
- def kpop_link_to(name = nil, options = nil, html_options = nil, &block)
- default_html_options = {
- data: { turbo: true, turbo_frame: "kpop" },
- }
+ def kpop_link_to(name = nil, options = nil, html_attributes = nil, &block)
+ default_html_attributes = { data: { turbo_frame: "kpop" } }
if block
# Param[name] is the path for the link
- link_to(name, default_html_options.deep_merge(options || {}), &block)
+ link_to(name, default_html_attributes.deep_merge_html_attributes(options || {}), &block)
else
- link_to(name, options, default_html_options.deep_merge(html_options || {}))
+ link_to(name, options, default_html_attributes.deep_merge_html_attributes(html_attributes || {}))
end
end
# Renders a button that will navigate the kpop turbo frame to the given URL.
# The URL should render a modal response inside a kpop frame tag.
- def kpop_button_to(name = nil, options = nil, html_options = nil, &block)
- default_html_options = {
- form: { data: { turbo: true, turbo_frame: "kpop" } },
+ def kpop_button_to(name = nil, options = nil, html_attributes = nil, &)
+ default_html_attributes = {
+ form: { data: { turbo_frame: "kpop" } },
}
- button_to(name, options, default_html_options.deep_merge(html_options || {}), &block)
+ button_to(name, options, default_html_attributes.deep_merge_html_attributes(html_attributes || {}), &)
end
# Renders a button that will close the current kpop modal, if any.
- def kpop_button_close(content = nil, **options, &block)
- content = block ? capture(yield) : content
- tag.button content, data: { action: "click->kpop#dismiss:prevent" }, **options
+ def kpop_button_close(content = nil, **, &block)
+ content = capture(yield) if block
+ tag.button(content, data: { action: "click->kpop--frame#dismiss:prevent" }, **)
end
end