@nuvler/cli 0.1.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/README.md +50 -5
  2. package/dist/api/developer-auth.js +48 -0
  3. package/dist/api/developer-auth.js.map +1 -0
  4. package/dist/api/theme-registry.js +9 -5
  5. package/dist/api/theme-registry.js.map +1 -1
  6. package/dist/commands/auth.js +27 -0
  7. package/dist/commands/auth.js.map +1 -0
  8. package/dist/commands/theme/configure.js +79 -0
  9. package/dist/commands/theme/configure.js.map +1 -0
  10. package/dist/commands/theme/create.js +111 -22
  11. package/dist/commands/theme/create.js.map +1 -1
  12. package/dist/commands/theme/dev.js +8 -12
  13. package/dist/commands/theme/dev.js.map +1 -1
  14. package/dist/commands/theme/publish.js +38 -6
  15. package/dist/commands/theme/publish.js.map +1 -1
  16. package/dist/config/auth.js +40 -0
  17. package/dist/config/auth.js.map +1 -0
  18. package/dist/config/connection-key.js +63 -0
  19. package/dist/config/connection-key.js.map +1 -0
  20. package/dist/config/developer-session.js +25 -0
  21. package/dist/config/developer-session.js.map +1 -0
  22. package/dist/config/project.js +59 -0
  23. package/dist/config/project.js.map +1 -0
  24. package/dist/index.js +84 -18
  25. package/dist/index.js.map +1 -1
  26. package/dist/nuvler.js +592 -138
  27. package/dist/nuvler.js.map +1 -1
  28. package/dist/preview/prepare.js +19 -0
  29. package/dist/preview/prepare.js.map +1 -0
  30. package/dist/templates/nuvler-atelier/README.md +30 -0
  31. package/{templates/starter-theme → dist/templates/nuvler-atelier}/gitignore.template +1 -1
  32. package/dist/templates/nuvler-atelier/nuvler.theme.json +16 -0
  33. package/dist/templates/nuvler-atelier/package.json +29 -0
  34. package/dist/templates/nuvler-atelier/src/definition.tsx +201 -0
  35. package/dist/templates/nuvler-atelier/src/theme.css +278 -0
  36. package/dist/templates/nuvler-atelier/src/theme.tsx +105 -0
  37. package/dist/templates/nuvler-default/README.md +34 -0
  38. package/dist/templates/nuvler-default/gitignore.template +9 -0
  39. package/dist/templates/nuvler-default/nuvler.theme.json +16 -0
  40. package/dist/templates/nuvler-default/package.json +42 -0
  41. package/dist/templates/nuvler-default/scripts/clean-dist.mjs +6 -0
  42. package/dist/templates/nuvler-default/scripts/copy-assets.mjs +12 -0
  43. package/dist/templates/nuvler-default/src/banner-carousel.tsx +24 -0
  44. package/dist/templates/nuvler-default/src/definition.ts +59 -0
  45. package/dist/templates/nuvler-default/src/footer.tsx +7 -0
  46. package/dist/templates/nuvler-default/src/header-interactions.tsx +190 -0
  47. package/dist/templates/nuvler-default/src/header.tsx +14 -0
  48. package/dist/templates/nuvler-default/src/home.tsx +69 -0
  49. package/dist/templates/nuvler-default/src/index.ts +28 -0
  50. package/dist/templates/nuvler-default/src/product-carousel.tsx +12 -0
  51. package/dist/templates/nuvler-default/src/product-detail.tsx +60 -0
  52. package/dist/templates/nuvler-default/src/products.tsx +15 -0
  53. package/dist/templates/nuvler-default/src/shared.tsx +44 -0
  54. package/dist/templates/nuvler-default/src/styles.d.ts +1 -0
  55. package/dist/templates/nuvler-default/src/theme-component.tsx +97 -0
  56. package/dist/templates/nuvler-default/src/theme.css +2934 -0
  57. package/dist/templates/nuvler-default/src/theme.tsx +2 -0
  58. package/dist/templates/nuvler-default/tsconfig.json +10 -0
  59. package/{templates/starter-theme → dist/templates/starter}/README.md +3 -3
  60. package/dist/templates/starter/gitignore.template +9 -0
  61. package/dist/templates/starter/nuvler.theme.json +16 -0
  62. package/{templates/starter-theme → dist/templates/starter}/package.json +2 -2
  63. package/dist/templates/starter/src/styles.d.ts +1 -0
  64. package/dist/templates/starter/tsconfig.json +17 -0
  65. package/dist/theme/artifact.js +1 -0
  66. package/dist/theme/artifact.js.map +1 -1
  67. package/package.json +3 -4
  68. package/preview-host/package.json +1 -1
  69. package/preview-host/src/public-preview-url.d.mts +5 -0
  70. package/preview-host/src/public-preview-url.mjs +50 -0
  71. package/preview-host/vendor/theme-runtime/default-theme.tsx +1 -1
  72. package/preview-host/vite.config.ts +4 -3
  73. package/templates/starter-theme/.env.example +0 -3
  74. package/templates/starter-theme/nuvler.theme.json +0 -10
  75. /package/{templates/starter-theme → dist/templates/nuvler-atelier}/src/styles.d.ts +0 -0
  76. /package/{templates/starter-theme → dist/templates/nuvler-atelier}/tsconfig.json +0 -0
  77. /package/{templates/starter-theme → dist/templates/starter}/src/definition.tsx +0 -0
  78. /package/{templates/starter-theme → dist/templates/starter}/src/theme.css +0 -0
  79. /package/{templates/starter-theme → dist/templates/starter}/src/theme.tsx +0 -0
@@ -0,0 +1,105 @@
1
+ import { useMemo, useState, type CSSProperties } from "react";
2
+ import type {
3
+ NuvlerThemeProps,
4
+ ThemeCartItem,
5
+ ThemeEditorialItem,
6
+ ThemeRoute,
7
+ ThemeSite,
8
+ } from "@nuvler/theme-sdk";
9
+ import { AtelierImage, plainText, themeDefinition } from "./definition.js";
10
+ import "./theme.css";
11
+
12
+ export { manifest, themeDefinition } from "./definition.js";
13
+
14
+ interface CartLine extends ThemeCartItem {
15
+ key: string;
16
+ quantity: number;
17
+ }
18
+
19
+ function catalogHref(route: Extract<ThemeRoute, { type: "catalog" }>, page: number): string {
20
+ const params = new URLSearchParams();
21
+ if (route.search) params.set("busca", route.search);
22
+ route.variants.forEach((variant) => params.append("variante", variant));
23
+ if (page > 1) params.set("pagina", String(page));
24
+ const pathname = route.categoryPath.length
25
+ ? `/categoria/${route.categoryPath.map(encodeURIComponent).join("/")}`
26
+ : "/produtos";
27
+ return params.size ? `${pathname}?${params}` : pathname;
28
+ }
29
+
30
+ function EditorialList({ title, basePath, items }: { title: string; basePath: string; items: ThemeEditorialItem[] }) {
31
+ return <main className="atelier-page atelier-container">
32
+ <header className="atelier-page-heading"><span className="atelier-kicker">Caderno Nuvler</span><h1>{title}</h1><p>Ideias, referências e histórias selecionadas para ajudar em cada escolha.</p></header>
33
+ <div className="atelier-editorial-grid">{items.map((item, index) => <a href={`${basePath}/${item.slug}`} key={item.slug}><AtelierImage image={item.image || item.thumbnail || item.coverImage} alt={item.title} /><small>Leitura {String(index + 1).padStart(2, "0")}</small><h2>{item.title}</h2><p>{item.description}</p><span>Ler agora ↗</span></a>)}</div>
34
+ </main>;
35
+ }
36
+
37
+ export default function Theme({ context, route = { type: "home" }, sdk, adapters }: NuvlerThemeProps) {
38
+ const { Header, Footer, Home, ProductGrid, ProductDetail } = themeDefinition.components;
39
+ const site: ThemeSite = { tenant: context.store, ...context.site };
40
+ const configured = site.settings?.theme;
41
+ const tokens = {
42
+ colors: { ...themeDefinition.tokens.colors, ...configured?.colors },
43
+ layout: { ...themeDefinition.tokens.layout, ...configured?.layout },
44
+ };
45
+ const style = {
46
+ "--atelier-primary": tokens.colors.primary,
47
+ "--atelier-accent": tokens.colors.secondary,
48
+ "--atelier-background": tokens.colors.background,
49
+ "--atelier-text": tokens.colors.text,
50
+ "--atelier-radius": `${tokens.layout.borderRadius}px`,
51
+ "--atelier-container": `${tokens.layout.containerWidth}px`,
52
+ } as CSSProperties;
53
+ const [cart, setCart] = useState<CartLine[]>([]);
54
+ const [cartOpen, setCartOpen] = useState(false);
55
+ const cartCount = cart.reduce((total, item) => total + item.quantity, 0);
56
+ const addToCart = (item: ThemeCartItem) => {
57
+ const key = `${item.productSlug}::${item.variantId || "parent"}`;
58
+ setCart((current) => {
59
+ const existing = current.find((candidate) => candidate.key === key);
60
+ return existing
61
+ ? current.map((candidate) => candidate.key === key ? { ...candidate, quantity: Math.min(99, candidate.quantity + 1) } : candidate)
62
+ : [...current, { ...item, key, quantity: 1 }];
63
+ });
64
+ sdk?.cart.add(item);
65
+ setCartOpen(true);
66
+ };
67
+ const message = useMemo(() => `Olá! Gostaria de solicitar um orçamento para:\n\n${cart.map((item, index) => `${index + 1}. ${item.quantity}x ${item.title}${item.variantName ? ` (${item.variantName})` : ""}${item.sku ? ` — ref. ${item.sku}` : ""}`).join("\n\n")}`, [cart]);
68
+ const whatsapp = site.settings?.contact.whatsapp?.replace(/\D/g, "");
69
+
70
+ let content;
71
+ if (route.type === "home") {
72
+ content = <Home sections={context.home.content.sections} products={context.catalog.products} posts={context.editorial.posts} services={context.editorial.services} cases={context.editorial.cases} site={site} template={themeDefinition.template} />;
73
+ } else if (route.type === "catalog") {
74
+ content = <main className="atelier-page atelier-container">
75
+ <header className="atelier-page-heading"><span className="atelier-kicker">Catálogo editorial</span><h1>{route.search ? `Resultados para “${route.search}”` : "Todos os produtos"}</h1><p>{route.pagination.total} produto(s) encontrados para sua seleção.</p></header>
76
+ <div className="atelier-catalog-layout">
77
+ <aside className="atelier-filters">
78
+ <form action={route.categoryPath.length ? `/categoria/${route.categoryPath.join("/")}` : "/produtos"}><label htmlFor="atelier-catalog-search">Refine sua busca</label><div><input id="atelier-catalog-search" name="busca" defaultValue={route.search} placeholder="Nome, marca ou referência" /><button>↗</button></div></form>
79
+ {route.facets.map((facet) => <fieldset key={facet.name}><legend>{facet.name}</legend>{facet.values.map(({ value, count }) => { const token = `${facet.name}::${value}`; return <label key={token}><input type="checkbox" name="variante" value={token} defaultChecked={route.variants.includes(token)} /><span>{value}</span><small>{count}</small></label>; })}</fieldset>)}
80
+ </aside>
81
+ <section><ProductGrid products={route.products} columns={site.settings?.catalog?.desktopColumns || 3} showCategory={site.settings?.catalog?.showCategory} showDescription={site.settings?.catalog?.showDescription} />
82
+ {route.pagination.totalPages > 1 && <nav className="atelier-pagination" aria-label="Paginação"><a className={!route.pagination.hasPreviousPage ? "disabled" : ""} href={catalogHref(route, route.pagination.page - 1)}>← Anterior</a><span>{route.pagination.page} / {route.pagination.totalPages}</span><a className={!route.pagination.hasNextPage ? "disabled" : ""} href={catalogHref(route, route.pagination.page + 1)}>Próxima →</a></nav>}
83
+ </section>
84
+ </div>
85
+ </main>;
86
+ } else if (route.type === "product") {
87
+ content = <main className="atelier-page atelier-container"><nav className="atelier-breadcrumb"><a href="/">Início</a><span>·</span><a href="/produtos">Produtos</a><span>·</span><strong>{route.product.title}</strong></nav><ProductDetail product={route.product} contact={site.settings?.contact} productUrl={typeof window === "undefined" ? null : window.location.href} descriptionContent={<p>{plainText(route.product.description)}</p>} onAddToCart={addToCart} /></main>;
88
+ } else if (route.type === "editorial-list") {
89
+ content = <EditorialList title={route.title} basePath={route.basePath} items={route.items} />;
90
+ } else if (route.type === "editorial-detail") {
91
+ content = <main className="atelier-page atelier-container"><article className="atelier-article"><span className="atelier-kicker">Caderno Nuvler</span><h1>{route.item.title}</h1><AtelierImage image={route.item.image || route.item.thumbnail || route.item.coverImage} alt={route.item.title} /><p>{route.item.description}</p><a href={route.basePath}>← Voltar</a></article></main>;
92
+ } else if (route.type === "page") {
93
+ content = <main className="atelier-page atelier-container"><header className="atelier-page-heading"><span className="atelier-kicker">Institucional</span><h1>{route.title}</h1></header></main>;
94
+ } else {
95
+ content = <main className="atelier-page atelier-container"><header className="atelier-page-heading"><span className="atelier-kicker">{route.type === "loading" ? "Carregando" : "404"}</span><h1>{route.type === "loading" ? "Preparando sua experiência…" : "Essa página não foi encontrada."}</h1><a className="atelier-button atelier-button-dark" href="/">Voltar ao início</a></header></main>;
96
+ }
97
+
98
+ const cartButton = <button className="atelier-cart-button" type="button" onClick={() => setCartOpen(true)} aria-label={`Abrir seleção com ${cartCount} itens`}><span>Seleção</span><b>{String(cartCount).padStart(2, "0")}</b></button>;
99
+ return <div className="nuvler-atelier-theme" data-theme-id={themeDefinition.manifest.id} data-theme-version={themeDefinition.manifest.version} style={style}>
100
+ <Header site={site} categories={context.navigation.categories} pages={context.navigation.pages} template={themeDefinition.template} searchProducts={adapters?.searchProducts} cart={cartButton} />
101
+ {content}
102
+ <Footer site={site} pages={context.navigation.pages} template={themeDefinition.template} />
103
+ {cartOpen && <div className="atelier-cart-backdrop" onPointerDown={(event) => event.target === event.currentTarget && setCartOpen(false)}><aside className="atelier-cart-drawer"><header><div><small>Sua curadoria</small><h2>{cartCount} {cartCount === 1 ? "item" : "itens"}</h2></div><button onClick={() => setCartOpen(false)} aria-label="Fechar">×</button></header><div className="atelier-cart-lines">{cart.length === 0 ? <p>Sua seleção está vazia. Explore os produtos e adicione o que interessar.</p> : cart.map((item) => <article key={item.key}><AtelierImage image={item.image} alt={item.title} /><div><strong>{item.title}</strong><small>{item.variantName || item.sku}</small><span><button onClick={() => setCart((current) => current.flatMap((candidate) => candidate.key !== item.key ? [candidate] : candidate.quantity > 1 ? [{ ...candidate, quantity: candidate.quantity - 1 }] : []))}>−</button>{item.quantity}<button onClick={() => setCart((current) => current.map((candidate) => candidate.key === item.key ? { ...candidate, quantity: candidate.quantity + 1 } : candidate))}>+</button></span></div></article>)}</div>{cart.length > 0 && <footer><p>Valores e disponibilidade serão confirmados pela equipe.</p>{whatsapp ? <a className="atelier-button atelier-button-light" href={`https://wa.me/${whatsapp}?text=${encodeURIComponent(message)}`} target="_blank" rel="noreferrer">Enviar pelo WhatsApp ↗</a> : <span>Configure o WhatsApp da loja para concluir.</span>}</footer>}</aside></div>}
104
+ </div>;
105
+ }
@@ -0,0 +1,34 @@
1
+ # Nuvler Default
2
+
3
+ Fonte oficial do tema padrão. Ele será distribuído pelo Theme Registry da
4
+ Nuvler, não pelo npm.
5
+
6
+ Ele é a referência de compatibilidade entre o Store e temas externos:
7
+
8
+ - `nuvler.theme.json` declara identidade, versão, entrada e estilos;
9
+ - `runtimeVersion` e `sdkVersion` declaram a compatibilidade pública do tema;
10
+ - `src/theme.tsx` é a entrada do preview Vite;
11
+ - `src/index.ts` expõe `nuvlerDefaultTheme`, `manifest`, `Theme`, `Header`,
12
+ `Footer`, `Home`, `ProductGrid` e `ProductDetail`;
13
+ - `src/theme.css` contém o visual completo do Store, incluindo Home, catálogo,
14
+ PDP, editoriais, carrinho e responsividade.
15
+
16
+ React é `peerDependency`: o tema reutiliza a cópia fornecida pelo
17
+ Store/preview host. Seus contratos vêm de `@nuvler/theme-sdk`.
18
+
19
+ Para executar:
20
+
21
+ ```bash
22
+ node packages/cli/dist/nuvler.js theme dev \
23
+ --theme themes/nuvler-default \
24
+ --store minha-loja \
25
+ --api-url http://localhost:3333/api
26
+ ```
27
+
28
+ Para gerar o artefato do Registry, execute na raiz do tooling:
29
+
30
+ ```bash
31
+ npm run pack:theme -- nuvler-default
32
+ ```
33
+
34
+ Resultado: `artifacts/nuvler-default-1.0.1.nuvler-theme.tgz`.
@@ -0,0 +1,9 @@
1
+ node_modules/
2
+ dist/
3
+ artifacts/
4
+ .vite/
5
+ *.tgz
6
+ *.tsbuildinfo
7
+ .nuvler/
8
+ .env
9
+ .env.*
@@ -0,0 +1,16 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "id": "nuvler-default",
4
+ "name": "Nuvler Default",
5
+ "version": "1.0.1",
6
+ "runtimeVersion": "1",
7
+ "sdkVersion": "^1.1.0",
8
+ "entry": "src/theme.tsx",
9
+ "styles": ["src/theme.css"],
10
+ "presentation": {
11
+ "description": "Tema oficial completo, indicado para produção e usado como base confiável.",
12
+ "templateId": "nuvler-default",
13
+ "colors": { "primary": "#176b3a", "secondary": "#d99b31", "background": "#f7f7f2", "text": "#18221b" },
14
+ "layout": { "containerWidth": 1280, "borderRadius": 18 }
15
+ }
16
+ }
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@nuvler/theme-nuvler-default",
3
+ "version": "1.0.1",
4
+ "private": true,
5
+ "description": "Tema padrão oficial da Nuvler",
6
+ "type": "module",
7
+ "sideEffects": ["**/*.css"],
8
+ "main": "./dist/src/index.js",
9
+ "types": "./dist/src/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/src/index.d.ts",
13
+ "import": "./dist/src/index.js",
14
+ "default": "./dist/src/index.js"
15
+ },
16
+ "./styles.css": "./dist/theme.css",
17
+ "./manifest": "./dist/nuvler.theme.json"
18
+ },
19
+ "files": ["dist", "README.md"],
20
+ "scripts": {
21
+ "dev": "nuvler theme dev --theme .",
22
+ "validate": "nuvler theme validate --theme .",
23
+ "build": "nuvler theme build --theme .",
24
+ "build:package": "node scripts/clean-dist.mjs && tsc -p tsconfig.json && node scripts/copy-assets.mjs",
25
+ "pack": "nuvler theme pack --theme .",
26
+ "publish": "nuvler theme publish --theme .",
27
+ "typecheck": "tsc -p tsconfig.json --noEmit"
28
+ },
29
+ "peerDependencies": {
30
+ "react": "^19.0.0"
31
+ },
32
+ "dependencies": {
33
+ "@nuvler/theme-sdk": "^1.1.0"
34
+ },
35
+ "devDependencies": {
36
+ "@types/react": "^19.0.0",
37
+ "react": "19.2.8"
38
+ },
39
+ "engines": {
40
+ "node": "^20.19.0 || >=22.12.0"
41
+ }
42
+ }
@@ -0,0 +1,6 @@
1
+ import { rm } from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+
5
+ const themeRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
6
+ await rm(path.join(themeRoot, "dist"), { recursive: true, force: true });
@@ -0,0 +1,12 @@
1
+ import { copyFile, mkdir } from "node:fs/promises";
2
+ import path from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+
5
+ const themeRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
6
+ const output = path.join(themeRoot, "dist");
7
+
8
+ await mkdir(output, { recursive: true });
9
+ await Promise.all([
10
+ copyFile(path.join(themeRoot, "src", "theme.css"), path.join(output, "theme.css")),
11
+ copyFile(path.join(themeRoot, "nuvler.theme.json"), path.join(output, "nuvler.theme.json")),
12
+ ]);
@@ -0,0 +1,24 @@
1
+ "use client";
2
+
3
+ import { useEffect, useState } from "react";
4
+ import { ThemeImageView } from "./shared.js";
5
+
6
+ export interface ThemeBanner {
7
+ imageUrl: string;
8
+ imageAlt?: string;
9
+ title?: string;
10
+ description?: string;
11
+ buttonLabel?: string;
12
+ buttonUrl?: string;
13
+ }
14
+
15
+ export function BannerCarousel({ banners, autoplay }: { banners: ThemeBanner[]; autoplay: boolean }) {
16
+ const [active, setActive] = useState(0);
17
+ useEffect(() => {
18
+ if (!autoplay || banners.length < 2) return;
19
+ const timer = window.setInterval(() => setActive((current) => (current + 1) % banners.length), 6000);
20
+ return () => window.clearInterval(timer);
21
+ }, [autoplay, banners.length]);
22
+ if (!banners.length) return null;
23
+ return <section className="banner-carousel" aria-roledescription="carrossel" aria-label="Banners da loja"><div className="banner-track" style={{ transform: `translateX(-${active * 100}%)` }}>{banners.map((banner, index) => <article className="banner-slide" key={`${banner.imageUrl}-${index}`} aria-hidden={active !== index}><ThemeImageView image={{ url: banner.imageUrl, alt: banner.imageAlt || banner.title || "Banner", width: null, height: null }} fallbackAlt={banner.title || "Banner"} priority={index === 0} />{(banner.title || banner.description || (banner.buttonLabel && banner.buttonUrl)) && <div className="banner-overlay"><div className="store-container"><div className="banner-copy">{banner.title && <h2>{banner.title}</h2>}{banner.description && <p>{banner.description}</p>}{banner.buttonLabel && banner.buttonUrl && <a className="button button-primary" href={banner.buttonUrl}>{banner.buttonLabel}</a>}</div></div></div>}</article>)}</div>{banners.length > 1 && <><button className="carousel-arrow carousel-arrow-prev" type="button" aria-label="Banner anterior" onClick={() => setActive((active - 1 + banners.length) % banners.length)}>‹</button><button className="carousel-arrow carousel-arrow-next" type="button" aria-label="Próximo banner" onClick={() => setActive((active + 1) % banners.length)}>›</button><div className="carousel-dots">{banners.map((_, index) => <button key={index} type="button" className={index === active ? "active" : ""} aria-label={`Ir para banner ${index + 1}`} onClick={() => setActive(index)} />)}</div></>}</section>;
24
+ }
@@ -0,0 +1,59 @@
1
+ import manifestData from "../nuvler.theme.json" with { type: "json" };
2
+ import {
3
+ defineTheme,
4
+ type ThemeHomeSection,
5
+ type ThemeManifest,
6
+ } from "@nuvler/theme-sdk";
7
+ import { Footer } from "./footer.js";
8
+ import { Header } from "./header.js";
9
+ import { Home } from "./home.js";
10
+ import { ProductDetail } from "./product-detail.js";
11
+ import { ProductGrid } from "./products.js";
12
+
13
+ function section(id: string, type: ThemeHomeSection["type"], order: number): ThemeHomeSection {
14
+ return { id, type, enabled: true, order, data: {} };
15
+ }
16
+
17
+ export const manifest = manifestData as ThemeManifest;
18
+
19
+ export const nuvlerDefaultTheme = defineTheme({
20
+ manifest,
21
+ tokens: {
22
+ colors: {
23
+ primary: "#176b3a",
24
+ secondary: "#d99b31",
25
+ background: "#f7f7f2",
26
+ text: "#18221b",
27
+ },
28
+ layout: { containerWidth: 1280, borderRadius: 18 },
29
+ },
30
+ template: {
31
+ announcement: "Soluções, conteúdo e atendimento para o seu negócio",
32
+ footerTagline: "Soluções, conteúdo e atendimento próximo para aproximar sua marca das pessoas.",
33
+ footerNavigationLabel: "Navegação",
34
+ footerNote: "Conteúdo e atendimento que geram confiança",
35
+ socialLabel: "Acompanhe a empresa",
36
+ benefits: [
37
+ { title: "Soluções sob medida", description: "Serviços pensados para o seu momento" },
38
+ { title: "Conteúdo relevante", description: "Informação para ajudar nas decisões" },
39
+ { title: "Atendimento próximo", description: "Fale diretamente com a empresa" },
40
+ ],
41
+ fallbackSections(modules) {
42
+ const sections = [section("default-hero", "hero", 0)];
43
+ let order = 1;
44
+ if (modules.includes("SERVICES")) sections.push(section("default-services", "services-grid", order++));
45
+ if (modules.includes("CASES")) sections.push(section("default-cases", "cases-grid", order++));
46
+ if (modules.includes("PRODUCTS")) sections.push(section("default-products", "products-carousel", order++));
47
+ if (modules.includes("BLOG")) sections.push(section("default-blog", "blog-grid", order));
48
+ return sections;
49
+ },
50
+ primaryAction(modules) {
51
+ if (modules.includes("SERVICES")) return { label: "Conheça nossos serviços", href: "/servicos" };
52
+ if (modules.includes("PRODUCTS")) return { label: "Ver produtos", href: "/produtos" };
53
+ if (modules.includes("CASES")) return { label: "Conheça nossos cases", href: "/cases" };
54
+ if (modules.includes("BLOG")) return { label: "Ver conteúdos", href: "/blog" };
55
+ return { label: "Conheça a empresa", href: "/" };
56
+ },
57
+ },
58
+ components: { Header, Footer, Home, ProductGrid, ProductDetail },
59
+ });
@@ -0,0 +1,7 @@
1
+ import type { FooterProps } from "@nuvler/theme-sdk";
2
+
3
+ export function Footer({ site, pages, template }: FooterProps) {
4
+ const settings = site.settings;
5
+ const name = settings?.siteName || site.tenant.name;
6
+ return <footer className="store-footer"><div className="store-container footer-grid"><div><strong className="footer-brand">{name}</strong><p>{settings?.description || template.footerTagline}</p></div><div><strong>{template.footerNavigationLabel}</strong>{site.modules.includes("PRODUCTS") && <a href="/produtos">Todos os produtos</a>}{site.modules.includes("BLOG") && <a href="/blog">Blog</a>}{site.modules.includes("SERVICES") && <a href="/servicos">Serviços</a>}{site.modules.includes("CASES") && <a href="/cases">Cases</a>}<a href="/">Início</a></div>{pages.length > 0 && <div><strong>Institucional</strong>{pages.slice(0, 6).map((page) => <a key={page.slug} href={`/${page.slug}`}>{page.title}</a>)}</div>}<div><strong>Atendimento</strong>{settings?.contact.email && <a href={`mailto:${settings.contact.email}`}>{settings.contact.email}</a>}{settings?.contact.phone && <a href={`tel:${settings.contact.phone}`}>{settings.contact.phone}</a>}{settings?.contact.address && <span>{settings.contact.address}</span>}</div>{settings?.social && Object.values(settings.social).some(Boolean) && <div className="footer-social"><strong>{template.socialLabel}</strong>{settings.social.instagram && <a href={settings.social.instagram} target="_blank" rel="noreferrer">Instagram</a>}{settings.social.facebook && <a href={settings.social.facebook} target="_blank" rel="noreferrer">Facebook</a>}{settings.social.youtube && <a href={settings.social.youtube} target="_blank" rel="noreferrer">YouTube</a>}{settings.social.tiktok && <a href={settings.social.tiktok} target="_blank" rel="noreferrer">TikTok</a>}</div>}</div><div className="store-container footer-bottom"><span>© {new Date().getFullYear()} {name}</span><span>{template.footerNote}</span></div></footer>;
7
+ }
@@ -0,0 +1,190 @@
1
+ "use client";
2
+
3
+ import { useEffect, useLayoutEffect, useRef, useState, type KeyboardEvent } from "react";
4
+ import type { ThemeCategory, ThemePageSummary, ThemeProduct, ThemeSite } from "@nuvler/theme-sdk";
5
+ import { categoryUrl, displayPrice, ThemeImageView } from "./shared.js";
6
+
7
+ function CategoryTree({ categories, path = [], depth = 0 }: {
8
+ categories: ThemeCategory[];
9
+ path?: string[];
10
+ depth?: number;
11
+ }) {
12
+ return categories.map((category) => {
13
+ const currentPath = [...path, category.slug];
14
+ return <div className="category-nav-tree-node" data-depth={depth} key={currentPath.join("/")}>
15
+ <a href={categoryUrl(currentPath)} style={{ paddingLeft: `${14 + depth * 16}px` }}>
16
+ {depth > 0 && <span className="category-tree-branch" aria-hidden="true" />}
17
+ <span>{category.name}</span>
18
+ </a>
19
+ {category.children?.length > 0 && <CategoryTree categories={category.children} path={currentPath} depth={depth + 1} />}
20
+ </div>;
21
+ });
22
+ }
23
+
24
+ export function CategoryNavigation({ categories }: { categories: ThemeCategory[] }) {
25
+ const innerRef = useRef<HTMLDivElement>(null);
26
+ const allRef = useRef<HTMLDetailsElement>(null);
27
+ const itemRefs = useRef<Array<HTMLDivElement | null>>([]);
28
+ const [visibleCount, setVisibleCount] = useState(0);
29
+
30
+ useLayoutEffect(() => {
31
+ const inner = innerRef.current;
32
+ const all = allRef.current;
33
+ if (!inner || !all) return;
34
+ const calculate = () => {
35
+ const styles = window.getComputedStyle(inner);
36
+ const gap = Number.parseFloat(styles.columnGap || styles.gap) || 0;
37
+ let width = all.offsetWidth;
38
+ let count = 0;
39
+ for (const item of itemRefs.current) {
40
+ if (!item || width + gap + item.offsetWidth > inner.clientWidth) break;
41
+ width += gap + item.offsetWidth;
42
+ count += 1;
43
+ }
44
+ setVisibleCount(count);
45
+ };
46
+ const frame = window.requestAnimationFrame(calculate);
47
+ const observer = new ResizeObserver(calculate);
48
+ observer.observe(inner);
49
+ return () => { window.cancelAnimationFrame(frame); observer.disconnect(); };
50
+ }, [categories]);
51
+
52
+ useEffect(() => {
53
+ const outside = (event: PointerEvent) => {
54
+ if (allRef.current?.open && !allRef.current.contains(event.target as Node)) allRef.current.open = false;
55
+ };
56
+ document.addEventListener("pointerdown", outside);
57
+ return () => document.removeEventListener("pointerdown", outside);
58
+ }, []);
59
+
60
+ return <nav className="category-nav" aria-label="Categorias de produtos">
61
+ <div className="store-container category-nav-inner" ref={innerRef}>
62
+ <details className="category-nav-all" ref={allRef}>
63
+ <summary className="all-categories"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M4 7h16M4 12h16M4 17h16" /></svg><span>Todas as categorias</span><svg className="category-nav-chevron" viewBox="0 0 20 20" aria-hidden="true"><path d="m6 8 4 4 4-4" /></svg></summary>
64
+ <div className="category-nav-all-panel">
65
+ <div className="category-nav-panel-heading"><div><span>Explore o catálogo</span><strong>Todas as categorias</strong></div><a href="/produtos">Ver todos</a></div>
66
+ <div className="category-nav-tree"><CategoryTree categories={categories} /></div>
67
+ </div>
68
+ </details>
69
+ {categories.map((category, index) => {
70
+ const overflowed = index >= visibleCount;
71
+ return <div className="category-nav-group" data-overflowed={overflowed || undefined} aria-hidden={overflowed || undefined} key={category.slug} ref={(node) => { itemRefs.current[index] = node; }}>
72
+ <a href={categoryUrl([category.slug])}>{category.name}{category.children?.length > 0 && <span aria-hidden="true">⌄</span>}</a>
73
+ {category.children?.length > 0 && <div className="category-nav-submenu"><CategoryTree categories={category.children} path={[category.slug]} /></div>}
74
+ </div>;
75
+ })}
76
+ </div>
77
+ </nav>;
78
+ }
79
+
80
+ export function SmartProductSearch({ endpoint = "/api/product-suggestions", queryParam = "q", searchProducts }: { endpoint?: string; queryParam?: string; searchProducts?: (query: string) => Promise<ThemeProduct[]> }) {
81
+ const [value, setValue] = useState("");
82
+ const [results, setResults] = useState<ThemeProduct[]>([]);
83
+ const [loading, setLoading] = useState(false);
84
+ const [open, setOpen] = useState(false);
85
+ const [activeIndex, setActiveIndex] = useState(-1);
86
+ const root = useRef<HTMLDivElement>(null);
87
+
88
+ useEffect(() => {
89
+ const query = value.trim();
90
+ if (query.length < 2) {
91
+ setLoading(false);
92
+ setOpen(false);
93
+ setResults([]);
94
+ setActiveIndex(-1);
95
+ return;
96
+ }
97
+
98
+ const controller = new AbortController();
99
+ setOpen(true);
100
+ setLoading(true);
101
+ setActiveIndex(-1);
102
+ const timer = window.setTimeout(() => {
103
+ const separator = endpoint.includes("?") ? "&" : "?";
104
+ const request = searchProducts
105
+ ? searchProducts(query)
106
+ : fetch(`${endpoint}${separator}${encodeURIComponent(queryParam)}=${encodeURIComponent(query)}`, { signal: controller.signal }).then((response) => {
107
+ if (!response.ok) throw new Error(`Busca indisponível (${response.status})`);
108
+ return response.json() as Promise<ThemeProduct[]>;
109
+ });
110
+ void request
111
+ .then((response) => {
112
+ if (!controller.signal.aborted) setResults(Array.isArray(response) ? response.slice(0, 5) : []);
113
+ })
114
+ .catch((error: unknown) => {
115
+ if (!(error instanceof DOMException && error.name === "AbortError")) setResults([]);
116
+ })
117
+ .finally(() => { if (!controller.signal.aborted) setLoading(false); });
118
+ }, 280);
119
+ return () => { window.clearTimeout(timer); controller.abort(); };
120
+ }, [endpoint, queryParam, searchProducts, value]);
121
+
122
+ useEffect(() => {
123
+ const close = (event: PointerEvent) => { if (!root.current?.contains(event.target as Node)) setOpen(false); };
124
+ document.addEventListener("pointerdown", close);
125
+ return () => document.removeEventListener("pointerdown", close);
126
+ }, []);
127
+
128
+ function handleKeyDown(event: KeyboardEvent<HTMLInputElement>) {
129
+ if (event.key === "Escape") {
130
+ setOpen(false);
131
+ setActiveIndex(-1);
132
+ return;
133
+ }
134
+ if (!open || loading || !results.length) return;
135
+ if (event.key === "ArrowDown" || event.key === "ArrowUp") {
136
+ event.preventDefault();
137
+ const direction = event.key === "ArrowDown" ? 1 : -1;
138
+ setActiveIndex((current) => {
139
+ if (current < 0) return direction > 0 ? 0 : results.length - 1;
140
+ return (current + direction + results.length) % results.length;
141
+ });
142
+ }
143
+ if (event.key === "Enter" && activeIndex >= 0) {
144
+ event.preventDefault();
145
+ window.location.assign(`/produto/${results[activeIndex].slug}`);
146
+ }
147
+ }
148
+
149
+ const query = value.trim();
150
+ const resultLabel = `${results.length} ${results.length === 1 ? "resultado" : "resultados"}`;
151
+
152
+ return <div className="header-search-shell" ref={root}>
153
+ <form className="header-search" action="/produtos">
154
+ <label className="sr-only" htmlFor="theme-store-search">Pesquisar produtos</label>
155
+ <input id="theme-store-search" name="busca" type="search" placeholder="Busque por produto, marca ou referência" autoComplete="off" value={value} onChange={(event) => setValue(event.target.value)} onFocus={() => query.length >= 2 && setOpen(true)} onKeyDown={handleKeyDown} aria-expanded={open} aria-controls="theme-search-suggestions" aria-activedescendant={activeIndex >= 0 ? `theme-search-result-${activeIndex}` : undefined} aria-autocomplete="list" role="combobox" />
156
+ <button type="submit" aria-label="Pesquisar produtos"><svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="11" cy="11" r="7" /><path d="m16.5 16.5 4 4" /></svg></button>
157
+ </form>
158
+ {open && query.length >= 2 && <div className="search-suggestions" id="theme-search-suggestions" role="listbox" aria-label="Sugestões de produtos">
159
+ <div className="search-suggestions-heading"><strong>Sugestões para “{query}”</strong>{!loading && <span>{resultLabel}</span>}</div>
160
+ {loading && <div className="search-suggestions-loading"><span aria-hidden="true" /><p>Procurando os produtos mais próximos…</p></div>}
161
+ {!loading && results.map((product, index) => <a id={`theme-search-result-${index}`} className={activeIndex === index ? "active" : ""} href={`/produto/${product.slug}`} role="option" aria-selected={activeIndex === index} key={product.slug} onPointerEnter={() => setActiveIndex(index)}>
162
+ <span className="search-suggestion-image"><ThemeImageView image={product.image} fallbackAlt={product.title} /></span>
163
+ <span className="search-suggestion-copy"><strong>{product.title}</strong><span className="search-suggestion-meta">{product.categories[0]?.name && <small>{product.categories[0].name}</small>}{product.sku && <small>Ref. {product.sku}</small>}</span></span>
164
+ {displayPrice(product) && <b>{displayPrice(product)}</b>}
165
+ <span className="search-suggestion-arrow" aria-hidden="true">→</span>
166
+ </a>)}
167
+ {!loading && !results.length && <div className="search-suggestions-empty"><strong>Nenhum produto encontrado</strong><p>Tente outro nome, marca ou referência.</p></div>}
168
+ {!loading && <a className="search-all-results" href={`/produtos?busca=${encodeURIComponent(query)}`}><span>Ver todos os resultados</span><strong>→</strong></a>}
169
+ </div>}
170
+ </div>;
171
+ }
172
+
173
+ function MobileCategories({ categories, path = [] }: { categories: ThemeCategory[]; path?: string[] }) {
174
+ return categories.map((category) => {
175
+ const next = [...path, category.slug];
176
+ return category.children?.length ? <details key={category.slug} className="mobile-menu-category"><summary><span>{category.name}</span><span aria-hidden="true">+</span></summary><div><a href={categoryUrl(next)}>Ver tudo em {category.name}</a><MobileCategories categories={category.children} path={next} /></div></details> : <a key={category.slug} href={categoryUrl(next)}>{category.name}</a>;
177
+ });
178
+ }
179
+
180
+ export function MobileStoreMenu({ site, categories, pages }: { site: ThemeSite; categories: ThemeCategory[]; pages: ThemePageSummary[] }) {
181
+ const [open, setOpen] = useState(false);
182
+ useEffect(() => {
183
+ if (!open) return;
184
+ const previous = document.body.style.overflow;
185
+ document.body.style.overflow = "hidden";
186
+ return () => { document.body.style.overflow = previous; };
187
+ }, [open]);
188
+ const settings = site.settings;
189
+ return <><button type="button" className="mobile-menu-trigger" onClick={() => setOpen(true)} aria-label="Abrir menu"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M4 7h16M4 12h16M4 17h16" /></svg></button>{open && <div className="mobile-menu-backdrop" role="presentation" onPointerDown={(event) => event.target === event.currentTarget && setOpen(false)}><aside className="mobile-menu-drawer" aria-label="Menu da loja"><div className="mobile-menu-heading"><div><small>Navegue pela loja</small><strong>{settings?.siteName || site.tenant.name}</strong></div><button type="button" onClick={() => setOpen(false)} aria-label="Fechar menu">×</button></div><nav className="mobile-menu-links"><a href="/">Início</a>{site.modules.includes("PRODUCTS") && <a href="/produtos">Todos os produtos</a>}{site.modules.includes("BLOG") && <a href="/blog">Blog</a>}{site.modules.includes("SERVICES") && <a href="/servicos">Serviços</a>}{site.modules.includes("CASES") && <a href="/cases">Cases</a>}{pages.slice(0, 8).map((page) => <a href={`/${page.slug}`} key={page.slug}>{page.title}</a>)}</nav>{categories.length > 0 && <section className="mobile-menu-categories"><h2>Categorias</h2><MobileCategories categories={categories} /></section>}</aside></div>}</>;
190
+ }
@@ -0,0 +1,14 @@
1
+ import type { HeaderProps } from "@nuvler/theme-sdk";
2
+ import { CategoryNavigation, MobileStoreMenu, SmartProductSearch } from "./header-interactions.js";
3
+ import { ThemeImageView } from "./shared.js";
4
+
5
+ function SupplementaryLinks({ site, pages }: Pick<HeaderProps, "site" | "pages">) {
6
+ return <>{site.modules.includes("BLOG") && <a href="/blog">Blog</a>}{site.modules.includes("SERVICES") && <a href="/servicos">Serviços</a>}{site.modules.includes("CASES") && <a href="/cases">Cases</a>}{pages.slice(0, 6).map((page) => <a key={page.slug} href={`/${page.slug}`}>{page.title}</a>)}</>;
7
+ }
8
+
9
+ export function Header({ site, categories, pages, template, cart, suggestionsEndpoint, suggestionsQueryParam, searchProducts }: HeaderProps) {
10
+ const name = site.settings?.siteName || site.tenant.name;
11
+ const hasCategories = categories.length > 0;
12
+ const hasExtra = site.modules.some((module) => ["BLOG", "SERVICES", "CASES"].includes(module)) || pages.length > 0;
13
+ return <><div className="announcement"><div className="store-container announcement-inner"><span>{template.announcement}</span>{site.settings?.contact.phone && <span>{site.settings.contact.phone}</span>}</div></div><header className="store-header"><div className={`store-container header-inner${hasCategories && hasExtra ? "" : " header-inner-simple"}`}><MobileStoreMenu site={site} categories={categories} pages={pages} /><a className="brand" href="/" aria-label={`${name} — início`}>{site.settings?.logo?.url ? <ThemeImageView image={site.settings.logo} fallbackAlt={name} className="brand-logo" priority /> : <><span className="brand-mark">7</span><span>{name}</span></>}</a>{site.modules.includes("PRODUCTS") && <SmartProductSearch endpoint={suggestionsEndpoint} queryParam={suggestionsQueryParam} searchProducts={searchProducts} />}<div className="header-message"><span className="header-message-icon" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="m12 3 2.1 4.9L19 10l-4.9 2.1L12 17l-2.1-4.9L5 10l4.9-2.1L12 3Z" /></svg></span><span className="header-message-copy"><small>Nossa loja</small><strong>{site.settings?.description?.trim() || template.announcement}</strong></span></div>{hasCategories && hasExtra && <div className="header-actions"><details className="header-more-menu"><summary>Mais <span aria-hidden="true">⌄</span></summary><div className="header-more-panel"><SupplementaryLinks site={site} pages={pages} /></div></details></div>}{cart}</div>{hasCategories ? <CategoryNavigation categories={categories} /> : <div className="primary-nav-shell"><nav className="store-container main-nav" aria-label="Navegação principal"><a href="/">Início</a>{site.modules.includes("PRODUCTS") && <a href="/produtos">Produtos</a>}<SupplementaryLinks site={site} pages={pages} /></nav></div>}</header></>;
14
+ }
@@ -0,0 +1,69 @@
1
+ import type { HomeProps, ThemeEditorialItem, ThemeHomeSection, ThemeSite } from "@nuvler/theme-sdk";
2
+ import { BannerCarousel, type ThemeBanner } from "./banner-carousel.js";
3
+ import { ProductCarousel } from "./product-carousel.js";
4
+ import { ThemeImageView } from "./shared.js";
5
+
6
+ function text(data: Record<string, unknown>, key: string, fallback = "") {
7
+ const value = data[key];
8
+ return typeof value === "string" && value.trim() ? value.trim() : fallback;
9
+ }
10
+
11
+ function limit(data: Record<string, unknown>) {
12
+ const value = Number(data.limit);
13
+ return Number.isInteger(value) ? Math.min(12, Math.max(1, value)) : 6;
14
+ }
15
+
16
+ function banners(data: Record<string, unknown>): ThemeBanner[] {
17
+ if (!Array.isArray(data.banners)) return [];
18
+ return data.banners.flatMap((entry) => {
19
+ if (!entry || typeof entry !== "object") return [];
20
+ const item = entry as Record<string, unknown>;
21
+ if (typeof item.imageUrl !== "string" || !item.imageUrl) return [];
22
+ return [{ imageUrl: item.imageUrl, imageAlt: typeof item.imageAlt === "string" ? item.imageAlt : undefined, title: typeof item.title === "string" ? item.title : undefined, description: typeof item.description === "string" ? item.description : undefined, buttonLabel: typeof item.buttonLabel === "string" ? item.buttonLabel : undefined, buttonUrl: typeof item.buttonUrl === "string" ? item.buttonUrl : undefined }];
23
+ });
24
+ }
25
+
26
+ function Heading({ data, title, href }: { data: Record<string, unknown>; title: string; href: string }) {
27
+ return <div className="section-heading"><div><span>{text(data, "eyebrow", "Em destaque")}</span><h2>{text(data, "title", title)}</h2></div><a href={href}>Ver todos</a></div>;
28
+ }
29
+
30
+ function Hero({ section, site, action }: { section: ThemeHomeSection; site: ThemeSite; action: { label: string; href: string } }) {
31
+ const name = site.settings?.siteName || site.tenant.name;
32
+ const title = text(section.data, "title", "Tudo o que você procura, em um só lugar.");
33
+ const description = text(section.data, "description", site.settings?.description || `Conheça a seleção de produtos da ${name}.`);
34
+ const imageUrl = text(section.data, "imageUrl");
35
+ const copy = <div className="hero-copy"><span className="hero-eyebrow">{text(section.data, "eyebrow", "Bem-vindo à nossa loja")}</span><h1>{title}</h1><p>{description}</p><div className="hero-actions"><a className="button button-primary" href={text(section.data, "buttonUrl", action.href)}>{text(section.data, "buttonLabel", action.label)}</a>{site.modules.includes("PRODUCTS") && <a className="text-link" href="/produtos">Ver catálogo completo <span>→</span></a>}</div></div>;
36
+ if (imageUrl) return <section className="hero-section hero-section-image"><ThemeImageView image={{ url: imageUrl, alt: text(section.data, "imageAlt", title), width: null, height: null }} fallbackAlt={title} className="hero-background-image" priority /><div className="hero-background-overlay" aria-hidden="true" /><div className="store-container hero-image-content">{copy}</div></section>;
37
+ return <section className="hero-section"><div className="store-container hero-grid">{copy}<div className="hero-art" aria-hidden="true"><div className="hero-orbit hero-orbit-one" /><div className="hero-orbit hero-orbit-two" /><div className="hero-seven">7</div><span className="hero-card hero-card-top">Seleção especial</span><span className="hero-card hero-card-bottom">Atendimento humano</span></div></div></section>;
38
+ }
39
+
40
+ function EditorialGrid({ items, basePath }: { items: ThemeEditorialItem[]; basePath: string }) {
41
+ if (!items.length) return <div className="empty-state"><span>7</span><h2>Nenhum conteúdo publicado</h2><p>As publicações aparecerão aqui quando estiverem disponíveis.</p></div>;
42
+ return <div className="editorial-grid">{items.map((item) => <article className="editorial-card" key={item.slug}><a className="editorial-card-image" href={`${basePath}/${item.slug}`}><ThemeImageView image={item.image || item.thumbnail || item.coverImage} fallbackAlt={item.title} /></a><div className="editorial-card-content">{(item.category?.title || item.category?.name) && <span>{item.category.title || item.category.name}</span>}<h2><a href={`${basePath}/${item.slug}`}>{item.title}</a></h2><p>{item.description}</p><a className="text-link" href={`${basePath}/${item.slug}`}>Saiba mais <span>→</span></a></div></article>)}</div>;
43
+ }
44
+
45
+ function TextSection({ section }: { section: ThemeHomeSection }) {
46
+ const title = text(section.data, "title", "Conteúdo");
47
+ const description = text(section.data, "description", text(section.data, "text"));
48
+ const imageUrl = text(section.data, "imageUrl");
49
+ if (section.type === "image-text") return <section className="store-section image-text-section"><div className="store-container image-text-layout" data-position={section.data.imagePosition === "right" ? "right" : "left"}>{imageUrl && <div className="image-text-media"><ThemeImageView image={{ url: imageUrl, alt: title, width: null, height: null }} fallbackAlt={title} /></div>}<div className="image-text-copy">{text(section.data, "eyebrow") && <span>{text(section.data, "eyebrow")}</span>}<h2>{title}</h2>{description && <p>{description}</p>}</div></div></section>;
50
+ return <section className="store-section editorial-section"><div className="store-container editorial-content">{text(section.data, "eyebrow") && <span>{text(section.data, "eyebrow")}</span>}<h2>{title}</h2>{description && <p>{description}</p>}{section.type === "cta" && text(section.data, "buttonLabel") && text(section.data, "buttonUrl") && <a className="button button-primary" href={text(section.data, "buttonUrl")}>{text(section.data, "buttonLabel")}</a>}</div></section>;
51
+ }
52
+
53
+ export function Home({ sections, products, posts, services, cases, site, template }: HomeProps) {
54
+ const visible = [...sections].filter((section) => section.enabled).sort((a, b) => a.order - b.order);
55
+ const rendered = visible.length ? visible : template.fallbackSections(site.modules);
56
+ const catalog = site.settings?.catalog ?? { showCategory: true, showDescription: true };
57
+ return <>{rendered.map((section, index) => {
58
+ if (section.type === "hero") return <Hero key={section.id || index} section={section} site={site} action={template.primaryAction(site.modules)} />;
59
+ if (section.type === "banner-carousel") return <BannerCarousel key={section.id || index} banners={banners(section.data)} autoplay={section.data.autoplay !== false} />;
60
+ if (["image-text", "rich-text", "cta"].includes(section.type)) return <TextSection key={section.id || index} section={section} />;
61
+ if (section.type === "products-grid" || section.type === "products-carousel") {
62
+ const category = text(section.data, "categorySlug");
63
+ const items = products.filter((product) => !category || product.categories.some(({ slug }) => slug === category)).slice(0, limit(section.data));
64
+ return <section className="store-section" key={section.id || index}><div className="store-container"><Heading data={section.data} title={section.type === "products-grid" ? "Produtos em destaque" : "Vitrine de produtos"} href="/produtos" /><ProductCarousel products={items} showCategory={catalog.showCategory} showDescription={catalog.showDescription} /></div></section>;
65
+ }
66
+ const map = section.type === "services-grid" ? { items: services, path: "/servicos", title: "Nossos serviços" } : section.type === "cases-grid" ? { items: cases, path: "/cases", title: "Cases e resultados" } : { items: posts, path: "/blog", title: "Conteúdos recentes" };
67
+ return <section className="store-section" key={section.id || index}><div className="store-container"><Heading data={section.data} title={map.title} href={map.path} /><EditorialGrid items={map.items.slice(0, limit(section.data))} basePath={map.path} /></div></section>;
68
+ })}<section className="benefits-section"><div className="store-container benefits-grid">{template.benefits.map((benefit) => <div key={benefit.title}><strong>{benefit.title}</strong><span>{benefit.description}</span></div>)}</div></section></>;
69
+ }