@nuvler/cli 0.5.8 → 0.5.10

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 (36) hide show
  1. package/README.md +7 -5
  2. package/dist/api/theme-context.js.map +1 -1
  3. package/dist/commands/theme/upgrade.js +2 -1
  4. package/dist/commands/theme/upgrade.js.map +1 -1
  5. package/dist/migrate/generator.js +21 -10
  6. package/dist/migrate/generator.js.map +1 -1
  7. package/dist/migrate/transformer.js +2 -1
  8. package/dist/migrate/transformer.js.map +1 -1
  9. package/dist/nuvler.js +116 -15
  10. package/dist/nuvler.js.map +1 -1
  11. package/dist/templates/nuvler-atelier/nuvler.theme.json +1 -1
  12. package/dist/templates/nuvler-atelier/package.json +1 -1
  13. package/dist/templates/nuvler-atelier/src/definition.tsx +8 -7
  14. package/dist/templates/nuvler-atelier/src/theme.tsx +24 -4
  15. package/dist/templates/nuvler-default/README.md +2 -2
  16. package/dist/templates/nuvler-default/nuvler.theme.json +1 -1
  17. package/dist/templates/nuvler-default/package.json +6 -5
  18. package/dist/templates/nuvler-default/scripts/verify-release.mjs +30 -0
  19. package/dist/templates/nuvler-default/src/banner-carousel.tsx +16 -15
  20. package/dist/templates/nuvler-default/src/header-interactions.tsx +2 -2
  21. package/dist/templates/nuvler-default/src/header.tsx +1 -1
  22. package/dist/templates/nuvler-default/src/home.tsx +13 -2
  23. package/dist/templates/nuvler-default/src/mini-banners.tsx +44 -0
  24. package/dist/templates/nuvler-default/src/product-carousel.tsx +2 -2
  25. package/dist/templates/nuvler-default/src/product-detail-interactive.tsx +7 -2
  26. package/dist/templates/nuvler-default/src/product-detail.tsx +3 -1
  27. package/dist/templates/nuvler-default/src/products.tsx +5 -4
  28. package/dist/templates/nuvler-default/src/theme-component.tsx +18 -4
  29. package/dist/templates/nuvler-default/src/theme.css +69 -8
  30. package/dist/templates/starter/package.json +1 -1
  31. package/dist/templates/starter/src/definition.tsx +5 -5
  32. package/dist/templates/starter/src/theme.tsx +2 -2
  33. package/package.json +3 -3
  34. package/preview-host/package.json +1 -1
  35. package/preview-host/src/fallback-context.json +1 -0
  36. package/preview-host/vendor/theme-runtime/default-theme.tsx +34 -5
@@ -34,6 +34,10 @@ interface PreviewCartItem extends ThemeCartItem {
34
34
  quantity: number;
35
35
  }
36
36
 
37
+ function money(value: number): string {
38
+ return new Intl.NumberFormat("pt-BR", { style: "currency", currency: "BRL" }).format(value);
39
+ }
40
+
37
41
  function catalogHref(route: Extract<PreviewRoute, { type: "catalog" }>, page: number): string {
38
42
  const params = new URLSearchParams();
39
43
  if (route.search) params.set("busca", route.search);
@@ -93,8 +97,18 @@ export function createNuvlerDefaultRuntime(themeDefinition: NuvlerStoreThemeDefi
93
97
  "--container-width": `${containerWidth}px`,
94
98
  "--border-radius": `${borderRadius}px`,
95
99
  } as CSSProperties;
100
+ const showPrices = site.settings?.catalog?.showPrices ?? true;
96
101
  const cartCount = cartItems.reduce((total, item) => total + item.quantity, 0);
97
- const cartMessage = useMemo(() => `Olá! Gostaria de solicitar um orçamento para os itens abaixo:\n\n${cartItems.map((item, index) => `${index + 1}. ${item.quantity}x ${item.title}${item.variantName ? ` (${item.variantName})` : ""}${item.sku ? ` — ref. ${item.sku}` : ""}`).join("\n\n")}`, [cartItems]);
102
+ const cartTotal = cartItems.reduce((total, item) => total + (item.unitPrice ?? 0) * item.quantity, 0);
103
+ const hasCompletePrices = cartItems.length > 0 && cartItems.every(({ unitPrice }) => typeof unitPrice === "number");
104
+ const cartMessage = useMemo(() => {
105
+ const lines = cartItems.map((item, index) => {
106
+ const price = showPrices && typeof item.unitPrice === "number" ? `\nValor unitário: ${money(item.unitPrice)}` : "";
107
+ return `${index + 1}. ${item.quantity}x ${item.title}${item.variantName ? ` (${item.variantName})` : ""}${item.sku ? ` — ref. ${item.sku}` : ""}${price}`;
108
+ });
109
+ const summary = showPrices && hasCompletePrices ? `\n\nTotal estimado: ${money(cartTotal)}` : "";
110
+ return `Olá! Gostaria de solicitar um orçamento para os itens abaixo:\n\n${lines.join("\n\n")}${summary}`;
111
+ }, [cartItems, cartTotal, hasCompletePrices, showPrices]);
98
112
  const whatsapp = site.settings?.contact.whatsapp?.replace(/\D/g, "");
99
113
  const checkoutUrl = whatsapp && cartItems.length
100
114
  ? `https://wa.me/${whatsapp}?text=${encodeURIComponent(cartMessage)}`
@@ -111,15 +125,15 @@ export function createNuvlerDefaultRuntime(themeDefinition: NuvlerStoreThemeDefi
111
125
  const cartButton = <button type="button" className="cart-button" onClick={() => setCartOpen(true)} aria-label={`Abrir carrinho com ${cartCount} itens`}><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M3 4h2l2 11h10l2-8H6M9 20h.01M17 20h.01" /></svg>{cartCount > 0 && <span>{Math.min(cartCount, 99)}</span>}</button>;
112
126
  let content;
113
127
  if (route.type === "home") content = <main><Home sections={context.home.content.sections} products={context.catalog.products} posts={context.editorial.posts} services={context.editorial.services} cases={context.editorial.cases} site={site} submitContact={sdk?.contact?.submit} template={themeDefinition.template} /></main>;
114
- else if (route.type === "product") content = <main className="product-page"><div className="store-container"><nav className="breadcrumbs" aria-label="Navegação estrutural"><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={window.location.href} descriptionContent={<p>{plainText(route.product.description)}</p>} onAddToCart={addToCart} /></div></main>;
115
- else if (route.type === "catalog") content = <main className="catalog-page"><section className="catalog-hero"><div className="store-container"><span>Nosso catálogo</span><h1>{route.search ? `Busca por “${route.search}”` : "Todos os produtos"}</h1><p>{route.pagination.total} produto(s)</p></div></section><div className="store-container catalog-layout"><aside className="category-filter catalog-filters"><form action={route.categoryPath.length ? `/${route.categoryPath.join("/")}` : "/produtos"} className="catalog-filter-form"><label htmlFor="preview-catalog-search">Buscar no catálogo</label><div className="catalog-filter-search"><input id="preview-catalog-search" name="busca" type="search" defaultValue={route.search} placeholder="Nome do produto" /><button type="submit" aria-label="Pesquisar">⌕</button></div></form>{route.facets.length > 0 && <form className="catalog-variant-filters">{route.search && <input type="hidden" name="busca" value={route.search} />}{route.facets.map((facet) => <fieldset className="catalog-filter-section" key={facet.name}><legend>{facet.name}</legend>{facet.values.map(({ value, count }) => { const token = `${facet.name}::${value}`; return <label className="catalog-filter-checkbox" key={token}><input type="checkbox" name="variante" value={token} defaultChecked={route.variants.includes(token)} /><span>{value}</span><small>{count}</small></label>; })}</fieldset>)}<button type="submit" className="button button-primary button-block">Aplicar filtros</button></form>}</aside><section className="catalog-results"><ProductGrid products={route.products} columns={site.settings?.catalog?.desktopColumns || 3} showCategory={site.settings?.catalog?.showCategory} showDescription={site.settings?.catalog?.showDescription} />{route.pagination.totalPages > 1 && <nav className="catalog-pagination" aria-label="Paginação dos produtos"><a className={route.pagination.hasPreviousPage ? "" : "disabled"} href={catalogHref(route, Math.max(1, route.pagination.page - 1))}><span>‹</span> Anterior</a><div className="catalog-pagination-pages"><span className="catalog-pagination-item"><a className="active" href={catalogHref(route, route.pagination.page)}>{route.pagination.page}</a></span></div><a className={route.pagination.hasNextPage ? "" : "disabled"} href={catalogHref(route, Math.min(route.pagination.totalPages, route.pagination.page + 1))}>Próxima <span>›</span></a></nav>}</section></div></main>;
128
+ else if (route.type === "product") content = <main className="product-page"><div className="store-container"><nav className="breadcrumbs" aria-label="Navegação estrutural"><a href="/">Início</a><span>/</span><a href="/produtos">Produtos</a><span>/</span><strong>{route.product.title}</strong></nav><ProductDetail product={route.product} showPrices={showPrices} contact={site.settings?.contact} productUrl={window.location.href} descriptionContent={<p>{plainText(route.product.description)}</p>} onAddToCart={addToCart} /></div></main>;
129
+ else if (route.type === "catalog") content = <main className="catalog-page"><section className="catalog-hero"><div className="store-container"><span>Nosso catálogo</span><h1>{route.search ? `Busca por “${route.search}”` : "Todos os produtos"}</h1><p>{route.pagination.total} produto(s)</p></div></section><div className="store-container catalog-layout"><aside className="category-filter catalog-filters"><form action={route.categoryPath.length ? `/${route.categoryPath.join("/")}` : "/produtos"} className="catalog-filter-form"><label htmlFor="preview-catalog-search">Buscar no catálogo</label><div className="catalog-filter-search"><input id="preview-catalog-search" name="busca" type="search" defaultValue={route.search} placeholder="Nome do produto" /><button type="submit" aria-label="Pesquisar">⌕</button></div></form>{route.facets.length > 0 && <form className="catalog-variant-filters">{route.search && <input type="hidden" name="busca" value={route.search} />}{route.facets.map((facet) => <fieldset className="catalog-filter-section" key={facet.name}><legend>{facet.name}</legend>{facet.values.map(({ value, count }) => { const token = `${facet.name}::${value}`; return <label className="catalog-filter-checkbox" key={token}><input type="checkbox" name="variante" value={token} defaultChecked={route.variants.includes(token)} /><span>{value}</span><small>{count}</small></label>; })}</fieldset>)}<button type="submit" className="button button-primary button-block">Aplicar filtros</button></form>}</aside><section className="catalog-results"><ProductGrid products={route.products} columns={site.settings?.catalog?.desktopColumns || 3} showPrices={showPrices} showCategory={site.settings?.catalog?.showCategory} showDescription={site.settings?.catalog?.showDescription} />{route.pagination.totalPages > 1 && <nav className="catalog-pagination" aria-label="Paginação dos produtos"><a className={route.pagination.hasPreviousPage ? "" : "disabled"} href={catalogHref(route, Math.max(1, route.pagination.page - 1))}><span>‹</span> Anterior</a><div className="catalog-pagination-pages"><span className="catalog-pagination-item"><a className="active" href={catalogHref(route, route.pagination.page)}>{route.pagination.page}</a></span></div><a className={route.pagination.hasNextPage ? "" : "disabled"} href={catalogHref(route, Math.min(route.pagination.totalPages, route.pagination.page + 1))}>Próxima <span>›</span></a></nav>}</section></div></main>;
116
130
  else if (route.type === "editorial-list") { const meta = editorialMeta(route.basePath); content = <main className="editorial-list-page"><section className="theme-page-hero"><div className="store-container"><span className="page-kicker">{meta.eyebrow}</span><h1>{route.title}</h1></div></section><section className="store-section"><div className="store-container"><EditorialPreview items={route.items} basePath={route.basePath} /></div></section></main>; }
117
131
  else if (route.type === "editorial-detail") { const meta = editorialMeta(route.basePath); const image = route.item.image || route.item.coverImage || route.item.thumbnail; content = <main className="article-page"><article className="store-container article-shell"><nav className="breadcrumbs" aria-label="Navegação estrutural"><a href="/">Início</a><span>/</span><a href={route.basePath}>{route.basePath === "/blog" ? "Blog" : route.basePath === "/servicos" ? "Serviços" : "Cases"}</a><span>/</span><strong>{route.item.title}</strong></nav><header className="article-header">{(route.item.category?.title || route.item.category?.name) ? <span>{route.item.category.title || route.item.category.name}</span> : <span>{meta.eyebrow}</span>}<h1>{route.item.title}</h1>{route.item.description && <p>{route.item.description}</p>}{publishedDate(route.item.publishedAt) && <small>{publishedDate(route.item.publishedAt)}</small>}</header>{image && <ThemeImageView image={image} fallbackAlt={route.item.title} className="article-cover" priority sizes="(max-width: 1100px) 100vw, 1040px" fallbackWidth={1600} fallbackHeight={900} />}<div className="article-content"><a className="text-link" href={route.basePath}>← Voltar para {route.basePath === "/blog" ? "o blog" : route.basePath === "/servicos" ? "serviços" : "cases"}</a></div></article></main>; }
118
132
  else if (route.type === "not-found") content = NotFound ? <NotFound homeHref="/" /> : <main className="not-found-page"><div className="not-found-card"><span>404</span><h1>Conteúdo não encontrado</h1></div></main>;
119
133
  else content = <main className="not-found-page"><div className="not-found-card"><span>Carregando</span><h1>{route.title || "Buscando conteúdo da loja"}</h1></div></main>;
120
134
  // A 404 mantém a mesma moldura das demais páginas, inclusive o footer.
121
135
  const isNotFound = false;
122
- return <ThemeInteractionProvider onAddToCart={addToCart}><div className="store-shell nuvler-default-theme" data-theme-id={themeDefinition.manifest.id} data-theme-version={themeDefinition.manifest.version} style={style}><Header site={site} categories={context.navigation.categories} pages={context.navigation.pages} menu={context.navigation.menu} headerButton={context.navigation.headerButton} template={themeDefinition.template} searchProducts={adapters?.searchProducts} cart={cartButton} /><div className={`store-page${isNotFound ? " store-page-not-found" : ""}`}>{content}</div>{!isNotFound && <Footer site={site} pages={context.navigation.pages} template={themeDefinition.template} />}{cartOpen && <div className="cart-backdrop" role="presentation" onPointerDown={(event) => event.target === event.currentTarget && setCartOpen(false)}><aside className="cart-drawer" aria-label="Carrinho de orçamento"><div className="cart-heading"><div><small>Seu orçamento</small><strong>{cartCount} {cartCount === 1 ? "item" : "itens"}</strong></div><button type="button" onClick={() => setCartOpen(false)} aria-label="Fechar carrinho">×</button></div><div className="cart-items">{!cartItems.length && <div className="cart-empty"><strong>Seu carrinho está vazio</strong><p>Abra um produto e adicione-o para montar a solicitação.</p><button type="button" onClick={() => setCartOpen(false)}>Continuar navegando</button></div>}{cartItems.map((item) => <article className="cart-item" key={item.key}><a href={item.productUrl || productUrl({ slug: item.productSlug })} onClick={() => setCartOpen(false)}><ThemeImageView image={item.image} fallbackAlt={item.title} /></a><div><strong>{item.title}</strong>{item.variantName && <small>{item.variantName}</small>}{item.sku && <small>Ref. {item.sku}</small>}<div className="cart-quantity"><button type="button" onClick={() => setCartItems((current) => current.flatMap((candidate) => candidate.key !== item.key ? [candidate] : candidate.quantity > 1 ? [{ ...candidate, quantity: candidate.quantity - 1 }] : []))}>−</button><span>{item.quantity}</span><button type="button" onClick={() => setCartItems((current) => current.map((candidate) => candidate.key === item.key ? { ...candidate, quantity: Math.min(99, candidate.quantity + 1) } : candidate))}>+</button><button type="button" className="cart-remove" onClick={() => setCartItems((current) => current.filter((candidate) => candidate.key !== item.key))}>Remover</button></div></div></article>)}</div>{cartItems.length > 0 && <footer className="cart-footer"><p>O valor e a disponibilidade serão confirmados pela loja.</p>{checkoutUrl ? <a className="button button-primary button-block" href={checkoutUrl} target="_blank" rel="noreferrer">Enviar orçamento pelo WhatsApp</a> : <p className="cart-warning">Configure o WhatsApp da loja para enviar o orçamento.</p>}</footer>}</aside></div>}</div></ThemeInteractionProvider>;
136
+ return <ThemeInteractionProvider onAddToCart={addToCart}><div className="store-shell nuvler-default-theme" data-theme-id={themeDefinition.manifest.id} data-theme-version={themeDefinition.manifest.version} style={style}><Header site={site} categories={context.navigation.categories} pages={context.navigation.pages} menu={context.navigation.menu} headerButton={context.navigation.headerButton} template={themeDefinition.template} searchProducts={adapters?.searchProducts} cart={cartButton} /><div className={`store-page${isNotFound ? " store-page-not-found" : ""}`}>{content}</div>{!isNotFound && <Footer site={site} pages={context.navigation.pages} template={themeDefinition.template} />}{cartOpen && <div className="cart-backdrop" role="presentation" onPointerDown={(event) => event.target === event.currentTarget && setCartOpen(false)}><aside className="cart-drawer" aria-label="Carrinho de orçamento"><div className="cart-heading"><div><small>Seu orçamento</small><strong>{cartCount} {cartCount === 1 ? "item" : "itens"}</strong></div><button type="button" onClick={() => setCartOpen(false)} aria-label="Fechar carrinho">×</button></div><div className="cart-items">{!cartItems.length && <div className="cart-empty"><strong>Seu carrinho está vazio</strong><p>Abra um produto e adicione-o para montar a solicitação.</p><button type="button" onClick={() => setCartOpen(false)}>Continuar navegando</button></div>}{cartItems.map((item) => <article className="cart-item" key={item.key}><a href={item.productUrl || productUrl({ slug: item.productSlug })} onClick={() => setCartOpen(false)}><ThemeImageView image={item.image} fallbackAlt={item.title} /></a><div><strong>{item.title}</strong>{item.variantName && <small>{item.variantName}</small>}{item.sku && <small>Ref. {item.sku}</small>}{showPrices && typeof item.unitPrice === "number" && <b>{money(item.unitPrice)}</b>}<div className="cart-quantity"><button type="button" onClick={() => setCartItems((current) => current.flatMap((candidate) => candidate.key !== item.key ? [candidate] : candidate.quantity > 1 ? [{ ...candidate, quantity: candidate.quantity - 1 }] : []))}>−</button><span>{item.quantity}</span><button type="button" onClick={() => setCartItems((current) => current.map((candidate) => candidate.key === item.key ? { ...candidate, quantity: Math.min(99, candidate.quantity + 1) } : candidate))}>+</button><button type="button" className="cart-remove" onClick={() => setCartItems((current) => current.filter((candidate) => candidate.key !== item.key))}>Remover</button></div></div></article>)}</div>{cartItems.length > 0 && <footer className="cart-footer">{showPrices && hasCompletePrices && <div><span>Total estimado</span><strong>{money(cartTotal)}</strong></div>}<p>O valor e a disponibilidade serão confirmados pela loja.</p>{checkoutUrl ? <a className="button button-primary button-block" href={checkoutUrl} target="_blank" rel="noreferrer">Enviar orçamento pelo WhatsApp</a> : <p className="cart-warning">Configure o WhatsApp da loja para enviar o orçamento.</p>}</footer>}</aside></div>}</div></ThemeInteractionProvider>;
123
137
  }
124
138
 
125
139
  Theme.displayName = `NuvlerThemeRuntime(${themeDefinition.manifest.id})`;
@@ -1723,17 +1723,23 @@ select {
1723
1723
  aspect-ratio: var(--banner-desktop-aspect-ratio, 1.78);
1724
1724
  }
1725
1725
 
1726
- .banner-slide > img,
1727
- .banner-slide > .store-image-placeholder {
1726
+ .banner-responsive-image {
1728
1727
  position: absolute;
1729
1728
  inset: 0;
1729
+ display: block;
1730
+ width: 100%;
1731
+ height: 100%;
1732
+ }
1733
+
1734
+ .banner-responsive-image > img,
1735
+ .banner-responsive-image > .store-image-placeholder {
1730
1736
  width: 100%;
1731
1737
  height: 100%;
1732
1738
  object-fit: cover;
1733
1739
  }
1734
- .banner-image-mobile { display: none; }
1735
- .banner-carousel-settings[data-image-fit="contain"] .banner-slide > img { object-fit: contain; }
1736
- .banner-carousel-settings[data-image-fit="natural"] .banner-slide > img { width: auto; height: auto; max-width: 100%; max-height: 100%; object-fit: contain; left: 50%; top: 50%; transform: translate(-50%, -50%); }
1740
+ .banner-carousel-settings[data-image-fit="contain"] .banner-responsive-image > img { object-fit: contain; }
1741
+ .banner-carousel-settings[data-image-fit="natural"] .banner-responsive-image { display: grid; place-items: center; }
1742
+ .banner-carousel-settings[data-image-fit="natural"] .banner-responsive-image > img { width: auto; height: auto; max-width: 100%; max-height: 100%; object-fit: contain; }
1737
1743
 
1738
1744
  .banner-overlay {
1739
1745
  position: absolute;
@@ -1763,6 +1769,59 @@ select {
1763
1769
  line-height: 1.65;
1764
1770
  }
1765
1771
 
1772
+ .mini-banners-section {
1773
+ padding-block: 36px;
1774
+ }
1775
+
1776
+ .mini-banners-grid {
1777
+ display: grid;
1778
+ grid-template-columns: repeat(2, minmax(0, 1fr));
1779
+ gap: clamp(16px, 2vw, 28px);
1780
+ }
1781
+
1782
+ .mini-banners-grid[data-layout="3x1"] {
1783
+ grid-template-columns: repeat(3, minmax(0, 1fr));
1784
+ }
1785
+
1786
+ .mini-banner-card {
1787
+ display: grid;
1788
+ align-content: start;
1789
+ min-width: 0;
1790
+ color: var(--store-text);
1791
+ }
1792
+
1793
+ .mini-banner-image {
1794
+ display: block;
1795
+ aspect-ratio: 16 / 9;
1796
+ border-radius: var(--border-radius);
1797
+ overflow: hidden;
1798
+ background: var(--store-surface-alt);
1799
+ }
1800
+
1801
+ .mini-banner-image > img,
1802
+ .mini-banner-image > .store-image-placeholder {
1803
+ width: 100%;
1804
+ height: 100%;
1805
+ object-fit: cover;
1806
+ transition: transform 220ms ease;
1807
+ }
1808
+
1809
+ .mini-banner-card strong {
1810
+ margin-top: 12px;
1811
+ font-size: clamp(15px, 1.5vw, 19px);
1812
+ line-height: 1.3;
1813
+ }
1814
+
1815
+ a.mini-banner-card:hover .mini-banner-image > img {
1816
+ transform: scale(1.025);
1817
+ }
1818
+
1819
+ a.mini-banner-card:focus-visible {
1820
+ outline: 3px solid var(--color-primary);
1821
+ outline-offset: 5px;
1822
+ border-radius: var(--border-radius);
1823
+ }
1824
+
1766
1825
  .banner-copy .button {
1767
1826
  margin-top: 28px;
1768
1827
  }
@@ -4192,6 +4251,11 @@ select {
4192
4251
  }
4193
4252
 
4194
4253
  @media (max-width: 800px) {
4254
+ .mini-banners-grid,
4255
+ .mini-banners-grid[data-layout="3x1"] {
4256
+ grid-template-columns: 1fr;
4257
+ }
4258
+
4195
4259
  .store-container {
4196
4260
  width: min(calc(100% - 28px), var(--container-width));
4197
4261
  }
@@ -4371,9 +4435,6 @@ select {
4371
4435
  max-height: var(--banner-mobile-height, 420px);
4372
4436
  aspect-ratio: var(--banner-mobile-aspect-ratio, 1.78);
4373
4437
  }
4374
- .banner-image-desktop { display: none; }
4375
- .banner-image-mobile { display: block; }
4376
-
4377
4438
  .banner-overlay {
4378
4439
  align-items: end;
4379
4440
  background: linear-gradient(0deg, rgba(8, 17, 11, 0.78), rgba(8, 17, 11, 0.05) 80%);
@@ -19,7 +19,7 @@
19
19
  "react": "^19.0.0"
20
20
  },
21
21
  "devDependencies": {
22
- "@nuvler/cli": "^0.5.5",
22
+ "@nuvler/cli": "^0.5.10",
23
23
  "@types/react": "^19.0.0",
24
24
  "react": "^19.0.0",
25
25
  "typescript": "^5.9.0"
@@ -32,8 +32,8 @@ function Footer({ site }: FooterProps) {
32
32
  return <footer className="theme-footer"><strong>{name}</strong><span>Tema __NUVLER_THEME_NAME__</span></footer>;
33
33
  }
34
34
 
35
- function ProductGrid({ products }: ProductGridProps) {
36
- return <div className="theme-products">{products.map((product) => <article key={product.slug}><a href={productUrl(product)}><strong>{product.title}</strong><span>{product.sku || "Ver produto"}</span></a></article>)}</div>;
35
+ function ProductGrid({ products, showPrices = true }: ProductGridProps) {
36
+ return <div className="theme-products">{products.map((product) => <article key={product.slug}><a href={productUrl(product)}><strong>{product.title}</strong><span>{showPrices && typeof (product.promotionalPrice ?? product.price) === "number" ? new Intl.NumberFormat("pt-BR", { style: "currency", currency: "BRL" }).format((product.promotionalPrice ?? product.price)!) : product.sku || "Ver produto"}</span></a></article>)}</div>;
37
37
  }
38
38
 
39
39
  function bannerUrl(banner: ThemeHomeBanner, mobile = false): string {
@@ -51,12 +51,12 @@ function Home({ products, site, sections }: HomeProps) {
51
51
  {(banner.title || banner.description || (banner.buttonLabel && banner.buttonUrl)) && <div className="theme-banner-content">{banner.title && <h2>{banner.title}</h2>}{banner.description && <p>{banner.description}</p>}{banner.buttonLabel && banner.buttonUrl && <a href={banner.buttonUrl}>{banner.buttonLabel}</a>}</div>}
52
52
  </section>}
53
53
  <section className="theme-hero"><span>__NUVLER_THEME_NAME__</span><h1>{name}</h1><p>{site.settings?.description || "Uma nova experiência de compra."}</p><a href="/produtos">Explorar produtos</a></section>
54
- <section className="theme-section"><h2>Produtos em destaque</h2><ProductGrid products={products} /></section>
54
+ <section className="theme-section"><h2>Produtos em destaque</h2><ProductGrid products={products} showPrices={site.settings?.catalog?.showPrices ?? true} /></section>
55
55
  </main>;
56
56
  }
57
57
 
58
- function ProductDetail({ product, descriptionContent, onAddToCart }: ProductDetailProps) {
59
- return <article className="theme-product-detail"><div><span>{product.categories[0]?.name || "Produto"}</span><h1>{product.title}</h1>{descriptionContent}</div><button type="button" onClick={() => onAddToCart?.({ productSlug: product.slug, productUrl: productUrl(product), title: product.title, sku: product.sku, image: product.image, unitPrice: product.promotionalPrice ?? product.price })}>Adicionar ao orçamento</button></article>;
58
+ function ProductDetail({ product, showPrices = true, descriptionContent, onAddToCart }: ProductDetailProps) {
59
+ return <article className="theme-product-detail"><div><span>{product.categories[0]?.name || "Produto"}</span><h1>{product.title}</h1>{showPrices && typeof (product.promotionalPrice ?? product.price) === "number" && <strong>{new Intl.NumberFormat("pt-BR", { style: "currency", currency: "BRL" }).format((product.promotionalPrice ?? product.price)!)}</strong>}{descriptionContent}</div><button type="button" onClick={() => onAddToCart?.({ productSlug: product.slug, productUrl: productUrl(product), title: product.title, sku: product.sku, image: product.image, unitPrice: showPrices ? product.promotionalPrice ?? product.price : null })}>Adicionar ao orçamento</button></article>;
60
60
  }
61
61
 
62
62
  export const manifest = manifestData as ThemeManifest;
@@ -35,8 +35,8 @@ export default function Theme({ context, route = { type: "home" }, sdk }: Nuvler
35
35
 
36
36
  let content;
37
37
  if (route.type === "home") 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} />;
38
- else if (route.type === "catalog") content = <main className="theme-section"><h1>{route.search ? `Busca: ${route.search}` : "Produtos"}</h1><ProductGrid products={route.products} /></main>;
39
- else if (route.type === "product") content = <main className="theme-section"><ProductDetail product={route.product} contact={site.settings?.contact} productUrl={null} descriptionContent={<p>{route.product.description}</p>} onAddToCart={sdk?.cart.add} /></main>;
38
+ else if (route.type === "catalog") content = <main className="theme-section"><h1>{route.search ? `Busca: ${route.search}` : "Produtos"}</h1><ProductGrid products={route.products} showPrices={site.settings?.catalog?.showPrices ?? true} /></main>;
39
+ else if (route.type === "product") content = <main className="theme-section"><ProductDetail product={route.product} showPrices={site.settings?.catalog?.showPrices ?? true} contact={site.settings?.contact} productUrl={null} descriptionContent={<p>{route.product.description}</p>} onAddToCart={sdk?.cart.add} /></main>;
40
40
  else if (route.type === "editorial-list") content = <main className="theme-section"><h1>{route.title}</h1>{route.items.map((item) => <article key={item.slug}><h2>{item.title}</h2><p>{item.description}</p></article>)}</main>;
41
41
  else if (route.type === "editorial-detail") content = <main className="theme-section"><h1>{route.item.title}</h1><p>{route.item.description}</p></main>;
42
42
  else content = <main className="theme-section"><h1>{route.type === "loading" ? "Carregando…" : route.type === "page" ? route.title : "Conteúdo não encontrado"}</h1></main>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuvler/cli",
3
- "version": "0.5.8",
3
+ "version": "0.5.10",
4
4
  "description": "CLI oficial para criação, validação, preview e empacotamento de temas Nuvler",
5
5
  "type": "module",
6
6
  "bin": {
@@ -20,8 +20,8 @@
20
20
  "typecheck": "tsc -p tsconfig.json --noEmit"
21
21
  },
22
22
  "dependencies": {
23
- "@nuvler/theme-schema": "^1.3.2",
24
- "@nuvler/theme-sdk": "^1.3.3",
23
+ "@nuvler/theme-schema": "^1.4.0",
24
+ "@nuvler/theme-sdk": "^1.4.2",
25
25
  "@vitejs/plugin-react": "^6.0.5",
26
26
  "commander": "^15.0.0",
27
27
  "react": "19.2.8",
@@ -10,7 +10,7 @@
10
10
  "typecheck": "tsc -p tsconfig.json --noEmit"
11
11
  },
12
12
  "dependencies": {
13
- "@nuvler/theme-sdk": "1.3.3",
13
+ "@nuvler/theme-sdk": "^1.4.2",
14
14
  "react": "19.2.8",
15
15
  "react-dom": "19.2.8"
16
16
  },
@@ -12,6 +12,7 @@
12
12
  "social": {},
13
13
  "catalog": {
14
14
  "showProductsWithoutImage": true,
15
+ "showPrices": true,
15
16
  "showDescription": true,
16
17
  "showCategory": true,
17
18
  "productsPerPage": 12,
@@ -2,6 +2,7 @@ import { useEffect, useMemo, useRef, useState, type CSSProperties, type FormEven
2
2
  import type {
3
3
  ThemeCategory,
4
4
  ThemeBannerCarouselData,
5
+ ThemeMiniBannersData,
5
6
  ThemeContext,
6
7
  ThemeHomeSection,
7
8
  ThemeHomeSectionType,
@@ -45,6 +46,7 @@ const template = {
45
46
  };
46
47
 
47
48
  const fallbackCatalog = {
49
+ showPrices: true,
48
50
  showDescription: true,
49
51
  showCategory: true,
50
52
  desktopColumns: 3 as const,
@@ -120,7 +122,7 @@ function displayPrice(product: ThemeProduct): string | null {
120
122
  : null;
121
123
  }
122
124
 
123
- function SmartSearch({ adapters }: { adapters: ThemeRuntimeAdapters }) {
125
+ function SmartSearch({ adapters, showPrices }: { adapters: ThemeRuntimeAdapters; showPrices: boolean }) {
124
126
  const { Link, Image } = adapters;
125
127
  const [value, setValue] = useState("");
126
128
  const [results, setResults] = useState<ThemeProduct[]>([]);
@@ -159,7 +161,7 @@ function SmartSearch({ adapters }: { adapters: ThemeRuntimeAdapters }) {
159
161
  {!loading && results.map((product) => <Link href={productUrl(product)} key={product.slug}>
160
162
  <span className="search-suggestion-image"><Image image={product.image} fallbackAlt={product.title} /></span>
161
163
  <span className="search-suggestion-copy"><strong>{product.title}</strong><small>{product.sku ? `Ref. ${product.sku}` : product.categories[0]?.name || "Produto"}</small></span>
162
- {displayPrice(product) && <b>{displayPrice(product)}</b>}
164
+ {showPrices && displayPrice(product) && <b>{displayPrice(product)}</b>}
163
165
  </Link>)}
164
166
  {!loading && !results.length && <p>Nenhum produto próximo foi encontrado.</p>}
165
167
  <Link className="search-all-results" href={`/produtos?busca=${encodeURIComponent(value.trim())}`}>Ver todos os resultados</Link>
@@ -194,7 +196,7 @@ function Header({ context, adapters }: Omit<DefaultThemeProps, "children">) {
194
196
  )}
195
197
  </Link>
196
198
  {context.site.modules.includes("PRODUCTS") && (
197
- <SmartSearch adapters={adapters} />
199
+ <SmartSearch adapters={adapters} showPrices={settings?.catalog?.showPrices ?? true} />
198
200
  )}
199
201
  <div className="header-message">
200
202
  <span className="header-message-icon" aria-hidden="true">
@@ -301,6 +303,7 @@ function ProductCard({ product, context, adapters }: {
301
303
  {catalog.showDescription && product.description && (
302
304
  <p className="product-card-description">{plainText(product.description)}</p>
303
305
  )}
306
+ {catalog.showPrices && displayPrice(product) && <b>{displayPrice(product)}</b>}
304
307
  <Link className="button button-secondary button-block" href={href}>
305
308
  Ver detalhes e orçar
306
309
  </Link>
@@ -377,6 +380,29 @@ function BannerSection({ section, adapters }: ThemeSectionRendererProps) {
377
380
  );
378
381
  }
379
382
 
383
+ function MiniBannersSection({ section, adapters }: ThemeSectionRendererProps) {
384
+ const { Image, Link } = adapters;
385
+ const data = section.data as ThemeMiniBannersData;
386
+ const items = Array.isArray(data.items)
387
+ ? data.items.filter((item) => Boolean(item.image?.url || item.imageUrl))
388
+ : [];
389
+ if (!items.length) return null;
390
+ return (
391
+ <section className="store-section mini-banners-section">
392
+ <div className="store-container mini-banners-grid" data-layout={data.layout}>
393
+ {items.map((item, index) => {
394
+ const image = item.image || (item.imageUrl ? { url: item.imageUrl, alt: item.imageAlt || item.title || "Mini banner", width: null, height: null } : null);
395
+ if (!image) return null;
396
+ const content = <><span className="mini-banner-image"><Image image={image} fallbackAlt={item.title || "Mini banner"} /></span>{item.title && <strong>{item.title}</strong>}</>;
397
+ return item.link
398
+ ? <Link className="mini-banner-card" href={item.link} key={`${image.url}-${index}`}>{content}</Link>
399
+ : <div className="mini-banner-card" key={`${image.url}-${index}`}>{content}</div>;
400
+ })}
401
+ </div>
402
+ </section>
403
+ );
404
+ }
405
+
380
406
  function TextSection({ section, adapters }: ThemeSectionRendererProps) {
381
407
  const { Link, Image } = adapters;
382
408
  const title = dataString(section.data, "title", "Conteúdo");
@@ -717,6 +743,7 @@ function AutomaticSection({ section, context, adapters }: ThemeSectionRendererPr
717
743
  export const defaultSectionRegistry: ThemeSectionRegistry = {
718
744
  hero: HeroSection,
719
745
  "banner-carousel": BannerSection,
746
+ "mini-banners": MiniBannersSection,
720
747
  "image-text": TextSection,
721
748
  "rich-text": TextSection,
722
749
  cta: TextSection,
@@ -809,14 +836,16 @@ function ProductPage({ product, context, adapters }: {
809
836
  }, [product.image, product.images, selectedVariant]);
810
837
  const [selectedImageUrl, setSelectedImageUrl] = useState<string | null>(null);
811
838
  const selectedImage = images.find((image) => image.url === selectedImageUrl) || images[0] || product.image;
839
+ const showPrices = context.site.settings?.catalog?.showPrices ?? true;
812
840
  const whatsapp = context.site.settings?.contact.whatsapp?.replace(/\D/g, "");
813
- const quoteUrl = whatsapp ? `https://wa.me/${whatsapp}?text=${encodeURIComponent(`Olá! Gostaria de solicitar um orçamento para ${product.title}.`)}` : null;
841
+ const priceText = showPrices && displayPrice(product) ? ` Valor: ${displayPrice(product)}.` : "";
842
+ const quoteUrl = whatsapp ? `https://wa.me/${whatsapp}?text=${encodeURIComponent(`Olá! Gostaria de solicitar um orçamento para ${product.title}.${priceText}`)}` : null;
814
843
 
815
844
  return <main className="product-page"><div className="store-container">
816
845
  <nav className="breadcrumbs"><Link href="/">Início</Link><span>/</span><Link href="/produtos">Produtos</Link><span>/</span><strong>{product.title}</strong></nav>
817
846
  <div className="product-detail">
818
847
  <div className="product-gallery"><div className="product-main-image"><Image image={selectedImage} fallbackAlt={selectedVariant?.name || product.title} priority /></div>{images.length > 1 && <div className="product-thumbnails">{images.map((image, index) => <button className={selectedImage?.url === image.url ? "active" : ""} type="button" onClick={() => setSelectedImageUrl(image.url)} key={`${image.url}-${index}`}><Image image={image} fallbackAlt={`${product.title} ${index + 1}`} /></button>)}</div>}</div>
819
- <div className="product-info">{product.categories[0] && <span className="product-category">{product.categories[0].name}</span>}<h1>{product.title}</h1><div className="product-description">{plainText(product.description)}</div>
848
+ <div className="product-info">{product.categories[0] && <span className="product-category">{product.categories[0].name}</span>}<h1>{product.title}</h1>{showPrices && displayPrice(product) && <strong>{displayPrice(product)}</strong>}<div className="product-description">{plainText(product.description)}</div>
820
849
  {product.variants.length > 0 && <div className="variant-selector"><fieldset><legend>Escolha uma variação</legend><div className="variant-values">{product.variants.filter((variant) => variant.active).map((variant) => <button className={variant.id === selectedVariantId ? "active" : ""} type="button" key={variant.id || variant.sku} onClick={() => { setSelectedVariantId(variant.id); setSelectedImageUrl(null); }}>{variant.name || variant.values.map((value) => value.value).join(" / ")}</button>)}</div></fieldset></div>}
821
850
  <div className="product-purchase">{quoteUrl ? <a className="button button-primary button-block" href={quoteUrl} target="_blank" rel="noreferrer">Solicitar orçamento pelo WhatsApp</a> : <span className="button button-secondary button-block">Entre em contato para orçar</span>}</div>
822
851
  <div className="purchase-benefits"><span><strong>Atendimento direto</strong> Fale com quem entende do produto</span><span><strong>Orçamento personalizado</strong> Condições para a sua necessidade</span></div>