Convert all 23 register_custom_layout calls to register_sx_layout across 6 services

Layout defcomps are now fully self-contained via IO-primitive auto-fetch
macros, eliminating Python layout functions that manually threaded context
values through SxExpr wrappers.

Services converted:
- Federation (1 layout): social
- Blog (7 layouts): blog, blog-settings, blog-cache, blog-snippets,
  blog-menu-items, blog-tag-groups, blog-tag-group-edit
- SX docs (2 layouts): sx, sx-section
- Cart (2 layouts): cart-page, cart-admin + orders/order-detail
- Events (9 layouts): calendar-admin, slots, slot, day-admin, entry,
  entry-admin, ticket-types, ticket-type, markets
- Market (2 layouts): market, market-admin

New IO primitives added to shared/sx/primitives_io.py:
- federation-actor-ctx, cart-page-ctx, request-view-args
- events-calendar-ctx, events-day-ctx, events-entry-ctx,
  events-slot-ctx, events-ticket-type-ctx
- market-header-ctx (pre-builds desktop/mobile nav as SxExpr)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-04 22:21:44 +00:00
parent ad75798ab7
commit 57a31a3b83
18 changed files with 1289 additions and 1215 deletions

View File

@@ -1,17 +1,92 @@
;; SX docs layout defcomps — root header via ~root-header-auto,
;; sx-specific headers passed as &key params.
;; SX docs layout defcomps — fully self-contained via IO primitives.
;; Registered via register_sx_layout in __init__.py.
;; --- SX home layout: root + sx menu row ---
;; --- Main nav defcomp: static nav items from MAIN_NAV ---
;; @css aria-selected:bg-violet-200 aria-selected:text-violet-900
(defcomp ~sx-layout-full (&key sx-row)
(defcomp ~sx-main-nav (&key section)
(let* ((sc "aria-selected:bg-violet-200 aria-selected:text-violet-900")
(items (list
(dict :label "Docs" :href "/docs/introduction")
(dict :label "Reference" :href "/reference/")
(dict :label "Protocols" :href "/protocols/wire-format")
(dict :label "Examples" :href "/examples/click-to-load")
(dict :label "Essays" :href "/essays/sx-sucks"))))
(<> (map (lambda (item)
(~nav-link
:href (get item "href")
:label (get item "label")
:is-selected (when (= (get item "label") section) "true")
:select-colours sc))
items))))
;; --- SX header row ---
(defcomp ~sx-header-row (&key nav child oob)
(~menu-row-sx :id "sx-row" :level 1 :colour "violet"
:link-href "/" :link-label "sx"
:link-label-content (~sx-docs-label)
:nav nav
:child-id "sx-header-child"
:child child
:oob oob))
;; --- Sub-row for section pages ---
(defcomp ~sx-sub-row (&key sub-label sub-href sub-nav selected oob)
(~menu-row-sx :id "sx-sub-row" :level 2 :colour "violet"
:link-href sub-href :link-label sub-label
:selected selected
:nav sub-nav
:oob oob))
;; ---------------------------------------------------------------------------
;; SX home layout (root + sx header)
;; ---------------------------------------------------------------------------
(defcomp ~sx-layout-full (&key section)
(<> (~root-header-auto)
sx-row))
(~sx-header-row :nav (~sx-main-nav :section section))))
(defcomp ~sx-layout-oob (&key root-header sx-row)
(<> root-header sx-row))
(defcomp ~sx-layout-oob (&key section)
(<> (~sx-header-row
:nav (~sx-main-nav :section section)
:oob true)
(~clear-oob-div :id "sx-header-child")
(~root-header-auto true)))
;; --- SX section layout: root + sx row (with child sub-row) ---
(defcomp ~sx-layout-mobile (&key section)
(<> (~mobile-menu-section
:label "sx" :href "/" :level 1 :colour "violet"
:items (~sx-main-nav :section section))
(~root-mobile-auto)))
(defcomp ~sx-section-layout-full (&key sx-row)
;; ---------------------------------------------------------------------------
;; SX section layout (root + sx header + sub-row)
;; ---------------------------------------------------------------------------
(defcomp ~sx-section-layout-full (&key section sub-label sub-href sub-nav selected)
(<> (~root-header-auto)
sx-row))
(~sx-header-row
:nav (~sx-main-nav :section section)
:child (~sx-sub-row :sub-label sub-label :sub-href sub-href
:sub-nav sub-nav :selected selected))))
(defcomp ~sx-section-layout-oob (&key section sub-label sub-href sub-nav selected)
(<> (~sx-sub-row :sub-label sub-label :sub-href sub-href
:sub-nav sub-nav :selected selected :oob true)
(~sx-header-row
:nav (~sx-main-nav :section section)
:oob true)
(~root-header-auto true)))
(defcomp ~sx-section-layout-mobile (&key section sub-label sub-href sub-nav)
(<>
(when sub-nav
(~mobile-menu-section
:label (or sub-label section) :href sub-href :level 2 :colour "violet"
:items sub-nav))
(~mobile-menu-section
:label "sx" :href "/" :level 1 :colour "violet"
:items (~sx-main-nav :section section))
(~root-mobile-auto)))