Use tailwind peer instead of javascript
All checks were successful
Ruby CI / test (pull_request) Successful in 23s
All checks were successful
Ruby CI / test (pull_request) Successful in 23s
This commit is contained in:
parent
59b41eaa70
commit
58e21336cd
4 changed files with 19 additions and 79 deletions
|
@ -1,39 +0,0 @@
|
|||
import { Controller } from "@hotwired/stimulus"
|
||||
|
||||
export default class extends Controller {
|
||||
static targets = ["button", "menu", "chevron"]
|
||||
|
||||
connect() {
|
||||
this.closeOnClickOutside = this.closeOnClickOutside.bind(this)
|
||||
}
|
||||
|
||||
toggle() {
|
||||
if (this.menuTarget.classList.contains("hidden")) {
|
||||
this.open()
|
||||
} else {
|
||||
this.close()
|
||||
}
|
||||
}
|
||||
|
||||
open() {
|
||||
this.menuTarget.classList.remove("hidden")
|
||||
this.chevronTarget.classList.add("rotate-180")
|
||||
document.addEventListener("click", this.closeOnClickOutside)
|
||||
}
|
||||
|
||||
close() {
|
||||
this.menuTarget.classList.add("hidden")
|
||||
this.chevronTarget.classList.remove("rotate-180")
|
||||
document.removeEventListener("click", this.closeOnClickOutside)
|
||||
}
|
||||
|
||||
closeOnClickOutside(event) {
|
||||
if (!this.element.contains(event.target)) {
|
||||
this.close()
|
||||
}
|
||||
}
|
||||
|
||||
disconnect() {
|
||||
document.removeEventListener("click", this.closeOnClickOutside)
|
||||
}
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
import { Controller } from "@hotwired/stimulus"
|
||||
|
||||
export default class extends Controller {
|
||||
static targets = ["hamburger", "menu"]
|
||||
|
||||
toggle() {
|
||||
if (this.menuTarget.classList.contains("hidden")) {
|
||||
this.open()
|
||||
} else {
|
||||
this.close()
|
||||
}
|
||||
}
|
||||
|
||||
open() {
|
||||
this.menuTarget.classList.remove("hidden")
|
||||
}
|
||||
|
||||
close() {
|
||||
this.menuTarget.classList.add("hidden")
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue