AI store generator for ecommerce, Malaysia first. Laravel 13 + React + TypeScript.
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

renderer.tsx 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import { About } from './sections/about';
  2. import { Contact } from './sections/contact';
  3. import { Faq } from './sections/faq';
  4. import { FeaturedProduct } from './sections/featured-product';
  5. import { Footer } from './sections/footer';
  6. import { Header } from './sections/header';
  7. import { Hero } from './sections/hero';
  8. import { Newsletter } from './sections/newsletter';
  9. import { ProductGrid } from './sections/product-grid';
  10. import { Testimonials } from './sections/testimonials';
  11. import { themeStyle } from './theme';
  12. import type { FontMap, PlanSection, StorePlan } from './types';
  13. /**
  14. * Draw one section. To add a new section type: add it to PlanSchema.php and
  15. * types.ts, write its component, and add one line here.
  16. */
  17. function Section({ section }: { section: PlanSection }) {
  18. switch (section.type) {
  19. case 'header':
  20. return <Header section={section} />;
  21. case 'hero':
  22. return <Hero section={section} />;
  23. case 'product_grid':
  24. return <ProductGrid section={section} />;
  25. case 'featured_product':
  26. return <FeaturedProduct section={section} />;
  27. case 'about':
  28. return <About section={section} />;
  29. case 'testimonials':
  30. return <Testimonials section={section} />;
  31. case 'faq':
  32. return <Faq section={section} />;
  33. case 'newsletter':
  34. return <Newsletter section={section} />;
  35. case 'contact':
  36. return <Contact section={section} />;
  37. case 'footer':
  38. return <Footer section={section} />;
  39. default:
  40. // A type this version of the app does not know. Skip it and keep the page working.
  41. return null;
  42. }
  43. }
  44. /** Turn a store plan into a storefront page. */
  45. export function StorefrontRenderer({
  46. plan,
  47. fonts,
  48. }: {
  49. plan: StorePlan;
  50. fonts: FontMap;
  51. }) {
  52. return (
  53. <div
  54. className="sf-root min-h-screen"
  55. style={themeStyle(plan.theme, fonts)}
  56. >
  57. {plan.sections.map((section) => (
  58. <Section key={section.id} section={section} />
  59. ))}
  60. </div>
  61. );
  62. }