@nuvler/cli 0.4.1 → 0.4.2

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 (30) hide show
  1. package/README.md +25 -2
  2. package/dist/commands/theme/create.js +1 -1
  3. package/dist/commands/theme/validate.js +21 -0
  4. package/dist/commands/theme/validate.js.map +1 -1
  5. package/dist/index.js +1 -1
  6. package/dist/nuvler.js +156 -4
  7. package/dist/nuvler.js.map +1 -1
  8. package/dist/templates/nuvler-atelier/package.json +1 -1
  9. package/dist/templates/nuvler-default/README.md +50 -4
  10. package/dist/templates/nuvler-default/package.json +34 -2
  11. package/dist/templates/nuvler-default/src/banner-carousel.tsx +42 -12
  12. package/dist/templates/nuvler-default/src/carousel-frame.tsx +58 -0
  13. package/dist/templates/nuvler-default/src/definition.ts +9 -59
  14. package/dist/templates/nuvler-default/src/footer.tsx +7 -2
  15. package/dist/templates/nuvler-default/src/header-interactions.tsx +1 -1
  16. package/dist/templates/nuvler-default/src/header.tsx +3 -3
  17. package/dist/templates/nuvler-default/src/home.tsx +41 -17
  18. package/dist/templates/nuvler-default/src/index.ts +1 -0
  19. package/dist/templates/nuvler-default/src/product-carousel.tsx +13 -7
  20. package/dist/templates/nuvler-default/src/product-detail-interactive.tsx +230 -0
  21. package/dist/templates/nuvler-default/src/product-detail.tsx +80 -55
  22. package/dist/templates/nuvler-default/src/products.tsx +6 -5
  23. package/dist/templates/nuvler-default/src/server-shell.tsx +88 -0
  24. package/dist/templates/nuvler-default/src/shared.tsx +25 -9
  25. package/dist/templates/nuvler-default/src/theme-config.ts +63 -0
  26. package/dist/templates/nuvler-default/src/theme.css +21 -1
  27. package/dist/templates/starter/package.json +1 -1
  28. package/dist/theme/performance.js +126 -0
  29. package/dist/theme/performance.js.map +1 -0
  30. package/package.json +1 -1
@@ -0,0 +1,230 @@
1
+ "use client";
2
+
3
+ import {
4
+ createContext,
5
+ useEffect,
6
+ useContext,
7
+ useMemo,
8
+ useRef,
9
+ useState,
10
+ type PointerEvent,
11
+ type ReactNode,
12
+ } from "react";
13
+ import type { ProductDetailProps, ThemeImage } from "@nuvler/theme-sdk";
14
+
15
+ type AddToCart = NonNullable<ProductDetailProps["onAddToCart"]>;
16
+
17
+ const ThemeInteractionContext = createContext<{ onAddToCart?: AddToCart }>({});
18
+
19
+ export function ThemeInteractionProvider({
20
+ children,
21
+ onAddToCart,
22
+ }: {
23
+ children: ReactNode;
24
+ onAddToCart?: AddToCart;
25
+ }) {
26
+ const value = useMemo(() => ({ onAddToCart }), [onAddToCart]);
27
+ return <ThemeInteractionContext.Provider value={value}>{children}</ThemeInteractionContext.Provider>;
28
+ }
29
+
30
+ interface ProductDetailInteractiveProps extends Omit<ProductDetailProps, "descriptionContent"> {
31
+ information: ReactNode;
32
+ benefits: ReactNode;
33
+ galleryImages: ReactNode;
34
+ galleryThumbnails: ReactNode;
35
+ }
36
+
37
+ export function ProductDetailInteractive({
38
+ product,
39
+ contact,
40
+ productUrl,
41
+ onAddToCart,
42
+ information,
43
+ benefits,
44
+ galleryImages,
45
+ galleryThumbnails,
46
+ }: ProductDetailInteractiveProps) {
47
+ const context = useContext(ThemeInteractionContext);
48
+ const addToCart = onAddToCart ?? context.onAddToCart;
49
+ const initialVariant = product.variants.find((item) => item.active);
50
+ const [selected, setSelected] = useState<Record<string, string>>(() => Object.fromEntries(
51
+ product.variantOptions.map((option) => [
52
+ option.name,
53
+ initialVariant?.values.find(({ name }) => name === option.name)?.value ?? option.values[0] ?? "",
54
+ ]),
55
+ ));
56
+ const [imageUrl, setImageUrl] = useState<string>();
57
+ const galleryRef = useRef<HTMLDivElement>(null);
58
+ const [zoomEnabled, setZoomEnabled] = useState(true);
59
+ const [zoom, setZoom] = useState({
60
+ visible: false,
61
+ x: 50,
62
+ y: 50,
63
+ size: 220,
64
+ backgroundX: 0,
65
+ backgroundY: 0,
66
+ backgroundWidth: 0,
67
+ backgroundHeight: 0,
68
+ });
69
+ const variant = useMemo(() => product.variants.find((item) => (
70
+ item.active && item.values.every(({ name, value }) => selected[name] === value)
71
+ )), [product.variants, selected]);
72
+ const images = useMemo(() => {
73
+ if (variant?.image?.url) return [variant.image];
74
+ const unique = new Map<string, ThemeImage>();
75
+ [product.image, ...(product.images || [])].forEach((image) => {
76
+ if (image?.url) unique.set(image.url, image);
77
+ });
78
+ return [...unique.values()];
79
+ }, [product.image, product.images, variant]);
80
+ const selectedImage = images.find((image) => image.url === imageUrl) || images[0] || product.image;
81
+ const phone = contact?.whatsapp?.replace(/\D/g, "");
82
+ const variantDescription = variant?.values.map(({ name, value }) => `${name}: ${value}`).join(", ") || "";
83
+ const message = `Olá! Gostaria de solicitar um orçamento para ${product.title}${variantDescription ? ` (${variantDescription})` : ""}${variant?.sku ? ` — ref. ${variant.sku}` : ""}.${productUrl ? ` ${productUrl}` : ""}`;
84
+ const whatsapp = phone ? `https://wa.me/${phone}?text=${encodeURIComponent(message)}` : null;
85
+ const hasVariants = product.variantOptions.length > 0;
86
+ const canPurchase = !hasVariants || Boolean(variant);
87
+
88
+ useEffect(() => {
89
+ const gallery = galleryRef.current;
90
+ if (!gallery) return;
91
+ const selectedUrl = selectedImage?.url ?? "";
92
+ const allowedUrls = new Set(images.flatMap((image) => image.url ? [image.url] : []));
93
+
94
+ gallery.querySelectorAll<HTMLElement>("[data-product-main-image]").forEach((node) => {
95
+ node.hidden = node.dataset.productMainImage !== selectedUrl;
96
+ });
97
+ gallery.querySelectorAll<HTMLButtonElement>("[data-product-thumbnail]").forEach((button) => {
98
+ const url = button.dataset.productThumbnail ?? "";
99
+ button.hidden = !allowedUrls.has(url);
100
+ button.classList.toggle("active", url === selectedUrl);
101
+ button.setAttribute("aria-pressed", String(url === selectedUrl));
102
+ });
103
+ }, [images, selectedImage?.url]);
104
+
105
+ function moveZoom(event: PointerEvent<HTMLDivElement>) {
106
+ if (event.pointerType !== "mouse" || !selectedImage?.url || !zoomEnabled || (event.target as Element).closest(".product-zoom-toggle")) {
107
+ setZoom((current) => ({ ...current, visible: false }));
108
+ return;
109
+ }
110
+ const bounds = event.currentTarget.getBoundingClientRect();
111
+ const image = event.currentTarget.querySelector<HTMLImageElement>("[data-product-main-image]:not([hidden]) img");
112
+ const naturalWidth = image?.naturalWidth || selectedImage.width || bounds.width;
113
+ const naturalHeight = image?.naturalHeight || selectedImage.height || bounds.height;
114
+ const imageAspect = naturalWidth / naturalHeight;
115
+ const containerAspect = bounds.width / bounds.height;
116
+ const renderedWidth = imageAspect > containerAspect ? bounds.width : bounds.height * imageAspect;
117
+ const renderedHeight = imageAspect > containerAspect ? bounds.width / imageAspect : bounds.height;
118
+ const left = (bounds.width - renderedWidth) / 2;
119
+ const top = (bounds.height - renderedHeight) / 2;
120
+ const pointerX = Math.max(left, Math.min(left + renderedWidth, event.clientX - bounds.left));
121
+ const pointerY = Math.max(top, Math.min(top + renderedHeight, event.clientY - bounds.top));
122
+ const size = Math.min(280, Math.max(210, bounds.width * 0.42));
123
+ const scale = 2.5;
124
+ const backgroundWidth = renderedWidth * scale;
125
+ const backgroundHeight = renderedHeight * scale;
126
+ setZoom({
127
+ visible: true,
128
+ x: pointerX / bounds.width * 100,
129
+ y: pointerY / bounds.height * 100,
130
+ size,
131
+ backgroundX: size / 2 - (pointerX - left) / renderedWidth * backgroundWidth,
132
+ backgroundY: size / 2 - (pointerY - top) / renderedHeight * backgroundHeight,
133
+ backgroundWidth,
134
+ backgroundHeight,
135
+ });
136
+ }
137
+
138
+ return (
139
+ <div className="product-detail">
140
+ <div className="product-gallery" ref={galleryRef}>
141
+ <div
142
+ className="product-main-image product-image-magnifier"
143
+ data-zoom-enabled={zoomEnabled}
144
+ onPointerEnter={moveZoom}
145
+ onPointerMove={moveZoom}
146
+ onPointerLeave={() => setZoom((current) => ({ ...current, visible: false }))}
147
+ >
148
+ {galleryImages}
149
+ {selectedImage?.url && <button
150
+ className={`product-zoom-toggle${zoomEnabled ? " active" : ""}`}
151
+ type="button"
152
+ aria-pressed={zoomEnabled}
153
+ aria-label={zoomEnabled ? "Desativar lupa" : "Ativar lupa"}
154
+ onClick={() => {
155
+ setZoomEnabled((enabled) => !enabled);
156
+ setZoom((current) => ({ ...current, visible: false }));
157
+ }}
158
+ >
159
+ <svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="10.5" cy="10.5" r="6.5" /><path d="m15.5 15.5 5 5M10.5 7.5v6M7.5 10.5h6" />{!zoomEnabled && <path className="zoom-off-line" d="M3 3l18 18" />}</svg>
160
+ <span>Lupa</span>
161
+ </button>}
162
+ {selectedImage?.url && <span
163
+ className={`product-zoom-lens${zoom.visible ? " visible" : ""}`}
164
+ aria-hidden="true"
165
+ style={{
166
+ left: `${zoom.x}%`,
167
+ top: `${zoom.y}%`,
168
+ width: zoom.size,
169
+ height: zoom.size,
170
+ backgroundImage: `url(${JSON.stringify(selectedImage.url)})`,
171
+ backgroundPosition: `${zoom.backgroundX}px ${zoom.backgroundY}px`,
172
+ backgroundSize: `${zoom.backgroundWidth}px ${zoom.backgroundHeight}px`,
173
+ }}
174
+ />}
175
+ </div>
176
+ <div
177
+ className="product-thumbnails"
178
+ onClick={(event) => {
179
+ const button = (event.target as Element).closest<HTMLButtonElement>("[data-product-thumbnail]");
180
+ if (button?.dataset.productThumbnail) setImageUrl(button.dataset.productThumbnail);
181
+ }}
182
+ >
183
+ {galleryThumbnails}
184
+ </div>
185
+ </div>
186
+ <div className="product-info">
187
+ {information}
188
+ <div className="product-purchase">
189
+ {hasVariants && <div className="variant-selector">
190
+ {product.variantOptions.map((option) => <fieldset key={option.name}>
191
+ <legend>{option.name}: <strong>{selected[option.name]}</strong></legend>
192
+ <div className="variant-values">
193
+ {option.values.map((value) => <button
194
+ key={value}
195
+ type="button"
196
+ className={selected[option.name] === value ? "active" : ""}
197
+ aria-pressed={selected[option.name] === value}
198
+ onClick={() => {
199
+ setSelected((current) => ({ ...current, [option.name]: value }));
200
+ setImageUrl(undefined);
201
+ }}
202
+ >{value}</button>)}
203
+ </div>
204
+ </fieldset>)}
205
+ {variant
206
+ ? <p className="selected-variant"><strong>{variant.name || variantDescription}</strong>{variant.sku && <span>Referência: {variant.sku}</span>}</p>
207
+ : <p className="variant-unavailable">Esta combinação não está disponível.</p>}
208
+ </div>}
209
+ {canPurchase && addToCart && <button
210
+ type="button"
211
+ className="button button-primary button-block"
212
+ onClick={() => addToCart({
213
+ productSlug: product.slug,
214
+ title: product.title,
215
+ sku: variant?.sku || product.sku,
216
+ variantId: variant?.id,
217
+ variantName: variantDescription,
218
+ image: variant?.image || product.image,
219
+ unitPrice: variant ? null : product.promotionalPrice ?? product.price,
220
+ })}
221
+ >Adicionar ao orçamento</button>}
222
+ {canPurchase && whatsapp && <a className={`button ${addToCart ? "button-secondary" : "button-primary"} button-block`} href={whatsapp} target="_blank" rel="noreferrer">Orçar somente este item</a>}
223
+ {canPurchase && !whatsapp && contact?.email && <a className="button button-primary button-block" href={`mailto:${contact.email}?subject=${encodeURIComponent(`Orçamento: ${product.title}`)}&body=${encodeURIComponent(message)}`}>Solicitar orçamento por e-mail</a>}
224
+ {canPurchase && !whatsapp && !contact?.email && contact?.phone && <a className="button button-primary button-block" href={`tel:${contact.phone}`}>Ligar e solicitar orçamento</a>}
225
+ </div>
226
+ {benefits}
227
+ </div>
228
+ </div>
229
+ );
230
+ }
@@ -1,60 +1,85 @@
1
- "use client";
2
-
3
- import { useMemo, useState, type PointerEvent } from "react";
4
1
  import type { ProductDetailProps, ThemeImage } from "@nuvler/theme-sdk";
5
- import { ThemeImageView } from "./shared.js";
6
2
 
7
- export function ProductDetail({ product, contact, productUrl, descriptionContent, onAddToCart }: ProductDetailProps) {
8
- const initialVariant = product.variants.find((item) => item.active);
9
- const [selected, setSelected] = useState<Record<string, string>>(() => Object.fromEntries(
10
- product.variantOptions.map((option) => [
11
- option.name,
12
- initialVariant?.values.find(({ name }) => name === option.name)?.value ?? option.values[0] ?? "",
13
- ]),
14
- ));
15
- const [imageUrl, setImageUrl] = useState<string>();
16
- const [zoomEnabled, setZoomEnabled] = useState(true);
17
- const [zoom, setZoom] = useState({ visible: false, x: 50, y: 50, size: 220, backgroundX: 0, backgroundY: 0, backgroundWidth: 0, backgroundHeight: 0 });
18
- const variant = useMemo(() => product.variants.find((item) => (
19
- item.active && item.values.every(({ name, value }) => selected[name] === value)
20
- )), [product.variants, selected]);
21
- const images = useMemo(() => {
22
- if (variant?.image?.url) return [variant.image];
23
- const unique = new Map<string, ThemeImage>();
24
- [product.image, ...(product.images || [])].forEach((image) => { if (image?.url) unique.set(image.url, image); });
25
- return [...unique.values()];
26
- }, [product.image, product.images, variant]);
27
- const selectedImage = images.find((image) => image.url === imageUrl) || images[0] || product.image;
28
- const phone = contact?.whatsapp?.replace(/\D/g, "");
29
- const variantDescription = variant?.values.map(({ name, value }) => `${name}: ${value}`).join(", ") || "";
30
- const message = `Olá! Gostaria de solicitar um orçamento para ${product.title}${variantDescription ? ` (${variantDescription})` : ""}${variant?.sku ? ` — ref. ${variant.sku}` : ""}.${productUrl ? ` ${productUrl}` : ""}`;
31
- const whatsapp = phone ? `https://wa.me/${phone}?text=${encodeURIComponent(message)}` : null;
32
- const hasVariants = product.variantOptions.length > 0;
33
- const canPurchase = !hasVariants || Boolean(variant);
3
+ import { ProductDetailInteractive } from "./product-detail-interactive.js";
4
+ import { ThemeImageView, type ThemeImageComponent } from "./shared.js";
34
5
 
35
- function moveZoom(event: PointerEvent<HTMLDivElement>) {
36
- if (event.pointerType !== "mouse" || !selectedImage?.url || !zoomEnabled || (event.target as Element).closest(".product-zoom-toggle")) {
37
- setZoom((current) => ({ ...current, visible: false }));
38
- return;
39
- }
40
- const bounds = event.currentTarget.getBoundingClientRect();
41
- const image = event.currentTarget.querySelector("img");
42
- const naturalWidth = image?.naturalWidth || selectedImage.width || bounds.width;
43
- const naturalHeight = image?.naturalHeight || selectedImage.height || bounds.height;
44
- const imageAspect = naturalWidth / naturalHeight;
45
- const containerAspect = bounds.width / bounds.height;
46
- const renderedWidth = imageAspect > containerAspect ? bounds.width : bounds.height * imageAspect;
47
- const renderedHeight = imageAspect > containerAspect ? bounds.width / imageAspect : bounds.height;
48
- const left = (bounds.width - renderedWidth) / 2;
49
- const top = (bounds.height - renderedHeight) / 2;
50
- const pointerX = Math.max(left, Math.min(left + renderedWidth, event.clientX - bounds.left));
51
- const pointerY = Math.max(top, Math.min(top + renderedHeight, event.clientY - bounds.top));
52
- const size = Math.min(280, Math.max(210, bounds.width * 0.42));
53
- const scale = 2.5;
54
- const backgroundWidth = renderedWidth * scale;
55
- const backgroundHeight = renderedHeight * scale;
56
- setZoom({ visible: true, x: pointerX / bounds.width * 100, y: pointerY / bounds.height * 100, size, backgroundX: size / 2 - (pointerX - left) / renderedWidth * backgroundWidth, backgroundY: size / 2 - (pointerY - top) / renderedHeight * backgroundHeight, backgroundWidth, backgroundHeight });
57
- }
6
+ export function ProductDetail({
7
+ product,
8
+ contact,
9
+ productUrl,
10
+ descriptionContent,
11
+ onAddToCart,
12
+ ImageComponent = ThemeImageView,
13
+ }: ProductDetailProps & { ImageComponent?: ThemeImageComponent }) {
14
+ const initialVariant = product.variants.find((variant) => variant.active);
15
+ const uniqueImages = new Map<string, ThemeImage>();
16
+ [
17
+ initialVariant?.image,
18
+ product.image,
19
+ ...(product.images ?? []),
20
+ ...product.variants.map((variant) => variant.image),
21
+ ].forEach((image) => {
22
+ if (image?.url) uniqueImages.set(image.url, image);
23
+ });
24
+ const images = [...uniqueImages.values()];
25
+ const galleryImages = images.length > 0
26
+ ? images.map((image, index) => (
27
+ <span
28
+ data-product-main-image={image.url}
29
+ hidden={index !== 0}
30
+ key={image.url}
31
+ >
32
+ <ImageComponent
33
+ image={image}
34
+ fallbackAlt={initialVariant?.name || product.title}
35
+ priority={index === 0}
36
+ sizes="(max-width: 900px) 100vw, 50vw"
37
+ fallbackWidth={1000}
38
+ fallbackHeight={1000}
39
+ />
40
+ </span>
41
+ ))
42
+ : <span data-product-main-image=""><ImageComponent image={null} fallbackAlt={product.title} /></span>;
43
+ const galleryThumbnails = images.length > 1
44
+ ? images.map((image, index) => (
45
+ <button
46
+ className={index === 0 ? "active" : ""}
47
+ type="button"
48
+ aria-pressed={index === 0}
49
+ aria-label={`Exibir imagem ${index + 1} de ${product.title}`}
50
+ data-product-thumbnail={image.url}
51
+ key={`${image.url}-${index}`}
52
+ >
53
+ <ImageComponent
54
+ image={image}
55
+ fallbackAlt={`${product.title} ${index + 1}`}
56
+ sizes="96px"
57
+ fallbackWidth={192}
58
+ fallbackHeight={192}
59
+ />
60
+ </button>
61
+ ))
62
+ : null;
63
+ const information = <>
64
+ {product.categories[0] && <span className="product-category">{product.categories[0].name}</span>}
65
+ <h1>{product.title}</h1>
66
+ <div className="product-description">{descriptionContent}</div>
67
+ </>;
68
+ const benefits = <div className="purchase-benefits">
69
+ <span><strong>Atendimento direto</strong> Fale com quem entende do produto</span>
70
+ <span><strong>Orçamento personalizado</strong> Condições para a sua necessidade</span>
71
+ </div>;
58
72
 
59
- return <div className="product-detail"><div className="product-gallery"><div className="product-main-image product-image-magnifier" data-zoom-enabled={zoomEnabled} onPointerEnter={moveZoom} onPointerMove={moveZoom} onPointerLeave={() => setZoom((current) => ({ ...current, visible: false }))}><ThemeImageView image={selectedImage} fallbackAlt={variant?.name || product.title} priority />{selectedImage?.url && <button className={`product-zoom-toggle${zoomEnabled ? " active" : ""}`} type="button" aria-pressed={zoomEnabled} aria-label={zoomEnabled ? "Desativar lupa" : "Ativar lupa"} onClick={() => { setZoomEnabled((enabled) => !enabled); setZoom((current) => ({ ...current, visible: false })); }}><svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="10.5" cy="10.5" r="6.5" /><path d="m15.5 15.5 5 5M10.5 7.5v6M7.5 10.5h6" />{!zoomEnabled && <path className="zoom-off-line" d="M3 3l18 18" />}</svg><span>Lupa</span></button>}{selectedImage?.url && <span className={`product-zoom-lens${zoom.visible ? " visible" : ""}`} aria-hidden="true" style={{ left: `${zoom.x}%`, top: `${zoom.y}%`, width: zoom.size, height: zoom.size, backgroundImage: `url(${JSON.stringify(selectedImage.url)})`, backgroundPosition: `${zoom.backgroundX}px ${zoom.backgroundY}px`, backgroundSize: `${zoom.backgroundWidth}px ${zoom.backgroundHeight}px` }} />}</div>{images.length > 1 && <div className="product-thumbnails">{images.map((image, index) => <button className={selectedImage?.url === image.url ? "active" : ""} type="button" aria-pressed={selectedImage?.url === image.url} aria-label={`Exibir imagem ${index + 1} de ${product.title}`} onClick={() => setImageUrl(image.url || undefined)} key={`${image.url}-${index}`}><ThemeImageView image={image} fallbackAlt={`${product.title} ${index + 1}`} /></button>)}</div>}</div><div className="product-info">{product.categories[0] && <span className="product-category">{product.categories[0].name}</span>}<h1>{product.title}</h1><div className="product-description">{descriptionContent}</div><div className="product-purchase">{hasVariants && <div className="variant-selector">{product.variantOptions.map((option) => <fieldset key={option.name}><legend>{option.name}: <strong>{selected[option.name]}</strong></legend><div className="variant-values">{option.values.map((value) => <button key={value} type="button" className={selected[option.name] === value ? "active" : ""} aria-pressed={selected[option.name] === value} onClick={() => { setSelected((current) => ({ ...current, [option.name]: value })); setImageUrl(undefined); }}>{value}</button>)}</div></fieldset>)}{variant ? <p className="selected-variant"><strong>{variant.name || variantDescription}</strong>{variant.sku && <span>Referência: {variant.sku}</span>}</p> : <p className="variant-unavailable">Esta combinação não está disponível.</p>}</div>}{canPurchase && onAddToCart && <button type="button" className="button button-primary button-block" onClick={() => onAddToCart({ productSlug: product.slug, title: product.title, sku: variant?.sku || product.sku, variantId: variant?.id, variantName: variantDescription, image: variant?.image || product.image, unitPrice: variant ? null : product.promotionalPrice ?? product.price })}>Adicionar ao orçamento</button>}{canPurchase && whatsapp && <a className={`button ${onAddToCart ? "button-secondary" : "button-primary"} button-block`} href={whatsapp} target="_blank" rel="noreferrer">Orçar somente este item</a>}{canPurchase && !whatsapp && contact?.email && <a className="button button-primary button-block" href={`mailto:${contact.email}?subject=${encodeURIComponent(`Orçamento: ${product.title}`)}&body=${encodeURIComponent(message)}`}>Solicitar orçamento por e-mail</a>}{canPurchase && !whatsapp && !contact?.email && contact?.phone && <a className="button button-primary button-block" href={`tel:${contact.phone}`}>Ligar e solicitar orçamento</a>}</div><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></div></div>;
73
+ return (
74
+ <ProductDetailInteractive
75
+ product={product}
76
+ contact={contact}
77
+ productUrl={productUrl}
78
+ onAddToCart={onAddToCart}
79
+ information={information}
80
+ benefits={benefits}
81
+ galleryImages={galleryImages}
82
+ galleryThumbnails={galleryThumbnails}
83
+ />
84
+ );
60
85
  }
@@ -1,15 +1,16 @@
1
1
  import type { ProductGridProps, ThemeProduct } from "@nuvler/theme-sdk";
2
- import { plainText, ThemeImageView } from "./shared.js";
2
+ import { plainText, ThemeImageView, type ThemeImageComponent } from "./shared.js";
3
3
 
4
- export function ProductCard({ product, showCategory = true, showDescription = true }: {
4
+ export function ProductCard({ product, showCategory = true, showDescription = true, ImageComponent = ThemeImageView }: {
5
5
  product: ThemeProduct;
6
6
  showCategory?: boolean;
7
7
  showDescription?: boolean;
8
+ ImageComponent?: ThemeImageComponent;
8
9
  }) {
9
- return <article className="product-card"><a className="product-card-image" href={`/produto/${product.slug}`}><ThemeImageView image={product.image} fallbackAlt={product.title} /></a><div className="product-card-content">{showCategory && <span className={`product-category${product.categories[0] ? "" : " product-category-empty"}`}>{product.categories[0]?.name || "Sem categoria"}</span>}<h3><a href={`/produto/${product.slug}`}>{product.title}</a></h3>{showDescription && product.description && <p className="product-card-description">{plainText(product.description)}</p>}<a className="button button-secondary button-block" href={`/produto/${product.slug}`}>Ver detalhes e orçar</a></div></article>;
10
+ return <article className="product-card"><a className="product-card-image" href={`/produto/${product.slug}`}><ImageComponent image={product.image} fallbackAlt={product.title} sizes="(max-width: 720px) 92vw, (max-width: 1100px) 45vw, 25vw" fallbackWidth={720} fallbackHeight={720} /></a><div className="product-card-content">{showCategory && <span className={`product-category${product.categories[0] ? "" : " product-category-empty"}`}>{product.categories[0]?.name || "Sem categoria"}</span>}<h3><a href={`/produto/${product.slug}`}>{product.title}</a></h3>{showDescription && product.description && <p className="product-card-description">{plainText(product.description)}</p>}<a className="button button-secondary button-block" href={`/produto/${product.slug}`}>Ver detalhes e orçar</a></div></article>;
10
11
  }
11
12
 
12
- export function ProductGrid({ products, columns = 4, showCategory = true, showDescription = true }: ProductGridProps) {
13
+ export function ProductGrid({ products, columns = 4, showCategory = true, showDescription = true, ImageComponent = ThemeImageView }: ProductGridProps & { ImageComponent?: ThemeImageComponent }) {
13
14
  if (!products.length) return <div className="empty-state"><span>7</span><h2>Nenhum produto encontrado</h2><p>Novos itens aparecerão aqui assim que forem publicados.</p></div>;
14
- return <div className="product-grid" data-columns={columns}>{products.map((product) => <ProductCard key={product.slug} product={product} showCategory={showCategory} showDescription={showDescription} />)}</div>;
15
+ return <div className="product-grid" data-columns={columns}>{products.map((product) => <ProductCard key={product.slug} product={product} showCategory={showCategory} showDescription={showDescription} ImageComponent={ImageComponent} />)}</div>;
15
16
  }
@@ -0,0 +1,88 @@
1
+ import type { CSSProperties, ReactNode } from "react";
2
+ import type { ThemeCategory, ThemePageSummary, ThemeSite } from "@nuvler/theme-sdk";
3
+
4
+ import { Footer } from "./footer.js";
5
+ import { Header } from "./header.js";
6
+ import {
7
+ manifest,
8
+ nuvlerDefaultTemplate,
9
+ nuvlerDefaultTokens,
10
+ } from "./theme-config.js";
11
+ import type { ThemeImageComponent } from "./shared.js";
12
+
13
+ export interface NuvlerDefaultShellProps {
14
+ site: ThemeSite;
15
+ categories: ThemeCategory[];
16
+ pages: ThemePageSummary[];
17
+ children: ReactNode;
18
+ cart?: ReactNode;
19
+ platformBrand?: ReactNode;
20
+ suggestionsEndpoint?: string;
21
+ suggestionsQueryParam?: string;
22
+ ImageComponent?: ThemeImageComponent;
23
+ }
24
+
25
+ export function NuvlerDefaultShell({
26
+ site,
27
+ categories,
28
+ pages,
29
+ children,
30
+ cart,
31
+ platformBrand,
32
+ suggestionsEndpoint,
33
+ suggestionsQueryParam,
34
+ ImageComponent,
35
+ }: NuvlerDefaultShellProps) {
36
+ const configured = site.settings?.theme;
37
+ const tokens = {
38
+ colors: { ...nuvlerDefaultTokens.colors, ...configured?.colors },
39
+ layout: { ...nuvlerDefaultTokens.layout, ...configured?.layout },
40
+ };
41
+ const style = {
42
+ "--color-primary": tokens.colors.primary,
43
+ "--color-primary-text": tokens.colors.primaryText,
44
+ "--color-secondary": tokens.colors.secondary,
45
+ "--color-secondary-text": tokens.colors.secondaryText,
46
+ "--color-accent": tokens.colors.accent,
47
+ "--store-background": tokens.colors.background,
48
+ "--store-surface": tokens.colors.surface,
49
+ "--store-surface-alt": tokens.colors.surfaceAlt,
50
+ "--store-text": tokens.colors.text,
51
+ "--store-muted": tokens.colors.textMuted,
52
+ "--store-line": tokens.colors.border,
53
+ "--store-header-background": tokens.colors.headerBackground,
54
+ "--store-header-text": tokens.colors.headerText,
55
+ "--store-footer-background": tokens.colors.footerBackground,
56
+ "--store-footer-text": tokens.colors.footerText,
57
+ "--container-width": `${tokens.layout.containerWidth}px`,
58
+ "--border-radius": `${tokens.layout.borderRadius}px`,
59
+ } as CSSProperties;
60
+
61
+ return (
62
+ <div
63
+ className="store-shell nuvler-default-theme"
64
+ data-theme-id={manifest.id}
65
+ data-theme-version={manifest.version}
66
+ data-nuvler-renderer="server"
67
+ style={style}
68
+ >
69
+ <Header
70
+ site={site}
71
+ categories={categories}
72
+ pages={pages}
73
+ template={nuvlerDefaultTemplate}
74
+ cart={cart}
75
+ suggestionsEndpoint={suggestionsEndpoint}
76
+ suggestionsQueryParam={suggestionsQueryParam}
77
+ ImageComponent={ImageComponent}
78
+ />
79
+ <div className="store-page">{children}</div>
80
+ <Footer
81
+ site={site}
82
+ pages={pages}
83
+ template={nuvlerDefaultTemplate}
84
+ platformBrand={platformBrand}
85
+ />
86
+ </div>
87
+ );
88
+ }
@@ -1,26 +1,42 @@
1
+ import type { ComponentType } from "react";
1
2
  import type { ThemeImage, ThemeProduct } from "@nuvler/theme-sdk";
2
3
 
4
+ export interface ThemeImageViewProps {
5
+ image: ThemeImage | null | undefined;
6
+ fallbackAlt: string;
7
+ className?: string;
8
+ priority?: boolean;
9
+ loading?: "eager" | "lazy";
10
+ sizes?: string;
11
+ fallbackWidth?: number;
12
+ fallbackHeight?: number;
13
+ }
14
+
15
+ export type ThemeImageComponent = ComponentType<ThemeImageViewProps>;
16
+
3
17
  export function ThemeImageView({
4
18
  image,
5
19
  fallbackAlt,
6
20
  className,
7
21
  priority = false,
8
- }: {
9
- image: ThemeImage | null | undefined;
10
- fallbackAlt: string;
11
- className?: string;
12
- priority?: boolean;
13
- }) {
22
+ loading = "lazy",
23
+ sizes,
24
+ fallbackWidth = 900,
25
+ fallbackHeight = 900,
26
+ }: ThemeImageViewProps) {
14
27
  if (!image?.url) {
15
28
  return <span className={`store-image-placeholder ${className ?? ""}`} aria-hidden="true"><span>7</span></span>;
16
29
  }
17
30
  return <img
18
31
  src={image.url}
19
32
  alt={image.alt || fallbackAlt}
20
- width={image.width || 900}
21
- height={image.height || 900}
33
+ width={image.width || fallbackWidth}
34
+ height={image.height || fallbackHeight}
22
35
  className={className}
23
- loading={priority ? "eager" : "lazy"}
36
+ loading={priority ? "eager" : loading}
37
+ fetchPriority={priority ? "high" : "auto"}
38
+ decoding="async"
39
+ sizes={sizes}
24
40
  />;
25
41
  }
26
42
 
@@ -0,0 +1,63 @@
1
+ import manifestData from "../nuvler.theme.json" with { type: "json" };
2
+ import type {
3
+ SiteTemplate,
4
+ ThemeHomeSection,
5
+ ThemeManifest,
6
+ NuvlerStoreThemeDefinition,
7
+ } from "@nuvler/theme-sdk";
8
+
9
+ function section(id: string, type: ThemeHomeSection["type"], order: number): ThemeHomeSection {
10
+ return { id, type, enabled: true, order, data: {} };
11
+ }
12
+
13
+ export const manifest = manifestData as ThemeManifest;
14
+
15
+ export const nuvlerDefaultTokens = {
16
+ colors: {
17
+ primary: "#176b3a",
18
+ primaryText: "#ffffff",
19
+ secondary: "#d99b31",
20
+ secondaryText: "#18221b",
21
+ accent: "#b45309",
22
+ background: "#f7f7f2",
23
+ surface: "#ffffff",
24
+ surfaceAlt: "#eef2e9",
25
+ text: "#18221b",
26
+ textMuted: "#657068",
27
+ border: "#dfe4dd",
28
+ headerBackground: "#ffffff",
29
+ headerText: "#18221b",
30
+ footerBackground: "#14251a",
31
+ footerText: "#f7f7f2",
32
+ },
33
+ layout: { containerWidth: 1280, borderRadius: 18 },
34
+ } satisfies NuvlerStoreThemeDefinition["tokens"];
35
+
36
+ export const nuvlerDefaultTemplate = {
37
+ announcement: "Soluções, conteúdo e atendimento para o seu negócio",
38
+ footerTagline: "Soluções, conteúdo e atendimento próximo para aproximar sua marca das pessoas.",
39
+ footerNavigationLabel: "Navegação",
40
+ footerNote: "Conteúdo e atendimento que geram confiança",
41
+ socialLabel: "Acompanhe a empresa",
42
+ benefits: [
43
+ { title: "Soluções sob medida", description: "Serviços pensados para o seu momento" },
44
+ { title: "Conteúdo relevante", description: "Informação para ajudar nas decisões" },
45
+ { title: "Atendimento próximo", description: "Fale diretamente com a empresa" },
46
+ ],
47
+ fallbackSections(modules) {
48
+ const sections = [section("default-hero", "hero", 0)];
49
+ let order = 1;
50
+ if (modules.includes("SERVICES")) sections.push(section("default-services", "services-grid", order++));
51
+ if (modules.includes("CASES")) sections.push(section("default-cases", "cases-grid", order++));
52
+ if (modules.includes("PRODUCTS")) sections.push(section("default-products", "products-carousel", order++));
53
+ if (modules.includes("BLOG")) sections.push(section("default-blog", "blog-grid", order));
54
+ return sections;
55
+ },
56
+ primaryAction(modules) {
57
+ if (modules.includes("SERVICES")) return { label: "Conheça nossos serviços", href: "/servicos" };
58
+ if (modules.includes("PRODUCTS")) return { label: "Ver produtos", href: "/produtos" };
59
+ if (modules.includes("CASES")) return { label: "Conheça nossos cases", href: "/cases" };
60
+ if (modules.includes("BLOG")) return { label: "Ver conteúdos", href: "/blog" };
61
+ return { label: "Conheça a empresa", href: "/" };
62
+ },
63
+ } satisfies SiteTemplate;
@@ -44,7 +44,6 @@ body {
44
44
  margin: 0;
45
45
  background: var(--store-background);
46
46
  color: var(--store-text);
47
- font-family: Arial, Helvetica, sans-serif;
48
47
  -webkit-font-smoothing: antialiased;
49
48
  }
50
49
 
@@ -52,6 +51,17 @@ body {
52
51
  min-height: 100vh;
53
52
  background: var(--store-background);
54
53
  color: var(--store-text);
54
+ font-family: var(
55
+ --nuvler-font-sans,
56
+ ui-sans-serif,
57
+ system-ui,
58
+ -apple-system,
59
+ BlinkMacSystemFont,
60
+ "Segoe UI",
61
+ Arial,
62
+ Helvetica,
63
+ sans-serif
64
+ );
55
65
  }
56
66
 
57
67
  .floating-whatsapp {
@@ -2221,6 +2231,16 @@ select {
2221
2231
  object-fit: contain;
2222
2232
  }
2223
2233
 
2234
+ .product-main-image > [data-product-main-image] {
2235
+ display: block;
2236
+ width: 100%;
2237
+ height: 100%;
2238
+ }
2239
+
2240
+ .product-main-image > [data-product-main-image][hidden] {
2241
+ display: none;
2242
+ }
2243
+
2224
2244
  .product-thumbnails {
2225
2245
  display: grid;
2226
2246
  grid-template-columns: repeat(5, 1fr);
@@ -18,7 +18,7 @@
18
18
  "react": "^19.0.0"
19
19
  },
20
20
  "devDependencies": {
21
- "@nuvler/cli": "^0.4.1",
21
+ "@nuvler/cli": "^0.4.2",
22
22
  "@types/react": "^19.0.0",
23
23
  "react": "^19.0.0",
24
24
  "typescript": "^5.9.0"