mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-20 05:39:39 +02:00
Initial commit
This commit is contained in:
commit
99de24ac70
147 changed files with 3519 additions and 0 deletions
23
app/javascript/controllers/dropdown_controller.js
Normal file
23
app/javascript/controllers/dropdown_controller.js
Normal file
|
@ -0,0 +1,23 @@
|
|||
import { Controller } from "@hotwired/stimulus"
|
||||
|
||||
// Connects to data-controller="dropdown"
|
||||
export default class extends Controller {
|
||||
static targets = ["menu"]
|
||||
|
||||
toggleMenu(event) {
|
||||
event.stopPropagation(); // Prevent event from closing the menu immediately
|
||||
this.menuTarget.classList.toggle("hidden");
|
||||
}
|
||||
|
||||
hideMenu() {
|
||||
this.menuTarget.classList.add("hidden");
|
||||
}
|
||||
|
||||
connect() {
|
||||
document.addEventListener("click", () => this.hideMenu());
|
||||
}
|
||||
|
||||
disconnect() {
|
||||
document.removeEventListener("click", () => this.hideMenu());
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue