Some checks failed
Build and Deploy / build-and-deploy (push) Failing after 2m33s
Continues the pattern of eliminating Python sx_call tree-building in favour of data-driven .sx defcomps. POST/PUT/DELETE routes now pass plain data (dicts, lists, scalars) and let .sx handle iteration, conditionals, and layout via map/let/when/if. Single response components wrap OOB swaps. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
94 lines
4.8 KiB
Plaintext
94 lines
4.8 KiB
Plaintext
;; Events calendar components
|
|
|
|
(defcomp ~events-calendar-nav-arrow (&key pill-cls href label)
|
|
(a :class (str pill-cls " text-xl") :href href
|
|
:sx-get href :sx-target "#main-panel" :sx-select "#main-panel" :sx-swap "outerHTML" :sx-push-url "true" label))
|
|
|
|
(defcomp ~events-calendar-month-label (&key month-name year)
|
|
(div :class "px-3 font-medium" (str month-name " " year)))
|
|
|
|
(defcomp ~events-calendar-weekday (&key name)
|
|
(div :class "py-1" name))
|
|
|
|
(defcomp ~events-calendar-day-short (&key day-str)
|
|
(span :class "sm:hidden text-[16px] text-stone-500" day-str))
|
|
|
|
(defcomp ~events-calendar-day-num (&key pill-cls href num)
|
|
(a :class pill-cls :href href :sx-get href :sx-target "#main-panel" :sx-select "#main-panel"
|
|
:sx-swap "outerHTML" :sx-push-url "true" num))
|
|
|
|
(defcomp ~events-calendar-entry-badge (&key bg-cls name state-label)
|
|
(div :class (str "flex items-center justify-between gap-1 text-[11px] rounded px-1 py-0.5 " bg-cls)
|
|
(span :class "truncate" name)
|
|
(span :class "shrink-0 text-[10px] font-semibold uppercase tracking-tight" state-label)))
|
|
|
|
(defcomp ~events-calendar-cell (&key cell-cls day-short day-num badges)
|
|
(div :class cell-cls
|
|
(div :class "flex justify-between items-center"
|
|
(div :class "flex flex-col" day-short day-num))
|
|
(div :class "mt-1 space-y-0.5" badges)))
|
|
|
|
(defcomp ~events-calendar-grid (&key arrows weekdays cells)
|
|
(section :class "bg-orange-100"
|
|
(header :class "flex items-center justify-center mt-2"
|
|
(nav :class "flex items-center gap-2 text-2xl" arrows))
|
|
(div :class "rounded-2xl border border-stone-200 bg-white/80 p-4"
|
|
(div :class "hidden sm:grid grid-cols-7 text-center text-md font-semibold text-stone-700 mb-2" weekdays)
|
|
(div :class "grid grid-cols-1 sm:grid-cols-7 gap-px bg-stone-200 rounded-xl overflow-hidden" cells))))
|
|
|
|
;; Calendar grid from data — all iteration in sx
|
|
(defcomp ~events-calendar-grid-from-data (&key pill-cls month-name year
|
|
prev-year-href prev-month-href
|
|
next-month-href next-year-href
|
|
weekday-names cells)
|
|
(~events-calendar-grid
|
|
:arrows (<>
|
|
(~events-calendar-nav-arrow :pill-cls pill-cls :href prev-year-href :label "\u00ab")
|
|
(~events-calendar-nav-arrow :pill-cls pill-cls :href prev-month-href :label "\u2039")
|
|
(~events-calendar-month-label :month-name month-name :year year)
|
|
(~events-calendar-nav-arrow :pill-cls pill-cls :href next-month-href :label "\u203a")
|
|
(~events-calendar-nav-arrow :pill-cls pill-cls :href next-year-href :label "\u00bb"))
|
|
:weekdays (<> (map (lambda (wd) (~events-calendar-weekday :name wd))
|
|
(or weekday-names (list))))
|
|
:cells (<> (map (lambda (cell)
|
|
(~events-calendar-cell
|
|
:cell-cls (get cell "cell-cls")
|
|
:day-short (when (get cell "day-str")
|
|
(~events-calendar-day-short :day-str (get cell "day-str")))
|
|
:day-num (when (get cell "day-href")
|
|
(~events-calendar-day-num :pill-cls pill-cls
|
|
:href (get cell "day-href") :num (get cell "day-num")))
|
|
:badges (when (get cell "badges")
|
|
(<> (map (lambda (b)
|
|
(~events-calendar-entry-badge
|
|
:bg-cls (get b "bg-cls") :name (get b "name")
|
|
:state-label (get b "state-label")))
|
|
(get cell "badges"))))))
|
|
(or cells (list))))))
|
|
|
|
(defcomp ~events-calendar-description-display (&key description edit-url)
|
|
(div :id "calendar-description"
|
|
(if description
|
|
(p :class "text-stone-700 whitespace-pre-line break-all" description)
|
|
(p :class "text-stone-400 italic" "No description yet."))
|
|
(button :type "button" :class "mt-2 text-xs underline"
|
|
:sx-get edit-url :sx-target "#calendar-description" :sx-swap "outerHTML"
|
|
(i :class "fas fa-edit"))))
|
|
|
|
(defcomp ~events-calendar-description-title-oob (&key description)
|
|
(div :id "calendar-description-title" :sx-swap-oob "outerHTML"
|
|
:class "text-base font-normal break-words whitespace-normal min-w-0 break-all w-full text-center block"
|
|
description))
|
|
|
|
(defcomp ~events-calendar-description-edit-form (&key save-url cancel-url csrf description)
|
|
(div :id "calendar-description"
|
|
(form :sx-post save-url :sx-target "#calendar-description" :sx-swap "outerHTML"
|
|
(input :type "hidden" :name "csrf_token" :value csrf)
|
|
(textarea :name "description" :autocomplete "off" :rows "4"
|
|
:class "w-full p-2 border rounded" description)
|
|
(div :class "mt-2 flex gap-2 text-xs"
|
|
(button :type "submit" :class "px-3 py-1 rounded bg-stone-800 text-white" "Save")
|
|
(button :type "button" :class "px-3 py-1 rounded border"
|
|
:sx-get cancel-url :sx-target "#calendar-description" :sx-swap "outerHTML"
|
|
"Cancel")))))
|