mirror of
https://github.com/czhu12/canine.git
synced 2025-12-21 10:49:49 -06:00
22 lines
722 B
JavaScript
22 lines
722 B
JavaScript
import { Controller } from "@hotwired/stimulus"
|
|
|
|
export default class extends Controller {
|
|
static targets = ["tabs", "content"]
|
|
|
|
connect() {
|
|
console.log(this.contentTarget)
|
|
this.tabsTarget.addEventListener("click", (event) => {
|
|
event.preventDefault()
|
|
this.tabsTarget.querySelectorAll(".tab").forEach((radio) => {
|
|
radio.classList.remove("tab-active")
|
|
})
|
|
event.target.classList.add("tab-active")
|
|
// Show loading spinner
|
|
this.contentTarget.innerHTML = `<div class="flex items-center justify-center my-6" style="height: 300px;">
|
|
<span class="loading loading-spinner loading-sm"></span>
|
|
</div>`
|
|
this.contentTarget.src = event.target.href
|
|
})
|
|
}
|
|
}
|