mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
therefore we can compose any controller from it - simplify `help-modal-controller` then - + create a simple `modal-controller` that close on `modal:close` event
16 lines
406 B
JavaScript
16 lines
406 B
JavaScript
import { Controller } from "stimulus";
|
|
import { useOpenAndCloseAsAModal } from "./mixins/useOpenAndCloseAsAModal";
|
|
|
|
export default class extends Controller {
|
|
static targets = ["background", "modal"];
|
|
|
|
connect() {
|
|
useOpenAndCloseAsAModal(this);
|
|
window.addEventListener("modal:close", this.close.bind(this));
|
|
}
|
|
|
|
disconnect() {
|
|
window.removeEventListener("modal:close", this.close);
|
|
}
|
|
}
|