import type { ReactNode } from 'react'; import { StorefrontProvider } from './context'; import { ProductPage } from './pages/product'; import { ShopPage } from './pages/shop'; import { About } from './sections/about'; import { Contact } from './sections/contact'; import { Faq } from './sections/faq'; import { FeaturedProduct } from './sections/featured-product'; import { Footer } from './sections/footer'; import { Header } from './sections/header'; import { Hero } from './sections/hero'; import { Newsletter } from './sections/newsletter'; import { ProductGrid } from './sections/product-grid'; import { Testimonials } from './sections/testimonials'; import { themeStyle } from './theme'; import type { FontMap, PlanSection, StorePlan, StoreProduct, StorefrontView, } from './types'; /** * Draw one section. To add a new section type: add it to PlanSchema.php and * types.ts, write its component, and add one line here. */ function Section({ section }: { section: PlanSection }) { switch (section.type) { case 'hero': return ; case 'product_grid': return ; case 'featured_product': return ; case 'about': return ; case 'testimonials': return ; case 'faq': return ; case 'newsletter': return ; case 'contact': return ; default: // A type this version of the app does not know. Skip it and keep the page working. return null; } } function PageBody({ plan, view }: { plan: StorePlan; view: StorefrontView }) { if (view.type === 'shop') { return ; } if (view.type === 'product') { return ; } const page = plan.pages.find((candidate) => candidate.id === view.pageId) ?? plan.pages[0]; return (
{page?.sections.map((section) => (
))}
); } /** * Turn a store plan into one storefront page: the shared header, the page itself, the shared footer. */ export function StorefrontRenderer({ plan, fonts, view, baseUrl, language, products, }: { plan: StorePlan; fonts: FontMap; view: StorefrontView; baseUrl: string; language: string; products: StoreProduct[]; }): ReactNode { const isHome = view.type === 'page' && view.pageId === 'home'; return (
); }