mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-25 20:46:48 +00:00
This is instead of adding the :data-controller attribute to the div#wrapper because that will wrap pretty much all content on the admin pages. Co-authored-by: Matt-Yorkley <9029026+Matt-Yorkley@users.noreply.github.com>
18 lines
486 B
JavaScript
18 lines
486 B
JavaScript
import { Controller } from "stimulus";
|
|
|
|
export default class extends Controller {
|
|
static targets = ["chevron"];
|
|
static values = { selector: String }
|
|
|
|
toggle(event) {
|
|
if (this.hasChevronTarget) {
|
|
this.chevronTarget.classList.toggle("icon-chevron-down")
|
|
this.chevronTarget.classList.toggle("icon-chevron-up")
|
|
}
|
|
|
|
const element = document.querySelector(this.selectorValue)
|
|
element.style.display = element.style.display === "none" ? "block" : "none"
|
|
}
|
|
}
|
|
|