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>
119 lines
4.9 KiB
Plaintext
119 lines
4.9 KiB
Plaintext
;; Cart layout defcomps — fully self-contained via IO primitives.
|
|
;; Registered via register_sx_layout in __init__.py.
|
|
|
|
;; ---------------------------------------------------------------------------
|
|
;; Auto-fetching cart page header macros
|
|
;; ---------------------------------------------------------------------------
|
|
|
|
(defmacro ~cart-page-header-auto (oob)
|
|
"Cart page header: cart-row + page-cart-row using (cart-page-ctx)."
|
|
(quasiquote
|
|
(let ((__cpctx (cart-page-ctx)))
|
|
(<>
|
|
(~menu-row-sx :id "cart-row" :level 1 :colour "sky"
|
|
:link-href (get __cpctx "cart-url")
|
|
:link-label "cart" :icon "fa fa-shopping-cart"
|
|
:child-id "cart-header-child")
|
|
(~header-child-sx :id "cart-header-child"
|
|
:inner (~menu-row-sx :id "page-cart-row" :level 2 :colour "sky"
|
|
:link-href (get __cpctx "page-cart-url")
|
|
:link-label-content (~cart-page-label
|
|
:feature-image (get __cpctx "feature-image")
|
|
:title (get __cpctx "title"))
|
|
:nav (~cart-all-carts-link :href (get __cpctx "cart-url"))
|
|
:oob (unquote oob)))))))
|
|
|
|
(defmacro ~cart-page-header-oob ()
|
|
"Cart page OOB: individual oob rows."
|
|
(quasiquote
|
|
(let ((__cpctx (cart-page-ctx)))
|
|
(<>
|
|
(~menu-row-sx :id "page-cart-row" :level 2 :colour "sky"
|
|
:link-href (get __cpctx "page-cart-url")
|
|
:link-label-content (~cart-page-label
|
|
:feature-image (get __cpctx "feature-image")
|
|
:title (get __cpctx "title"))
|
|
:nav (~cart-all-carts-link :href (get __cpctx "cart-url"))
|
|
:oob true)
|
|
(~menu-row-sx :id "cart-row" :level 1 :colour "sky"
|
|
:link-href (get __cpctx "cart-url")
|
|
:link-label "cart" :icon "fa fa-shopping-cart"
|
|
:child-id "cart-header-child"
|
|
:oob true)))))
|
|
|
|
;; ---------------------------------------------------------------------------
|
|
;; cart-page layout: root + cart row + page-cart row
|
|
;; ---------------------------------------------------------------------------
|
|
|
|
(defcomp ~cart-page-layout-full ()
|
|
(<> (~root-header-auto)
|
|
(~header-child-sx
|
|
:inner (~cart-page-header-auto))))
|
|
|
|
(defcomp ~cart-page-layout-oob ()
|
|
(<> (~cart-page-header-oob)
|
|
(~root-header-auto true)))
|
|
|
|
;; ---------------------------------------------------------------------------
|
|
;; cart-admin layout: root + post header + admin header
|
|
;; Uses (post-header-ctx) — requires :data handler to populate g._defpage_ctx
|
|
;; ---------------------------------------------------------------------------
|
|
|
|
(defcomp ~cart-admin-layout-full (&key selected)
|
|
(<> (~root-header-auto)
|
|
(~header-child-sx
|
|
:inner (~post-header-auto nil))))
|
|
|
|
(defcomp ~cart-admin-layout-oob (&key selected)
|
|
(<> (~post-header-auto true)
|
|
(~oob-header-sx :parent-id "post-header-child"
|
|
:row (~post-admin-header-auto nil selected))
|
|
(~root-header-auto true)))
|
|
|
|
;; ---------------------------------------------------------------------------
|
|
;; orders-within-cart: root + auth-simple + orders
|
|
;; ---------------------------------------------------------------------------
|
|
|
|
(defcomp ~cart-orders-layout-full (&key list-url)
|
|
(<> (~root-header-auto)
|
|
(~header-child-sx
|
|
:inner (<> (~auth-header-row-simple-auto)
|
|
(~header-child-sx :id "auth-header-child"
|
|
:inner (~orders-header-row :list-url list-url))))))
|
|
|
|
(defcomp ~cart-orders-layout-oob (&key list-url)
|
|
(<> (~auth-header-row-simple-auto true)
|
|
(~oob-header-sx
|
|
:parent-id "auth-header-child"
|
|
:row (~orders-header-row :list-url list-url))
|
|
(~root-header-auto true)))
|
|
|
|
;; ---------------------------------------------------------------------------
|
|
;; order-detail-within-cart: root + auth-simple + orders + order
|
|
;; ---------------------------------------------------------------------------
|
|
|
|
(defcomp ~cart-order-detail-layout-full (&key list-url detail-url order-label)
|
|
(<> (~root-header-auto)
|
|
(~header-child-sx
|
|
:inner (<> (~auth-header-row-simple-auto)
|
|
(~header-child-sx :id "auth-header-child"
|
|
:inner (<> (~orders-header-row :list-url list-url)
|
|
(~header-child-sx :id "orders-header-child"
|
|
:inner (~menu-row-sx :id "order-row" :level 3 :colour "sky"
|
|
:link-href detail-url
|
|
:link-label order-label
|
|
:icon "fa fa-gbp"))))))))
|
|
|
|
(defcomp ~cart-order-detail-layout-oob (&key detail-url order-label)
|
|
(<> (~oob-header-sx
|
|
:parent-id "orders-header-child"
|
|
:row (~menu-row-sx :id "order-row" :level 3 :colour "sky"
|
|
:link-href detail-url :link-label order-label
|
|
:icon "fa fa-gbp" :oob true))
|
|
(~root-header-auto true)))
|
|
|
|
;; --- orders rows wrapper (for infinite scroll) ---
|
|
|
|
(defcomp ~cart-orders-rows (&key rows next-scroll)
|
|
(<> rows next-scroll))
|