Add register_sx_layout infrastructure, convert account/federation/orders
Phase 0: Add _ctx_to_env() and render_to_sx_with_env() to shared/sx/helpers.py, register_sx_layout() to shared/sx/layouts.py, and ~root-header/~root-mobile wrapper defcomps to layout.sx. Convert built-in "root" layout to .sx. Phases 1-3: Convert account (65→19 lines), federation (105→97 lines), and orders (88→21 lines) to use register_sx_layout with .sx defcomps that read ctx values as free variables from the evaluation environment. No more Python building SX strings via SxExpr(await root_header_sx(ctx)). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
49
orders/sx/layouts.sx
Normal file
49
orders/sx/layouts.sx
Normal file
@@ -0,0 +1,49 @@
|
||||
;; Orders layout defcomps — read ctx values from env free variables.
|
||||
;; Registered via register_sx_layout("orders", ...) in __init__.py.
|
||||
|
||||
;; --- orders layout: root + auth + orders rows ---
|
||||
|
||||
(defcomp ~orders-layout-full (&key list-url)
|
||||
(<> (~root-header)
|
||||
(~header-child-sx
|
||||
:inner (<> (~auth-header-row :account-url account-url
|
||||
:select-colours select-colours
|
||||
:account-nav account-nav)
|
||||
(~orders-header-row :list-url (or list-url "/"))))))
|
||||
|
||||
(defcomp ~orders-layout-oob (&key list-url)
|
||||
(<> (~auth-header-row :account-url account-url
|
||||
:select-colours select-colours
|
||||
:account-nav account-nav
|
||||
:oob true)
|
||||
(~oob-header-sx
|
||||
:parent-id "auth-header-child"
|
||||
:row (~orders-header-row :list-url (or list-url "/")))
|
||||
(~root-header :oob true)))
|
||||
|
||||
(defcomp ~orders-layout-mobile ()
|
||||
(~root-mobile))
|
||||
|
||||
;; --- order-detail layout: root + auth + orders + order rows ---
|
||||
|
||||
(defcomp ~order-detail-layout-full (&key list-url detail-url)
|
||||
(<> (~root-header)
|
||||
(~order-detail-header-stack
|
||||
:auth (~auth-header-row :account-url account-url
|
||||
:select-colours select-colours
|
||||
:account-nav account-nav)
|
||||
:orders (~orders-header-row :list-url (or list-url "/"))
|
||||
:order (~menu-row-sx :id "order-row" :level 3 :colour "sky"
|
||||
:link-href (or detail-url "/") :link-label "Order"
|
||||
:icon "fa fa-gbp"))))
|
||||
|
||||
(defcomp ~order-detail-layout-oob (&key detail-url)
|
||||
(<> (~oob-header-sx
|
||||
:parent-id "orders-header-child"
|
||||
:row (~menu-row-sx :id "order-row" :level 3 :colour "sky"
|
||||
:link-href (or detail-url "/") :link-label "Order"
|
||||
:icon "fa fa-gbp" :oob true))
|
||||
(~root-header :oob true)))
|
||||
|
||||
(defcomp ~order-detail-layout-mobile ()
|
||||
(~root-mobile))
|
||||
Reference in New Issue
Block a user