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:
@@ -92,3 +92,71 @@
|
||||
|
||||
(defcomp ~market-landing-content (&key inner)
|
||||
(<> (article :class "relative w-full" inner) (div :class "pb-8")))
|
||||
|
||||
|
||||
;; ---------------------------------------------------------------------------
|
||||
;; Composition: product detail page from data
|
||||
;; ---------------------------------------------------------------------------
|
||||
|
||||
;; Gallery section from pre-computed data
|
||||
(defcomp ~market-detail-gallery-from-data (&key images labels brand like-data has-nav-buttons thumbs)
|
||||
(let ((like-sx (when like-data
|
||||
(~market-like-button
|
||||
:form-id (get like-data "form-id") :action (get like-data "action")
|
||||
:slug (get like-data "slug") :csrf (get like-data "csrf")
|
||||
:icon-cls (get like-data "icon-cls")))))
|
||||
(if images
|
||||
(<>
|
||||
(~market-detail-gallery
|
||||
:inner (~market-detail-gallery-inner
|
||||
:like like-sx
|
||||
:image (get (first images) "src") :alt (get (first images) "alt")
|
||||
:labels (when labels
|
||||
(<> (map (lambda (src) (~market-label-overlay :src src)) labels)))
|
||||
:brand brand)
|
||||
:nav (when has-nav-buttons (~market-detail-nav-buttons)))
|
||||
(when thumbs
|
||||
(~market-detail-thumbs :thumbs
|
||||
(<> (map (lambda (t)
|
||||
(~market-detail-thumb
|
||||
:title (get t "title") :src (get t "src") :alt (get t "alt")))
|
||||
thumbs)))))
|
||||
(~market-detail-no-image :like like-sx))))
|
||||
|
||||
;; Right column details from data
|
||||
(defcomp ~market-detail-info-from-data (&key extras desc-short desc-html sections)
|
||||
(~market-detail-right-col :inner
|
||||
(<>
|
||||
(when extras
|
||||
(~market-detail-extras :inner
|
||||
(<> (map (lambda (e)
|
||||
(if (= (get e "type") "unit-price")
|
||||
(~market-detail-unit-price :price (get e "value"))
|
||||
(~market-detail-case-size :size (get e "value"))))
|
||||
extras))))
|
||||
(when (or desc-short desc-html)
|
||||
(~market-detail-desc-wrapper :inner
|
||||
(<> (when desc-short (~market-detail-desc-short :text desc-short))
|
||||
(when desc-html (~market-detail-desc-html :html desc-html)))))
|
||||
(when sections
|
||||
(~market-detail-sections :items
|
||||
(<> (map (lambda (s)
|
||||
(~market-detail-section :title (get s "title") :html (get s "html")))
|
||||
sections)))))))
|
||||
|
||||
;; Full product detail layout from data
|
||||
(defcomp ~market-product-detail-from-data (&key images labels brand like-data
|
||||
has-nav-buttons thumbs sticker-items
|
||||
extras desc-short desc-html sections)
|
||||
(~market-detail-layout
|
||||
:gallery (~market-detail-gallery-from-data
|
||||
:images images :labels labels :brand brand :like-data like-data
|
||||
:has-nav-buttons has-nav-buttons :thumbs thumbs)
|
||||
:stickers (when sticker-items
|
||||
(~market-detail-stickers :items
|
||||
(<> (map (lambda (s)
|
||||
(~market-detail-sticker :src (get s "src") :name (get s "name")))
|
||||
sticker-items))))
|
||||
:details (~market-detail-info-from-data
|
||||
:extras extras :desc-short desc-short :desc-html desc-html
|
||||
:sections sections)))
|
||||
|
||||
Reference in New Issue
Block a user