From 51d6ee20516553bf6b94cfbac72d871ff780f55b Mon Sep 17 00:00:00 2001 From: Stephan Stang Date: Wed, 19 Nov 2025 18:19:25 +0100 Subject: [PATCH] feat(layout-system basics): Added component-map, component-props, configloader and renderer. Added vt-template for nav and poc example footer. Added ste.medusa-starter.design.json. Probable starting point (main)/layout.tsx refactored to use dynamic layout renderer instead of hardcoded template. --- config/ste.medusa-starter.design.json | 68 ++++++++ src/app/[countryCode]/(main)/layout.tsx | 33 ++-- .../layout/templates/vt-footer/index.tsx | 158 ++++++++++++++++++ src/modules/layout/templates/vt-nav/index.tsx | 26 +++ src/vibentec/component-map.tsx | 76 +++++++++ src/vibentec/component-props.ts | 1 + src/vibentec/configloader.ts | 10 ++ src/vibentec/renderer.tsx | 16 ++ 8 files changed, 367 insertions(+), 21 deletions(-) create mode 100644 config/ste.medusa-starter.design.json create mode 100644 src/modules/layout/templates/vt-footer/index.tsx create mode 100644 src/modules/layout/templates/vt-nav/index.tsx create mode 100644 src/vibentec/component-map.tsx create mode 100644 src/vibentec/component-props.ts create mode 100644 src/vibentec/configloader.ts create mode 100644 src/vibentec/renderer.tsx diff --git a/config/ste.medusa-starter.design.json b/config/ste.medusa-starter.design.json new file mode 100644 index 0000000..879fb8c --- /dev/null +++ b/config/ste.medusa-starter.design.json @@ -0,0 +1,68 @@ +[ + { + "Nav": { + "props": {}, + "children": [ + { + "Div": { + "props": { "className": "flex items-center h-full" }, + "children": [ + { + "LocalizedClientLink": { + "props": { + "href": "/", + "label": "Medusa Store", + "className": "bg-black txt-compact-xlarge-plus hover:text-ui-fg-base uppercase", + "data-testid": "nav-store-link" + } + } + } + ] + } + }, + { + "Div": { + "props": { "className": "flex items-center gap-x-6 h-full flex-1 basis-0 justify-end" }, + "children": [ + { + "LocalizedClientLink": { + "props": { + "href": "/account", + "label": "Account", + "className": "hover:text-ui-fg-base bg-black", + "data-testid": "nav-account-link" + } + } + }, + { + "Suspense": { + "props": { + "fallback": [ + { + "LocalizedClientLink": { + "props": { + "href": "/cart", + "label": "Cart (0)", + "className": "bg-black hover:text-ui-fg-base flex gap-2", + "data-testid": "nav-cart-link" + } + } + } + ] + }, + "children": [ + { "CartButton": {} } + ] + } + } + ] + } + } + ] + } + }, + { "CartMismatchBanner": { "show": true } }, + { "FreeShippingPriceNudge": { "variant": "popup" } }, + { "PropsChildren" : {}}, + { "Footer": { "copyrightText": "© 2025 MyShop" } } +] \ No newline at end of file diff --git a/src/app/[countryCode]/(main)/layout.tsx b/src/app/[countryCode]/(main)/layout.tsx index 5635222..6036614 100644 --- a/src/app/[countryCode]/(main)/layout.tsx +++ b/src/app/[countryCode]/(main)/layout.tsx @@ -4,10 +4,9 @@ import { listCartOptions, retrieveCart } from "@lib/data/cart" import { retrieveCustomer } from "@lib/data/customer" import { getBaseURL } from "@lib/util/env" import { StoreCartShippingOption } from "@medusajs/types" -import CartMismatchBanner from "@modules/layout/components/cart-mismatch-banner" -import Footer from "@modules/layout/templates/footer" -import Nav from "@modules/layout/templates/nav" -import FreeShippingPriceNudge from "@modules/shipping/components/free-shipping-price-nudge" +import { DynamicLayoutRenderer } from "../../../vibentec/renderer" +import { LayoutContext, LayoutComponentNode, } from "../../../vibentec/component-map" +import { loadDesignConfig } from "vibentec/configloader" export const metadata: Metadata = { metadataBase: new URL(getBaseURL()), @@ -24,22 +23,14 @@ export default async function PageLayout(props: { children: React.ReactNode }) { shippingOptions = shipping_options } - return ( - <> -