mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-11 03:40:20 +00:00
24 lines
694 B
JavaScript
24 lines
694 B
JavaScript
import { Controller } from "stimulus";
|
|
|
|
export default class extends Controller {
|
|
static targets = ["chevron", "classUpdate"];
|
|
static values = { selector: String };
|
|
|
|
toggleDisplay(_event) {
|
|
if (this.hasChevronTarget) {
|
|
this.chevronTarget.classList.toggle("ofn-i_005-caret-down");
|
|
this.chevronTarget.classList.toggle("ofn-i_006-caret-up");
|
|
}
|
|
|
|
if (this.hasClassUpdateTarget) {
|
|
this.classUpdateTargets.forEach((t) => {
|
|
t.classList.toggle("closed");
|
|
t.classList.toggle("open");
|
|
});
|
|
}
|
|
|
|
const element = document.querySelector(this.selectorValue);
|
|
element.style.display = element.style.display === "none" ? "block" : "none";
|
|
}
|
|
}
|