| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- 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 } 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 'header':
- return <Header section={section} />;
- case 'hero':
- return <Hero section={section} />;
- case 'product_grid':
- return <ProductGrid section={section} />;
- case 'featured_product':
- return <FeaturedProduct section={section} />;
- case 'about':
- return <About section={section} />;
- case 'testimonials':
- return <Testimonials section={section} />;
- case 'faq':
- return <Faq section={section} />;
- case 'newsletter':
- return <Newsletter section={section} />;
- case 'contact':
- return <Contact section={section} />;
- case 'footer':
- return <Footer section={section} />;
- default:
- // A type this version of the app does not know. Skip it and keep the page working.
- return null;
- }
- }
-
- /** Turn a store plan into a storefront page. */
- export function StorefrontRenderer({
- plan,
- fonts,
- }: {
- plan: StorePlan;
- fonts: FontMap;
- }) {
- return (
- <div
- className="sf-root min-h-screen"
- style={themeStyle(plan.theme, fonts)}
- >
- {plan.sections.map((section) => (
- <Section key={section.id} section={section} />
- ))}
- </div>
- );
- }
|