Aggiunge navigazione mobile dedicata e trasforma le principali liste operative in layout più leggibili e facili da toccare. Co-authored-by: Cursor <cursoragent@cursor.com>
36 lines
828 B
JavaScript
36 lines
828 B
JavaScript
import { Controller } from "@hotwired/stimulus"
|
|
|
|
export default class extends Controller {
|
|
static targets = ["panel"]
|
|
|
|
connect() {
|
|
this.boundKey = this.onKey.bind(this)
|
|
document.addEventListener("keydown", this.boundKey)
|
|
}
|
|
|
|
disconnect() {
|
|
document.removeEventListener("keydown", this.boundKey)
|
|
document.body.classList.remove("overflow-hidden")
|
|
}
|
|
|
|
toggle(event) {
|
|
event?.preventDefault()
|
|
event?.stopPropagation()
|
|
this.panelTarget.classList.contains("hidden") ? this.show() : this.hide()
|
|
}
|
|
|
|
show() {
|
|
this.panelTarget.classList.remove("hidden")
|
|
document.body.classList.add("overflow-hidden")
|
|
}
|
|
|
|
hide() {
|
|
this.panelTarget.classList.add("hidden")
|
|
document.body.classList.remove("overflow-hidden")
|
|
}
|
|
|
|
onKey(event) {
|
|
if (event.key === "Escape") this.hide()
|
|
}
|
|
}
|