Move market composition from Python to .sx defcomps (Phase 3)
Python sxc/pages/ functions no longer build nested sx_call chains or reference leaf component names. Instead they extract data (URLs, prices, CSRF, cart state) and call a single top-level composition defcomp with pure data values. The .sx defcomps handle all component-to-component wiring, iteration (map), and conditional rendering. New .sx composition defcomps: - headers.sx: ~market-header-from-data, ~market-desktop-nav-from-data, ~market-product-header-from-data, ~market-product-admin-header-from-data - prices.sx: ~market-prices-header-from-data, ~market-card-price-from-data - navigation.sx: ~market-mobile-nav-from-data - cards.sx: ~market-product-cards-content, ~market-card-from-data, ~market-cards-content, ~market-landing-from-data - detail.sx: ~market-product-detail-from-data, ~market-detail-gallery-from-data, ~market-detail-info-from-data - meta.sx: ~market-product-meta-from-data - filters.sx: ~market-desktop-filter-from-data, ~market-mobile-chips-from-data, ~market-mobile-filter-content-from-data, plus 6 sub-composition defcomps Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -15,3 +15,64 @@
|
||||
:class "px-2 py-1 text-stone-500 hover:text-stone-700"
|
||||
(i :class "fa fa-cog" :aria-hidden "true")))
|
||||
|
||||
|
||||
;; ---------------------------------------------------------------------------
|
||||
;; Composition defcomps — receive data, compose component trees
|
||||
;; ---------------------------------------------------------------------------
|
||||
|
||||
;; Desktop category nav from pre-computed category data
|
||||
(defcomp ~market-desktop-nav-from-data (&key categories hx-select select-colours
|
||||
all-href all-active admin-href)
|
||||
(~market-desktop-category-nav
|
||||
:links (<>
|
||||
(~market-category-link :href all-href :hx-select hx-select
|
||||
:active all-active :select-colours select-colours :label "All")
|
||||
(map (lambda (cat)
|
||||
(~market-category-link
|
||||
:href (get cat "href") :hx-select hx-select
|
||||
:active (get cat "active") :select-colours select-colours
|
||||
:label (get cat "label"))) categories))
|
||||
:admin (when admin-href
|
||||
(~market-admin-link :href admin-href :hx-select hx-select))))
|
||||
|
||||
;; Market-level header row from data
|
||||
(defcomp ~market-header-from-data (&key market-title top-slug sub-slug link-href
|
||||
categories hx-select select-colours
|
||||
all-href all-active admin-href oob)
|
||||
(~menu-row-sx :id "market-row" :level 2
|
||||
:link-href link-href
|
||||
:link-label-content (~market-shop-label
|
||||
:title market-title :top-slug (or top-slug "") :sub-div sub-slug)
|
||||
:nav (~market-desktop-nav-from-data
|
||||
:categories categories :hx-select hx-select :select-colours select-colours
|
||||
:all-href all-href :all-active all-active :admin-href admin-href)
|
||||
:child-id "market-header-child"
|
||||
:oob oob))
|
||||
|
||||
;; Product-level header row from data
|
||||
(defcomp ~market-product-header-from-data (&key title link-href hx-select
|
||||
price-data admin-href oob)
|
||||
(~menu-row-sx :id "product-row" :level 3
|
||||
:link-href link-href
|
||||
:link-label-content (~market-product-label :title title)
|
||||
:nav (<>
|
||||
(~market-prices-header-from-data
|
||||
:cart-id (get price-data "cart-id")
|
||||
:cart-action (get price-data "cart-action")
|
||||
:csrf (get price-data "csrf")
|
||||
:quantity (get price-data "quantity")
|
||||
:cart-href (get price-data "cart-href")
|
||||
:sp-val (get price-data "sp-val") :sp-str (get price-data "sp-str")
|
||||
:rp-val (get price-data "rp-val") :rp-str (get price-data "rp-str")
|
||||
:rrp-str (get price-data "rrp-str"))
|
||||
(when admin-href
|
||||
(~market-admin-link :href admin-href :hx-select hx-select)))
|
||||
:child-id "product-header-child"
|
||||
:oob oob))
|
||||
|
||||
;; Product admin header row from data
|
||||
(defcomp ~market-product-admin-header-from-data (&key link-href oob)
|
||||
(~menu-row-sx :id "product-admin-row" :level 4
|
||||
:link-href link-href :link-label "admin!!" :icon "fa fa-cog"
|
||||
:child-id "product-admin-header-child" :oob oob))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user