TurboModal
Turbo Frame driven modal
Usage
Turbo modal provides helpers to add a basic scrim and modal target frame. These should be placed inside the body:
“ml
Maruku could not parse this XML/HTML:
<body>
“
Import turbo_modal styles
“s /* application.scss /
@import “~@katalyst-interactive/turbo-modal”;
“
Import turbo_modal stimulus controllers
“ /* application.js / import TurboModal from “@katalyst-interactive/turbo-modal” application.load(TurboModal)
“
Show a modal
To get a modal displaying you will need 2 things: 1. A modal_link
(or programmatic trigger) 2. Some modal_content
modal_link
‘s are similar to a link_to
in rails but it will point the path of the link to target the modal turbo frame. The resulting path will need to wrap some content in a modal_content
helper tag.
eg:
“ml <%= modal_link “click to open modal”, modal_path(“example”) %>
“
“ml <%= modal_content do %>
Modal title
<% end %>
“
Installation
Run these commands:
“sh $ bundle add ‘turbo_modal’ $ rails turbo_modal:install
“
rails turbo_modal:install
will add the turbo_modal
npm packages required. It also sets up stimulus and turbo packages.
License
The gem is available as open source under the terms of the MIT License.