Skip to content

Self-hosted project management for devs and their clients: tickets, time tracking, docs and meetings, with an AI assistant that cites its sources. AGPL-3.0.

715 B
Raw Blame
import { Controller } from "@hotwired/stimulus"

export default class extends Controller {
  static targets = ["item", "panel", "icon"]

  toggle(event) {
    const button = event.currentTarget
    const index = this.itemTargets.indexOf(button)
    if (index === -1) return

    const panel = this.panelTargets[index]
    const icon = this.iconTargets[index]
    const isOpen = !panel.classList.contains("hidden")

    if (isOpen) {
      panel.classList.add("hidden")
      icon.classList.remove("rotate-45")
      button.setAttribute("aria-expanded", "false")
    } else {
      panel.classList.remove("hidden")
      icon.classList.add("rotate-45")
      button.setAttribute("aria-expanded", "true")
    }
  }
}