@nuvler/cli 0.5.9 → 0.5.11
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/create.js +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 +118 -16
- package/dist/nuvler.js.map +1 -1
- package/dist/templates/nuvler-atelier/nuvler.theme.json +1 -1
- package/dist/templates/nuvler-atelier/package.json +3 -3
- package/dist/templates/nuvler-atelier/src/definition.tsx +16 -8
- package/dist/templates/nuvler-atelier/src/theme.css +3 -0
- 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 +22 -4
- package/dist/templates/nuvler-default/package.json +6 -5
- package/dist/templates/nuvler-default/scripts/verify-release.mjs +34 -0
- package/dist/templates/nuvler-default/src/carousel-frame.tsx +125 -20
- 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 +700 -76
- package/dist/templates/nuvler-default/src/mini-banners.tsx +45 -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 +6 -5
- package/dist/templates/nuvler-default/src/shared.tsx +9 -1
- package/dist/templates/nuvler-default/src/theme-component.tsx +18 -4
- package/dist/templates/nuvler-default/src/theme.css +201 -7
- package/dist/templates/starter/package.json +2 -2
- package/dist/templates/starter/src/definition.tsx +5 -5
- package/dist/templates/starter/src/theme.tsx +2 -2
- package/package.json +3 -3
- 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 +42 -6
|
@@ -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,
|
|
@@ -114,13 +116,20 @@ function CategoryTree({
|
|
|
114
116
|
}
|
|
115
117
|
|
|
116
118
|
function displayPrice(product: ThemeProduct): string | null {
|
|
117
|
-
const price = product.promotionalPrice
|
|
119
|
+
const price = typeof product.promotionalPrice === "number" && typeof product.price === "number" && product.promotionalPrice < product.price
|
|
120
|
+
? product.promotionalPrice
|
|
121
|
+
: product.price;
|
|
118
122
|
return typeof price === "number"
|
|
119
123
|
? new Intl.NumberFormat("pt-BR", { style: "currency", currency: "BRL" }).format(price)
|
|
120
124
|
: null;
|
|
121
125
|
}
|
|
122
126
|
|
|
123
|
-
function
|
|
127
|
+
function originalPrice(product: ThemeProduct): string | null {
|
|
128
|
+
if (typeof product.price !== "number" || typeof product.promotionalPrice !== "number" || product.promotionalPrice >= product.price) return null;
|
|
129
|
+
return new Intl.NumberFormat("pt-BR", { style: "currency", currency: "BRL" }).format(product.price);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function SmartSearch({ adapters, showPrices }: { adapters: ThemeRuntimeAdapters; showPrices: boolean }) {
|
|
124
133
|
const { Link, Image } = adapters;
|
|
125
134
|
const [value, setValue] = useState("");
|
|
126
135
|
const [results, setResults] = useState<ThemeProduct[]>([]);
|
|
@@ -159,7 +168,7 @@ function SmartSearch({ adapters }: { adapters: ThemeRuntimeAdapters }) {
|
|
|
159
168
|
{!loading && results.map((product) => <Link href={productUrl(product)} key={product.slug}>
|
|
160
169
|
<span className="search-suggestion-image"><Image image={product.image} fallbackAlt={product.title} /></span>
|
|
161
170
|
<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>}
|
|
171
|
+
{showPrices && displayPrice(product) && <b>{displayPrice(product)}</b>}
|
|
163
172
|
</Link>)}
|
|
164
173
|
{!loading && !results.length && <p>Nenhum produto próximo foi encontrado.</p>}
|
|
165
174
|
<Link className="search-all-results" href={`/produtos?busca=${encodeURIComponent(value.trim())}`}>Ver todos os resultados</Link>
|
|
@@ -194,7 +203,7 @@ function Header({ context, adapters }: Omit<DefaultThemeProps, "children">) {
|
|
|
194
203
|
)}
|
|
195
204
|
</Link>
|
|
196
205
|
{context.site.modules.includes("PRODUCTS") && (
|
|
197
|
-
<SmartSearch adapters={adapters} />
|
|
206
|
+
<SmartSearch adapters={adapters} showPrices={settings?.catalog?.showPrices ?? true} />
|
|
198
207
|
)}
|
|
199
208
|
<div className="header-message">
|
|
200
209
|
<span className="header-message-icon" aria-hidden="true">
|
|
@@ -301,6 +310,7 @@ function ProductCard({ product, context, adapters }: {
|
|
|
301
310
|
{catalog.showDescription && product.description && (
|
|
302
311
|
<p className="product-card-description">{plainText(product.description)}</p>
|
|
303
312
|
)}
|
|
313
|
+
{catalog.showPrices && displayPrice(product) && <div className="product-card-price">{originalPrice(product) && <s>De: {originalPrice(product)}</s>}<b>{originalPrice(product) ? "por " : ""}{displayPrice(product)}</b></div>}
|
|
304
314
|
<Link className="button button-secondary button-block" href={href}>
|
|
305
315
|
Ver detalhes e orçar
|
|
306
316
|
</Link>
|
|
@@ -377,6 +387,29 @@ function BannerSection({ section, adapters }: ThemeSectionRendererProps) {
|
|
|
377
387
|
);
|
|
378
388
|
}
|
|
379
389
|
|
|
390
|
+
function MiniBannersSection({ section, adapters }: ThemeSectionRendererProps) {
|
|
391
|
+
const { Image, Link } = adapters;
|
|
392
|
+
const data = section.data as ThemeMiniBannersData;
|
|
393
|
+
const items = Array.isArray(data.items)
|
|
394
|
+
? data.items.filter((item) => Boolean(item.image?.url || item.imageUrl))
|
|
395
|
+
: [];
|
|
396
|
+
if (!items.length) return null;
|
|
397
|
+
return (
|
|
398
|
+
<section className="store-section mini-banners-section">
|
|
399
|
+
<div className="store-container mini-banners-grid" data-layout={data.layout}>
|
|
400
|
+
{items.map((item, index) => {
|
|
401
|
+
const image = item.image || (item.imageUrl ? { url: item.imageUrl, alt: item.imageAlt || item.title || "Mini banner", width: null, height: null } : null);
|
|
402
|
+
if (!image) return null;
|
|
403
|
+
const content = <><span className="mini-banner-image"><Image image={image} fallbackAlt={item.title || "Mini banner"} /></span>{item.title && <strong>{item.title}</strong>}</>;
|
|
404
|
+
return item.link
|
|
405
|
+
? <Link className="mini-banner-card" href={item.link} key={`${image.url}-${index}`}>{content}</Link>
|
|
406
|
+
: <div className="mini-banner-card" key={`${image.url}-${index}`}>{content}</div>;
|
|
407
|
+
})}
|
|
408
|
+
</div>
|
|
409
|
+
</section>
|
|
410
|
+
);
|
|
411
|
+
}
|
|
412
|
+
|
|
380
413
|
function TextSection({ section, adapters }: ThemeSectionRendererProps) {
|
|
381
414
|
const { Link, Image } = adapters;
|
|
382
415
|
const title = dataString(section.data, "title", "Conteúdo");
|
|
@@ -717,6 +750,7 @@ function AutomaticSection({ section, context, adapters }: ThemeSectionRendererPr
|
|
|
717
750
|
export const defaultSectionRegistry: ThemeSectionRegistry = {
|
|
718
751
|
hero: HeroSection,
|
|
719
752
|
"banner-carousel": BannerSection,
|
|
753
|
+
"mini-banners": MiniBannersSection,
|
|
720
754
|
"image-text": TextSection,
|
|
721
755
|
"rich-text": TextSection,
|
|
722
756
|
cta: TextSection,
|
|
@@ -809,14 +843,16 @@ function ProductPage({ product, context, adapters }: {
|
|
|
809
843
|
}, [product.image, product.images, selectedVariant]);
|
|
810
844
|
const [selectedImageUrl, setSelectedImageUrl] = useState<string | null>(null);
|
|
811
845
|
const selectedImage = images.find((image) => image.url === selectedImageUrl) || images[0] || product.image;
|
|
846
|
+
const showPrices = context.site.settings?.catalog?.showPrices ?? true;
|
|
812
847
|
const whatsapp = context.site.settings?.contact.whatsapp?.replace(/\D/g, "");
|
|
813
|
-
const
|
|
848
|
+
const priceText = showPrices && displayPrice(product) ? ` Valor: ${displayPrice(product)}.` : "";
|
|
849
|
+
const quoteUrl = whatsapp ? `https://wa.me/${whatsapp}?text=${encodeURIComponent(`Olá! Gostaria de solicitar um orçamento para ${product.title}.${priceText}`)}` : null;
|
|
814
850
|
|
|
815
851
|
return <main className="product-page"><div className="store-container">
|
|
816
852
|
<nav className="breadcrumbs"><Link href="/">Início</Link><span>/</span><Link href="/produtos">Produtos</Link><span>/</span><strong>{product.title}</strong></nav>
|
|
817
853
|
<div className="product-detail">
|
|
818
854
|
<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
|
|
855
|
+
<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
856
|
{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
857
|
<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
858
|
<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>
|