<div><!-- Outside of the modal to trigger the opening --><buttonclass="stimulus-modal-btn">Open modal</button><!-- The Modal itself --><divclass="stimulus-modal-container"><!-- Modal content --><divclass="stimulus-modal-content"><spanclass="close-modal-icon">×</span><p>Inside the modal</p></div></div></div>
2. Refacto it so that you can use it anywhere and pass a block
2.1 use of shared/partial
put in a partial in shared/_modal.html.erb
make it so that it's using dynamic values from locals instead of the Open modal content and the <p>Inside the modal</p> content
2.2 use the power of rails view helpers
use the magic of procs to pass a &block (close to what a yield is)
import{Controller}from"@hotwired/stimulus"// Connects to data-controller="modal"exportdefaultclassextendsController{statictargets=["modal"];openModal(){this.modalTarget.style.display="block";};closeModal(){this.modalTarget.style.display="none";};closeWithKeyboard(e){if(e.code=="Escape"){this.closeModal();};};}