Use Stimulus to position events by timezone

This commit is contained in:
Kevin McConnell
2025-01-22 14:38:38 +00:00
parent e11b5095d5
commit b2f72ff668
5 changed files with 39 additions and 11 deletions
@@ -0,0 +1,17 @@
import { Controller } from "@hotwired/stimulus"
const MAX_ROWS = 25
export default class extends Controller {
static targets = [ "cell", "item" ]
cellTargetConnected(target) {
const dt = new Date(target.dataset.datetime)
target.classList.toggle("future", dt > new Date())
}
itemTargetConnected(target) {
const dt = new Date(target.dataset.datetime)
target.style.gridRowStart = MAX_ROWS - dt.getHours()
}
}