Merge branch 'worktree-sx-layout-conversion' into macros
# Conflicts: # blog/sxc/pages/layouts.py # cart/sxc/pages/layouts.py # events/sxc/pages/helpers.py # events/sxc/pages/layouts.py # market/sxc/pages/layouts.py # sx/sxc/pages/layouts.py
This commit is contained in:
@@ -4,15 +4,9 @@ from __future__ import annotations
|
||||
from typing import Any
|
||||
|
||||
from shared.sx.parser import SxExpr
|
||||
from shared.sx.helpers import (
|
||||
sx_call,
|
||||
post_header_sx as _post_header_sx,
|
||||
post_admin_header_sx,
|
||||
oob_header_sx as _oob_header_sx,
|
||||
header_child_sx,
|
||||
)
|
||||
from shared.sx.helpers import sx_call
|
||||
|
||||
from .utils import _set_prices, _price_str, _clear_deeper_oob
|
||||
from .utils import _set_prices, _price_str
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -272,62 +266,14 @@ def _product_admin_header_sx(ctx: dict, d: dict, *, oob: bool = False) -> str:
|
||||
)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Market admin header
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
async def _market_admin_header_sx(ctx: dict, *, oob: bool = False, selected: str = "") -> str:
|
||||
"""Build market admin header row -- delegates to shared helper."""
|
||||
slug = (ctx.get("post") or {}).get("slug", "")
|
||||
return await post_admin_header_sx(ctx, slug, oob=oob, selected=selected)
|
||||
|
||||
|
||||
# ===========================================================================
|
||||
# Layout registration
|
||||
# Layout registration — all layouts delegate to .sx defcomps
|
||||
# ===========================================================================
|
||||
|
||||
def _register_market_layouts() -> None:
|
||||
from shared.sx.layouts import register_custom_layout
|
||||
register_custom_layout("market", _market_full, _market_oob, _market_mobile)
|
||||
register_custom_layout("market-admin", _market_admin_full, _market_admin_oob)
|
||||
|
||||
|
||||
async def _market_full(ctx: dict, **kw: Any) -> str:
|
||||
from shared.sx.helpers import render_to_sx_with_env
|
||||
return await render_to_sx_with_env("market-browse-layout-full", {},
|
||||
post_header=await _post_header_sx(ctx),
|
||||
market_header=_market_header_sx(ctx))
|
||||
|
||||
|
||||
async def _market_oob(ctx: dict, **kw: Any) -> str:
|
||||
oob_hdr = await _oob_header_sx("post-header-child", "market-header-child",
|
||||
_market_header_sx(ctx))
|
||||
return sx_call("market-browse-layout-oob",
|
||||
oob_header=oob_hdr,
|
||||
post_header_oob=await _post_header_sx(ctx, oob=True),
|
||||
clear_oob=SxExpr(_clear_deeper_oob("post-row", "post-header-child",
|
||||
"market-row", "market-header-child")))
|
||||
|
||||
|
||||
def _market_mobile(ctx: dict, **kw: Any) -> str:
|
||||
return _mobile_nav_panel_sx(ctx)
|
||||
|
||||
|
||||
async def _market_admin_full(ctx: dict, **kw: Any) -> str:
|
||||
from shared.sx.helpers import render_to_sx_with_env
|
||||
selected = kw.get("selected", "")
|
||||
return await render_to_sx_with_env("market-admin-layout-full", {},
|
||||
post_header=await _post_header_sx(ctx),
|
||||
market_header=_market_header_sx(ctx),
|
||||
admin_header=await _market_admin_header_sx(ctx, selected=selected))
|
||||
|
||||
|
||||
async def _market_admin_oob(ctx: dict, **kw: Any) -> str:
|
||||
selected = kw.get("selected", "")
|
||||
return sx_call("market-admin-layout-oob",
|
||||
market_header_oob=_market_header_sx(ctx, oob=True),
|
||||
admin_oob_header=await _oob_header_sx("market-header-child", "market-admin-header-child",
|
||||
await _market_admin_header_sx(ctx, selected=selected)),
|
||||
clear_oob=SxExpr(_clear_deeper_oob("post-row", "post-header-child",
|
||||
"market-row", "market-header-child",
|
||||
"market-admin-row", "market-admin-header-child")))
|
||||
from shared.sx.layouts import register_sx_layout
|
||||
register_sx_layout("market",
|
||||
"market-browse-layout-full", "market-browse-layout-oob",
|
||||
"market-browse-layout-mobile")
|
||||
register_sx_layout("market-admin",
|
||||
"market-admin-layout-full", "market-admin-layout-oob")
|
||||
|
||||
Reference in New Issue
Block a user