feat: redesign the timeline as day columns with a bar per placement

This commit is contained in:
fromme committed 2026-11-12 11:14:25 +01:00
1 parent 4e50f23558
commit e976342c09
8 files changed
+413 -190

No files matched your search

@@ -1,22 +1,26 @@
import { Controller } from '@hotwired/stimulus'
export default class extends Controller {
static targets = [ 'today' ]
static targets = [ 'scroller', 'today' ]
connect() {
if (false === this.hasTodayTarget) {
requestAnimationFrame(() => this.scrollToToday({ behavior: 'instant' }))
}
// centres today's column; the house column stays in front of the left part
scrollToToday({ behavior = 'smooth' } = {}) {
if (false === this.hasScrollerTarget || false === this.hasTodayTarget) {
return
}
requestAnimationFrame(() => {
const containerRect = this.element.getBoundingClientRect()
const todayRect = this.todayTarget.getBoundingClientRect()
const scroller = this.scrollerTarget
const scrollerRect = scroller.getBoundingClientRect()
const todayRect = this.todayTarget.getBoundingClientRect()
const scrollLeft = todayRect.left - containerRect.left + this.element.scrollLeft
const centered = scrollLeft - (this.element.clientWidth / 2) + (todayRect.width / 2)
const maxScrollLeft = this.element.scrollWidth - this.element.clientWidth
const scrollLeft = todayRect.left - scrollerRect.left + scroller.scrollLeft
const centered = scrollLeft - (scroller.clientWidth / 2) + (todayRect.width / 2)
const maxScrollLeft = scroller.scrollWidth - scroller.clientWidth
this.element.scrollLeft = Math.min(Math.max(0, centered), maxScrollLeft)
})
scroller.scrollTo({ left: Math.min(Math.max(0, centered), maxScrollLeft), behavior })
}
}