Module: ModalStack::Helpers::ModalLinkHelper
- Defined in:
- lib/modal_stack/helpers/modal_link_helper.rb
Overview
View helper that turns a regular link into a modal stack trigger. Falls back to plain link_to when the request comes from Hotwire Native (cf. RFC §15 Q3 — “don’t break” policy on native shells).
<%= modal_link_to "Edit", edit_project_path(@project) %>
<%= modal_link_to "Details", project_path(@project), as: :drawer, side: :right %>
Constant Summary collapse
- LINK_CONTROLLER =
"modal-stack-link"- LINK_CLICK_ACTION =
"click->modal-stack-link#open"- MODAL_OPTION_KEYS =
%i[as side size width height dismissible].freeze
Instance Method Summary collapse
Instance Method Details
#modal_link_to(name = nil, options = nil, html_options = nil, &block) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/modal_stack/helpers/modal_link_helper.rb', line 17 def modal_link_to(name = nil, = nil, = nil, &block) if block_given? = = name name = block end = ( || {}).dup return link_to(name, , , &block) if hotwire_native_request? = .extract!(*MODAL_OPTION_KEYS) [:data] = build_modal_link_data([:data] || {}, ) link_to(name, , , &block) end |