Fix market header ImportError and sx docs menu bar 3 OOB insertion

- market/sx/layouts.sx: Update ~market-header-auto macro to build nav
  from data fields via ~market-desktop-nav-from-data instead of
  expecting pre-built "desktop-nav" SxExpr (removed in Phase 9)
- shared/sx/primitives_io.py: Import _market_header_data instead of
  deleted _desktop_category_nav_sx, return individual data fields
- sx/sx/layouts.sx: Fix ~sx-section-layout-oob to use ~oob-header-sx
  for inserting sub-row into always-existing container div

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-05 08:50:48 +00:00
parent 1d59023571
commit 2a04aaad5e
3 changed files with 22 additions and 10 deletions

View File

@@ -15,7 +15,13 @@
:title (get __mctx "market-title") :title (get __mctx "market-title")
:top-slug (get __mctx "top-slug") :top-slug (get __mctx "top-slug")
:sub-div (get __mctx "sub-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" :child-id "market-header-child"
:oob (unquote oob))))) :oob (unquote oob)))))

View File

@@ -876,10 +876,10 @@ async def _io_events_ticket_type_ctx(
async def _io_market_header_ctx( async def _io_market_header_ctx(
args: list[Any], kwargs: dict[str, Any], ctx: RequestContext args: list[Any], kwargs: dict[str, Any], ctx: RequestContext
) -> dict[str, Any]: ) -> 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 Returns plain data (categories list, hrefs, flags) for the
the existing Python helper functions in sxc.pages.layouts. ~market-header-auto macro. Mobile nav is pre-built as SxExpr.
""" """
from quart import g, url_for from quart import g, url_for
from shared.config import config as get_config from shared.config import config as get_config
@@ -916,9 +916,9 @@ async def _io_market_header_ctx(
"category_label": "", "category_label": "",
} }
# Pre-build nav using existing helper functions (lazy import from market service) # Build header + mobile nav data via new data-driven helpers
from sxc.pages.layouts import _desktop_category_nav_sx, _mobile_nav_panel_sx from sxc.pages.layouts import _market_header_data, _mobile_nav_panel_sx
desktop_nav = _desktop_category_nav_sx(mini_ctx, categories, "", "#main-panel") header_data = _market_header_data(mini_ctx)
mobile_nav = _mobile_nav_panel_sx(mini_ctx) mobile_nav = _mobile_nav_panel_sx(mini_ctx)
return { return {
@@ -926,7 +926,12 @@ async def _io_market_header_ctx(
"link-href": link_href, "link-href": link_href,
"top-slug": "", "top-slug": "",
"sub-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 "", "mobile-nav": SxExpr(mobile_nav) if mobile_nav else "",
} }

View File

@@ -73,8 +73,9 @@
:sub-nav sub-nav :selected selected)))) :sub-nav sub-nav :selected selected))))
(defcomp ~sx-section-layout-oob (&key section sub-label sub-href sub-nav 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 (<> (~oob-header-sx :parent-id "sx-header-child"
:sub-nav sub-nav :selected selected :oob true) :row (~sx-sub-row :sub-label sub-label :sub-href sub-href
:sub-nav sub-nav :selected selected))
(~sx-header-row (~sx-header-row
:nav (~sx-main-nav :section section) :nav (~sx-main-nav :section section)
:oob true) :oob true)