repositories / dotfiles

dotfiles

bugabingas dorkfiles

owned by bugabinga

caldav: clock calendar grid with weekday header, today circle, event markers

806066c1ad0e434720d3262423c3604f4d063b06

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Rewrite clockContent grid (Task 7): single-letter Monday-first weekday
header (weekend dimmed), today as filled accent circle with contrast
number, out-of-month dimmed. Per-day marker strip keyed off the cell's
iso date: all-day events as wide pills, timed events/tasks as dots, max
3 then a gray overflow bar. eventsByDate derives from caldavService.events
via Ical.coveredDates; single-day only (multi-day handled by bands next).
Refresh-on-open via Component.onCompleted. Replaces fragile parent.parent
chains with clockCol id refs.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

Changed files (1)

+92 / −13 text lines

Diff layout

quickshell/nuguland/PopoutHost.qml

Modified

+92 / −13 text lines

22import Quickshell
33import Quickshell.Wayland
44import "Util.js" as Util
5import "caldav.js" as Ical
67PanelWindow {
78 id: root
251252 id: clockContent
253254 Column {
255 id: clockCol
254257 property var state: root.timeService ? Util.parseJson(root.timeService.stateJson(), {
255258 }) : ({
256259 })
262265 })
263266 property var days: calendar.weeks ? [].concat.apply([], calendar.weeks) : []
268 // iso "YYYY-MM-DD" -> array of single-day markers {color, allDay}.
269 // Multi-day events (coveredDates>1) are drawn as bands, not markers.
270 readonly property var caldavEvents: root.caldavService ? root.caldavService.events : []
271 readonly property var eventsByDate: {
272 const map = {};
273 const evs = caldavEvents || [];
274 for (let i = 0; i < evs.length; i++) {
275 const ev = evs[i];
276 const dates = Ical.coveredDates(ev);
277 if (dates.length !== 1)
278 continue;
279 const iso = dates[0];
280 (map[iso] || (map[iso] = [])).push({
281 "color": ev.color,
282 "allDay": ev.allDay || ev.kind === "task"
283 });
284 }
285 return map;
286 }
265288 spacing: 8
266289 width: parent ? parent.width : 0
291 Component.onCompleted: if (root.caldavService) root.caldavService.refresh()
268293 NuguText {
269294 theme: root.theme
270295 variant: "title"
271 text: parent.state.clock ? parent.state.clock.statusDisplay : "--:--:--"
296 text: clockCol.state.clock ? clockCol.state.clock.statusDisplay : "--:--:--"
272297 }
274299 NuguText {
275300 theme: root.theme
276301 variant: "meta"
277 text: parent.state.date ? parent.state.date.line : "calendar"
302 text: clockCol.state.date ? clockCol.state.date.line : "calendar"
303 }
305 // single-letter weekday header, Monday-first; weekend dimmed
306 Row {
307 spacing: 2
309 Repeater {
310 model: ["M", "D", "M", "D", "F", "S", "S"]
312 NuguText {
313 width: 30
314 horizontalAlignment: Text.AlignHCenter
315 theme: root.theme
316 variant: "meta"
317 text: modelData
318 opacity: index >= 5 ? 0.4 : 0.7
319 }
321 }
278323 }
280325 Grid {
283328 spacing: 2
285330 Repeater {
286 model: parent.parent.days
331 model: clockCol.days
288 Rectangle {
289 width: 24
290 height: 16
291 radius: 4
292 color: modelData.selected && root.theme ? root.theme.ui.focus : "transparent"
293 border.width: 0
294 border.color: root.theme ? root.theme.ui.accent : "transparent"
333 Item {
334 id: cell
336 readonly property var markers: clockCol.eventsByDate[modelData.iso] || []
338 width: 30
339 height: 30
341 // today: filled accent circle behind the number
342 Rectangle {
343 visible: !!modelData.today
344 anchors.centerIn: parent
345 width: 22
346 height: 22
347 radius: 11
348 color: root.theme ? root.theme.ui.accent : "transparent"
349 }
296351 NuguText {
297352 anchors.centerIn: parent
298353 theme: root.theme
299354 variant: "meta"
300 selected: !!modelData.selected
301355 text: modelData.day ? String(modelData.day) : ""
302 opacity: modelData.inMonth ? 1 : 0.35
356 color: modelData.today && root.theme ? root.theme.content.backdrop : (root.theme ? root.theme.content.normal : "white")
357 opacity: modelData.inMonth ? 1 : 0.3
358 }
360 // marker strip: all-day pills + timed dots, max 3 then "+"
361 Row {
362 anchors.horizontalCenter: parent.horizontalCenter
363 anchors.bottom: parent.bottom
364 anchors.bottomMargin: 2
365 spacing: 2
367 Repeater {
368 model: Math.min(cell.markers.length, 3)
370 Rectangle {
371 readonly property var m: cell.markers[index]
372 readonly property bool overflow: index === 2 && cell.markers.length > 3
374 width: overflow ? 5 : (m.allDay ? 8 : 4)
375 height: 3
376 radius: 1.5
377 color: overflow ? (root.theme ? root.theme.content.minor : "gray") : m.color
378 }
380 }
303382 }
305384 }
311390 NuguText {
312391 theme: root.theme
313 text: parent.state.agenda && parent.state.agenda.length > 0 ? `agenda: ${parent.state.agenda[0].title}` : "agenda: clear"
392 text: clockCol.state.agenda && clockCol.state.agenda.length > 0 ? `agenda: ${clockCol.state.agenda[0].title}` : "agenda: clear"
314393 }
316395 }