diff --git a/market/sx/layouts.sx b/market/sx/layouts.sx index a55828c..e9676d8 100644 --- a/market/sx/layouts.sx +++ b/market/sx/layouts.sx @@ -15,7 +15,13 @@ :title (get __mctx "market-title") :top-slug (get __mctx "top-slug") :sub-div (get __mctx "sub-slug")) - :nav (get __mctx "desktop-nav") + :nav (~market-desktop-nav-from-data + :categories (get __mctx "categories") + :hx-select (get __mctx "hx-select") + :select-colours (get __mctx "select-colours") + :all-href (get __mctx "all-href") + :all-active (get __mctx "all-active") + :admin-href (get __mctx "admin-href")) :child-id "market-header-child" :oob (unquote oob))))) diff --git a/shared/sx/primitives_io.py b/shared/sx/primitives_io.py index 63fe8e3..09b758d 100644 --- a/shared/sx/primitives_io.py +++ b/shared/sx/primitives_io.py @@ -876,10 +876,10 @@ async def _io_events_ticket_type_ctx( async def _io_market_header_ctx( args: list[Any], kwargs: dict[str, Any], ctx: RequestContext ) -> dict[str, Any]: - """``(market-header-ctx)`` → dict with market header values. + """``(market-header-ctx)`` → dict with market header data. - Pre-builds desktop-nav and mobile-nav as SxExpr strings using - the existing Python helper functions in sxc.pages.layouts. + Returns plain data (categories list, hrefs, flags) for the + ~market-header-auto macro. Mobile nav is pre-built as SxExpr. """ from quart import g, url_for from shared.config import config as get_config @@ -916,9 +916,9 @@ async def _io_market_header_ctx( "category_label": "", } - # Pre-build nav using existing helper functions (lazy import from market service) - from sxc.pages.layouts import _desktop_category_nav_sx, _mobile_nav_panel_sx - desktop_nav = _desktop_category_nav_sx(mini_ctx, categories, "", "#main-panel") + # Build header + mobile nav data via new data-driven helpers + from sxc.pages.layouts import _market_header_data, _mobile_nav_panel_sx + header_data = _market_header_data(mini_ctx) mobile_nav = _mobile_nav_panel_sx(mini_ctx) return { @@ -926,7 +926,12 @@ async def _io_market_header_ctx( "link-href": link_href, "top-slug": "", "sub-slug": "", - "desktop-nav": SxExpr(desktop_nav) if desktop_nav else "", + "categories": header_data.get("categories", []), + "hx-select": header_data.get("hx-select", "#main-panel"), + "select-colours": header_data.get("select-colours", ""), + "all-href": header_data.get("all-href", ""), + "all-active": header_data.get("all-active", False), + "admin-href": header_data.get("admin-href", ""), "mobile-nav": SxExpr(mobile_nav) if mobile_nav else "", } diff --git a/sx/sx/layouts.sx b/sx/sx/layouts.sx index 2f8a4a1..26395e4 100644 --- a/sx/sx/layouts.sx +++ b/sx/sx/layouts.sx @@ -73,8 +73,9 @@ :sub-nav sub-nav :selected selected)))) (defcomp ~sx-section-layout-oob (&key section sub-label sub-href sub-nav selected) - (<> (~sx-sub-row :sub-label sub-label :sub-href sub-href - :sub-nav sub-nav :selected selected :oob true) + (<> (~oob-header-sx :parent-id "sx-header-child" + :row (~sx-sub-row :sub-label sub-label :sub-href sub-href + :sub-nav sub-nav :selected selected)) (~sx-header-row :nav (~sx-main-nav :section section) :oob true)