mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-10 17:21:38 -05:00
45 lines
1.3 KiB
JavaScript
45 lines
1.3 KiB
JavaScript
import { Controller } from "@hotwired/stimulus"
|
|
|
|
export default class extends Controller {
|
|
static targets = ["panel", "toggleIcon"]
|
|
|
|
connect() {
|
|
// Restore panel state from sessionStorage on page load
|
|
const panelState = sessionStorage.getItem('mapControlsPanelState')
|
|
if (panelState === 'visible') {
|
|
this.showPanel()
|
|
}
|
|
}
|
|
|
|
toggle() {
|
|
const isHidden = this.panelTarget.classList.contains("hidden")
|
|
|
|
if (isHidden) {
|
|
this.showPanel()
|
|
sessionStorage.setItem('mapControlsPanelState', 'visible')
|
|
} else {
|
|
this.hidePanel()
|
|
sessionStorage.setItem('mapControlsPanelState', 'hidden')
|
|
}
|
|
}
|
|
|
|
showPanel() {
|
|
this.panelTarget.classList.remove("hidden")
|
|
|
|
// Update icon to chevron-up
|
|
const currentIcon = this.toggleIconTarget.querySelector('svg')
|
|
currentIcon.classList.remove('lucide-chevron-down')
|
|
currentIcon.classList.add('lucide-chevron-up')
|
|
currentIcon.innerHTML = '<path d="m18 15-6-6-6 6"/>'
|
|
}
|
|
|
|
hidePanel() {
|
|
this.panelTarget.classList.add("hidden")
|
|
|
|
// Update icon to chevron-down
|
|
const currentIcon = this.toggleIconTarget.querySelector('svg')
|
|
currentIcon.classList.remove('lucide-chevron-up')
|
|
currentIcon.classList.add('lucide-chevron-down')
|
|
currentIcon.innerHTML = '<path d="m6 9 6 6 6-6"/>'
|
|
}
|
|
}
|