Module: KpopHelper

Defined in:
app/helpers/kpop_helper.rb

Instance Method Summary collapse

Instance Method Details

#kpop_button_close(content = nil, &block) ⇒ Object

Renders a button that will close the current kpop modal, if any.



28
29
30
31
# File 'app/helpers/kpop_helper.rb', line 28

def kpop_button_close(content = nil, **, &block)
  content = capture(yield) if block
  tag.button(content, data: { action: "click->kpop--frame#dismiss:prevent" }, **)
end

#kpop_button_to(name = nil, options = nil, html_attributes = nil) ⇒ Object

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.



20
21
22
23
24
25
# File 'app/helpers/kpop_helper.rb', line 20

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_attributes.deep_merge_html_attributes(html_attributes || {}), &)
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.



8
9
10
11
12
13
14
15
16
# File 'app/helpers/kpop_helper.rb', line 8

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_attributes.deep_merge_html_attributes(options || {}), &block)
  else
    link_to(name, options, default_html_attributes.deep_merge_html_attributes(html_attributes || {}))
  end
end