@nuvler/cli 0.5.9 → 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.
- package/README.md +7 -5
- package/dist/api/theme-context.js.map +1 -1
- package/dist/commands/theme/upgrade.js +2 -1
- package/dist/commands/theme/upgrade.js.map +1 -1
- package/dist/migrate/generator.js +21 -10
- package/dist/migrate/generator.js.map +1 -1
- package/dist/migrate/transformer.js +2 -1
- package/dist/migrate/transformer.js.map +1 -1
- package/dist/nuvler.js +116 -15
- package/dist/nuvler.js.map +1 -1
- package/dist/templates/nuvler-atelier/nuvler.theme.json +1 -1
- package/dist/templates/nuvler-atelier/package.json +1 -1
- package/dist/templates/nuvler-atelier/src/definition.tsx +8 -7
- package/dist/templates/nuvler-atelier/src/theme.tsx +24 -4
- package/dist/templates/nuvler-default/README.md +2 -2
- package/dist/templates/nuvler-default/nuvler.theme.json +1 -1
- package/dist/templates/nuvler-default/package.json +5 -4
- package/dist/templates/nuvler-default/scripts/verify-release.mjs +30 -0
- package/dist/templates/nuvler-default/src/header-interactions.tsx +2 -2
- package/dist/templates/nuvler-default/src/header.tsx +1 -1
- package/dist/templates/nuvler-default/src/home.tsx +13 -2
- package/dist/templates/nuvler-default/src/mini-banners.tsx +44 -0
- package/dist/templates/nuvler-default/src/product-carousel.tsx +2 -2
- package/dist/templates/nuvler-default/src/product-detail-interactive.tsx +7 -2
- package/dist/templates/nuvler-default/src/product-detail.tsx +3 -1
- package/dist/templates/nuvler-default/src/products.tsx +5 -4
- package/dist/templates/nuvler-default/src/theme-component.tsx +18 -4
- package/dist/templates/nuvler-default/src/theme.css +58 -0
- package/dist/templates/starter/package.json +1 -1
- package/dist/templates/starter/src/definition.tsx +5 -5
- package/dist/templates/starter/src/theme.tsx +2 -2
- package/package.json +2 -2
- package/preview-host/package.json +1 -1
- package/preview-host/src/fallback-context.json +1 -0
- package/preview-host/vendor/theme-runtime/default-theme.tsx +34 -5
|
@@ -1769,6 +1769,59 @@ select {
|
|
|
1769
1769
|
line-height: 1.65;
|
|
1770
1770
|
}
|
|
1771
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
|
+
|
|
1772
1825
|
.banner-copy .button {
|
|
1773
1826
|
margin-top: 28px;
|
|
1774
1827
|
}
|
|
@@ -4198,6 +4251,11 @@ select {
|
|
|
4198
4251
|
}
|
|
4199
4252
|
|
|
4200
4253
|
@media (max-width: 800px) {
|
|
4254
|
+
.mini-banners-grid,
|
|
4255
|
+
.mini-banners-grid[data-layout="3x1"] {
|
|
4256
|
+
grid-template-columns: 1fr;
|
|
4257
|
+
}
|
|
4258
|
+
|
|
4201
4259
|
.store-container {
|
|
4202
4260
|
width: min(calc(100% - 28px), var(--container-width));
|
|
4203
4261
|
}
|
|
@@ -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.
|
|
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,7 +20,7 @@
|
|
|
20
20
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@nuvler/theme-schema": "^1.
|
|
23
|
+
"@nuvler/theme-schema": "^1.4.0",
|
|
24
24
|
"@nuvler/theme-sdk": "^1.4.2",
|
|
25
25
|
"@vitejs/plugin-react": "^6.0.5",
|
|
26
26
|
"commander": "^15.0.0",
|
|
@@ -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
|
|
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
|
|
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>
|