Files
rose-ash/cart/sx/layouts.sx
giles b0920a1121 Rename all 1,169 components to path-based names with namespace support
Component names now reflect filesystem location using / as path separator
and : as namespace separator for shared components:
  ~sx-header → ~layouts/header
  ~layout-app-body → ~shared:layout/app-body
  ~blog-admin-dashboard → ~admin/dashboard

209 files, 4,941 replacements across all services.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-12 22:00:12 +00:00

137 lines
6.0 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)))
(<>
(~shared:layout/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")
(~shared:layout/header-child-sx :id "cart-header-child"
:inner (~shared:layout/menu-row-sx :id "page-cart-row" :level 2 :colour "sky"
:link-href (get __cpctx "page-cart-url")
:link-label-content (~header/page-label
:feature-image (get __cpctx "feature-image")
:title (get __cpctx "title"))
:nav (~header/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)))
(<>
(~shared:layout/menu-row-sx :id "page-cart-row" :level 2 :colour "sky"
:link-href (get __cpctx "page-cart-url")
:link-label-content (~header/page-label
:feature-image (get __cpctx "feature-image")
:title (get __cpctx "title"))
:nav (~header/all-carts-link :href (get __cpctx "cart-url"))
:oob true)
(~shared:layout/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 ~layouts/page-layout-full ()
(<> (~root-header-auto)
(~shared:layout/header-child-sx
:inner (~cart-page-header-auto))))
(defcomp ~layouts/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 ~layouts/admin-layout-full (&key selected)
(<> (~root-header-auto)
(~shared:layout/header-child-sx
:inner (~post-header-auto nil))))
(defcomp ~layouts/admin-layout-oob (&key selected)
(<> (~post-header-auto true)
(~shared:layout/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 ~layouts/orders-layout-full (&key list-url)
(<> (~root-header-auto)
(~shared:layout/header-child-sx
:inner (<> (~auth-header-row-simple-auto)
(~shared:layout/header-child-sx :id "auth-header-child"
:inner (~shared:auth/orders-header-row :list-url list-url))))))
(defcomp ~layouts/orders-layout-oob (&key list-url)
(<> (~auth-header-row-simple-auto true)
(~shared:layout/oob-header-sx
:parent-id "auth-header-child"
:row (~shared:auth/orders-header-row :list-url list-url))
(~root-header-auto true)))
;; ---------------------------------------------------------------------------
;; order-detail-within-cart: root + auth-simple + orders + order
;; ---------------------------------------------------------------------------
(defcomp ~layouts/order-detail-layout-full (&key list-url detail-url order-label)
(<> (~root-header-auto)
(~shared:layout/header-child-sx
:inner (<> (~auth-header-row-simple-auto)
(~shared:layout/header-child-sx :id "auth-header-child"
:inner (<> (~shared:auth/orders-header-row :list-url list-url)
(~shared:layout/header-child-sx :id "orders-header-child"
:inner (~shared:layout/menu-row-sx :id "order-row" :level 3 :colour "sky"
:link-href detail-url
:link-label order-label
:icon "fa fa-gbp"))))))))
(defcomp ~layouts/order-detail-layout-oob (&key detail-url order-label)
(<> (~shared:layout/oob-header-sx
:parent-id "orders-header-child"
:row (~shared:layout/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 ~layouts/orders-rows (&key rows next-scroll)
(<> rows next-scroll))
;; Composition defcomp — replaces Python loop in render_orders_rows
(defcomp ~layouts/orders-rows-content (&key orders detail-url-prefix page total-pages next-url)
(~layouts/orders-rows
:rows (map (lambda (od)
(~shared:orders/row-pair :order od :detail-url-prefix detail-url-prefix))
(or orders (list)))
:next-scroll (if (< page total-pages)
(~shared:controls/infinite-scroll :url next-url :page page
:total-pages total-pages :id-prefix "orders" :colspan 5)
(~shared:orders/end-row))))
;; Composition defcomp — replaces conditional composition in render_checkout_error_page
(defcomp ~layouts/checkout-error-from-data (&key msg order-id back-url)
(~shared:orders/checkout-error-content
:msg msg
:order (when order-id (~shared:orders/checkout-error-order-id :oid (str "#" order-id)))
:back-url back-url))