Create a modal with a data attribute to name your modal e.g data-modal-name="modal-name". Then to trigger it via click from an element, simply add a this attribute data-modal-trigger="modal-name"
Dismissing modals, just add an attribute data-modal-dimiss to any element you want to use to dismiss the modal
To trigger a modal dynamically, run the ff: showModal('modal-name')
To hide the modal, just need to run: hideModal();