Move events/market/blog composition from Python to .sx defcomps (Phase 9)
Some checks failed
Build and Deploy / build-and-deploy (push) Failing after 2m33s

Continues the pattern of eliminating Python sx_call tree-building in favour
of data-driven .sx defcomps. POST/PUT/DELETE routes now pass plain data
(dicts, lists, scalars) and let .sx handle iteration, conditionals, and
layout via map/let/when/if. Single response components wrap OOB swaps.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-05 08:17:09 +00:00
parent 877e776977
commit 51ebf347ba
23 changed files with 1841 additions and 1423 deletions

View File

@@ -43,3 +43,17 @@
(defcomp ~market-cart-add-oob (&key id content inner)
(div :id id :sx-swap-oob "outerHTML"
(if content content (when inner inner))))
;; Cart added response — composes cart mini + add/remove OOB in sx
(defcomp ~market-cart-added-response (&key has-count cart-href blog-href logo
slug action csrf quantity minus-val plus-val)
(<>
(if has-count
(~market-cart-mini-count :href cart-href :count (str has-count))
(~market-cart-mini-empty :href blog-href :logo logo))
(~market-cart-add-oob :id (str "cart-add-" slug)
:inner (if (= (or quantity "0") "0")
(~market-cart-add-empty :cart-id (str "cart-" slug) :action action :csrf csrf)
(~market-cart-add-quantity :cart-id (str "cart-" slug) :action action :csrf csrf
:minus-val minus-val :plus-val plus-val
:quantity quantity :cart-href cart-href)))))

View File

@@ -271,3 +271,18 @@
(~market-filter-stickers-from-data :items sticker-data :hx-select hx-select))
(when brand-data
(~market-filter-brands-from-data :items brand-data :hx-select hx-select))))
;; Composite mobile filter — eliminates SxExpr nesting in Python (M2)
(defcomp ~market-mobile-filter-from-data (&key search-bar
sort-chip liked-chip label-chips sticker-chips brand-chips
sort-data like-data label-data sticker-data brand-data
clear-href hx-select)
(~market-mobile-filter-summary
:search-bar search-bar
:chips (~market-mobile-chips-from-data
:sort-chip sort-chip :liked-chip liked-chip
:label-chips label-chips :sticker-chips sticker-chips :brand-chips brand-chips)
:filter (~market-mobile-filter-content-from-data
:sort-data sort-data :like-data like-data
:label-data label-data :sticker-data sticker-data :brand-data brand-data
:clear-href clear-href :hx-select hx-select)))

View File

@@ -96,10 +96,37 @@
(<> (~root-header-auto)
(~header-child-sx :inner (<> post-header market-header product-header admin-header))))
;; OOB wrappers
;; OOB wrappers — compose headers + clear divs in sx (no Python concatenation)
(defcomp ~market-oob-wrap (&key parts)
(<> parts))
(defcomp ~market-clear-product-oob ()
"Clear admin-level OOB divs when rendering product detail."
(<>
(~clear-oob-div :id "product-admin-row")
(~clear-oob-div :id "product-admin-header-child")
(~clear-oob-div :id "market-admin-row")
(~clear-oob-div :id "market-admin-header-child")
(~clear-oob-div :id "post-admin-row")
(~clear-oob-div :id "post-admin-header-child")))
(defcomp ~market-clear-product-admin-oob ()
"Clear deeper OOB divs when rendering product admin."
(<>
(~clear-oob-div :id "market-admin-row")
(~clear-oob-div :id "market-admin-header-child")
(~clear-oob-div :id "post-admin-row")
(~clear-oob-div :id "post-admin-header-child")))
(defcomp ~market-product-oob (&key market-header oob-header)
"Product detail OOB: market header + product header + clear deeper."
(<> market-header oob-header (~market-clear-product-oob)))
(defcomp ~market-product-admin-oob (&key product-header oob-header)
"Product admin OOB: product header + admin header + clear deeper."
(<> product-header oob-header (~market-clear-product-admin-oob)))
;; Content wrappers
(defcomp ~market-content-padded (&key content)
(<> content (div :class "pb-8")))