@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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuvler-theme-nuvler-atelier",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -13,13 +13,13 @@
|
|
|
13
13
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@nuvler/theme-sdk": "^1.
|
|
16
|
+
"@nuvler/theme-sdk": "^1.4.3"
|
|
17
17
|
},
|
|
18
18
|
"peerDependencies": {
|
|
19
19
|
"react": "^19.0.0"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
|
-
"@nuvler/cli": "^0.5.
|
|
22
|
+
"@nuvler/cli": "^0.5.11",
|
|
23
23
|
"@types/react": "^19.0.0",
|
|
24
24
|
"react": "^19.0.0",
|
|
25
25
|
"typescript": "^5.9.0"
|
|
@@ -29,12 +29,19 @@ function value(data: Record<string, unknown> | undefined, key: string): string {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
function price(product: ThemeProduct): string | null {
|
|
32
|
-
const amount = product.promotionalPrice
|
|
32
|
+
const amount = typeof product.promotionalPrice === "number" && typeof product.price === "number" && product.promotionalPrice < product.price
|
|
33
|
+
? product.promotionalPrice
|
|
34
|
+
: product.price;
|
|
33
35
|
return typeof amount === "number"
|
|
34
36
|
? new Intl.NumberFormat("pt-BR", { style: "currency", currency: "BRL" }).format(amount)
|
|
35
37
|
: null;
|
|
36
38
|
}
|
|
37
39
|
|
|
40
|
+
function originalPrice(product: ThemeProduct): string | null {
|
|
41
|
+
if (typeof product.price !== "number" || typeof product.promotionalPrice !== "number" || product.promotionalPrice >= product.price) return null;
|
|
42
|
+
return new Intl.NumberFormat("pt-BR", { style: "currency", currency: "BRL" }).format(product.price);
|
|
43
|
+
}
|
|
44
|
+
|
|
38
45
|
export function AtelierImage({ image, alt, className }: { image?: ThemeImage | null; alt: string; className?: string }) {
|
|
39
46
|
if (!image?.url) return <span className={`atelier-image-placeholder ${className ?? ""}`} aria-hidden="true"><b>N</b></span>;
|
|
40
47
|
return <img src={image.url} alt={image.alt || alt} width={image.width || 1000} height={image.height || 1000} className={className} loading="lazy" />;
|
|
@@ -156,14 +163,14 @@ function Footer({ site, pages }: FooterProps) {
|
|
|
156
163
|
</footer>;
|
|
157
164
|
}
|
|
158
165
|
|
|
159
|
-
function ProductGrid({ products, columns = 3, showCategory = true, showDescription = true }: ProductGridProps) {
|
|
166
|
+
function ProductGrid({ products, columns = 3, showPrices = true, showCategory = true, showDescription = true }: ProductGridProps) {
|
|
160
167
|
return <div className="atelier-products" data-columns={columns}>{products.map((product, index) => <article className="atelier-product-card" key={product.slug}>
|
|
161
168
|
<a className="atelier-product-media" href={productUrl(product)}><span className="atelier-product-index">{String(index + 1).padStart(2, "0")}</span><AtelierImage image={product.image} alt={product.title} /></a>
|
|
162
169
|
<div className="atelier-product-copy">
|
|
163
170
|
{showCategory && <small>{product.categories[0]?.name || product.brand || "Seleção"}</small>}
|
|
164
171
|
<h3><a href={productUrl(product)}>{product.title}</a></h3>
|
|
165
172
|
{showDescription && product.description && <p>{plainText(product.description)}</p>}
|
|
166
|
-
<div
|
|
173
|
+
<div>{showPrices && <span className="atelier-product-price">{originalPrice(product) && <s>De: {originalPrice(product)}</s>}<b>{originalPrice(product) ? "por " : ""}{price(product) || "Preço sob consulta"}</b></span>}{!showPrices && product.sku && <span>Ref. {product.sku}</span>}<a href={productUrl(product)} aria-label={`Ver ${product.title}`}>↗</a></div>
|
|
167
174
|
</div>
|
|
168
175
|
</article>)}</div>;
|
|
169
176
|
}
|
|
@@ -175,6 +182,7 @@ function Home({ sections, products, posts, services, cases, site, template }: Ho
|
|
|
175
182
|
const heroButton = value(hero?.data, "buttonLabel") || template.primaryAction(site.modules).label;
|
|
176
183
|
const heroUrl = value(hero?.data, "buttonUrl") || template.primaryAction(site.modules).href;
|
|
177
184
|
const highlight = products[0];
|
|
185
|
+
const showPrices = site.settings?.catalog?.showPrices ?? true;
|
|
178
186
|
const editorial = [...posts, ...cases].slice(0, 3);
|
|
179
187
|
const bannerSections = sections.filter((section) => section.enabled && section.type === "banner-carousel");
|
|
180
188
|
return <main>
|
|
@@ -183,14 +191,14 @@ function Home({ sections, products, posts, services, cases, site, template }: Ho
|
|
|
183
191
|
<div className="atelier-hero-visual">
|
|
184
192
|
<span className="atelier-orbit" /><span className="atelier-orbit second" />
|
|
185
193
|
<AtelierImage image={highlight?.image} alt={highlight?.title || heroTitle} />
|
|
186
|
-
{highlight && <a href={productUrl(highlight)}><small>Destaque da semana</small><strong>{highlight.title}</strong><span>{price(highlight) || "Conheça o produto"} →</span></a>}
|
|
194
|
+
{highlight && <a href={productUrl(highlight)}><small>Destaque da semana</small><strong>{highlight.title}</strong><span>{showPrices ? price(highlight) || "Conheça o produto" : "Conheça o produto"} →</span></a>}
|
|
187
195
|
</div>
|
|
188
196
|
</section>
|
|
189
197
|
{bannerSections.map((section, index) => <AtelierBannerCarousel section={section} key={section.id || index} />)}
|
|
190
198
|
<section className="atelier-marquee"><div>{template.benefits.concat(template.benefits).map((benefit, index) => <span key={`${benefit.title}-${index}`}><b>✦</b>{benefit.title}<small>{benefit.description}</small></span>)}</div></section>
|
|
191
199
|
<section className="atelier-section atelier-container">
|
|
192
200
|
<header className="atelier-section-heading"><div><span className="atelier-kicker">Seleção essencial</span><h2>Produtos que merecem atenção</h2></div><p>Uma vitrine com mais respiro, imagens protagonistas e as informações certas para decidir.</p><a href="/produtos">Explorar tudo ↗</a></header>
|
|
193
|
-
<ProductGrid products={products.slice(0, 6)} columns={3} showCategory={site.settings?.catalog?.showCategory} showDescription={site.settings?.catalog?.showDescription} />
|
|
201
|
+
<ProductGrid products={products.slice(0, 6)} columns={3} showPrices={showPrices} showCategory={site.settings?.catalog?.showCategory} showDescription={site.settings?.catalog?.showDescription} />
|
|
194
202
|
</section>
|
|
195
203
|
{services.length > 0 && <section className="atelier-services"><div className="atelier-container"><header><span className="atelier-kicker">Além do catálogo</span><h2>Soluções que acompanham sua escolha.</h2></header><div>{services.slice(0, 4).map((service, index) => <a href={`/servicos/${service.slug}`} key={service.slug}><small>{String(index + 1).padStart(2, "0")}</small><h3>{service.title}</h3><p>{service.description}</p><span>Conhecer solução ↗</span></a>)}</div></div></section>}
|
|
196
204
|
{editorial.length > 0 && <section className="atelier-section atelier-container"><header className="atelier-section-heading"><div><span className="atelier-kicker">Caderno Nuvler</span><h2>Conteúdo para escolher melhor</h2></div><a href="/blog">Ver publicações ↗</a></header><div className="atelier-editorial-grid">{editorial.map((item, index) => <a href={`${posts.includes(item) ? "/blog" : "/cases"}/${item.slug}`} key={item.slug}><AtelierImage image={item.image || item.thumbnail || item.coverImage} alt={item.title} /><small>Leitura {String(index + 1).padStart(2, "0")}</small><h3>{item.title}</h3><p>{item.description}</p><span>Ler agora ↗</span></a>)}</div></section>}
|
|
@@ -198,7 +206,7 @@ function Home({ sections, products, posts, services, cases, site, template }: Ho
|
|
|
198
206
|
</main>;
|
|
199
207
|
}
|
|
200
208
|
|
|
201
|
-
function ProductDetail({ product, descriptionContent, onAddToCart }: ProductDetailProps) {
|
|
209
|
+
function ProductDetail({ product, showPrices = true, descriptionContent, onAddToCart }: ProductDetailProps) {
|
|
202
210
|
const initial = useMemo(() => Object.fromEntries(product.variantOptions.map((option) => [option.name, option.values[0] || ""])), [product.variantOptions]);
|
|
203
211
|
const [selected, setSelected] = useState<Record<string, string>>(initial);
|
|
204
212
|
const variant = product.variants.find((candidate) => candidate.active && candidate.values.every(({ name, value: optionValue }) => selected[name] === optionValue));
|
|
@@ -208,9 +216,9 @@ function ProductDetail({ product, descriptionContent, onAddToCart }: ProductDeta
|
|
|
208
216
|
const selectedImage = images.find((image) => image.url === activeImage) || images[0] || null;
|
|
209
217
|
return <article className="atelier-product-detail">
|
|
210
218
|
<div className="atelier-gallery"><div className="atelier-gallery-main"><AtelierImage image={selectedImage} alt={product.title} /></div>{images.length > 1 && <div className="atelier-thumbnails">{images.map((image, index) => <button type="button" className={activeImage === image.url ? "active" : ""} onClick={() => setActiveImage(image.url)} key={`${image.url}-${index}`}><AtelierImage image={image} alt={`${product.title} ${index + 1}`} /></button>)}</div>}</div>
|
|
211
|
-
<div className="atelier-product-info"><span className="atelier-kicker">{product.categories[0]?.name || product.brand || "Produto selecionado"}</span><h1>{product.title}</h1><div className="atelier-product-meta"
|
|
219
|
+
<div className="atelier-product-info"><span className="atelier-kicker">{product.categories[0]?.name || product.brand || "Produto selecionado"}</span><h1>{product.title}</h1><div className="atelier-product-meta">{showPrices && <span>{price(product) || "Preço sob consulta"}</span>}{(variant?.sku || product.sku) && <small>Ref. {variant?.sku || product.sku}</small>}</div><div className="atelier-description">{descriptionContent}</div>
|
|
212
220
|
{product.variantOptions.map((option) => <fieldset key={option.name}><legend>{option.name}: <strong>{selected[option.name]}</strong></legend><div>{option.values.map((optionValue) => <button type="button" className={selected[option.name] === optionValue ? "active" : ""} onClick={() => setSelected((current) => ({ ...current, [option.name]: optionValue }))} key={optionValue}>{optionValue}</button>)}</div></fieldset>)}
|
|
213
|
-
<button className="atelier-button atelier-button-dark atelier-add" type="button" disabled={product.variantOptions.length > 0 && !variant} onClick={() => onAddToCart?.({ productSlug: product.slug, productUrl: productUrl(product), title: product.title, sku: variant?.sku || product.sku, variantId: variant?.id, variantName: variant?.name, image: variant?.image || product.image, unitPrice: product.promotionalPrice ?? product.price })}>Adicionar à seleção <b>+</b></button>
|
|
221
|
+
<button className="atelier-button atelier-button-dark atelier-add" type="button" disabled={product.variantOptions.length > 0 && !variant} onClick={() => onAddToCart?.({ productSlug: product.slug, productUrl: productUrl(product), title: product.title, sku: variant?.sku || product.sku, variantId: variant?.id, variantName: variant?.name, image: variant?.image || product.image, unitPrice: showPrices ? product.promotionalPrice ?? product.price : null })}>Adicionar à seleção <b>+</b></button>
|
|
214
222
|
<div className="atelier-detail-benefits"><span><b>01</b> Atendimento especializado</span><span><b>02</b> Orçamento pelo WhatsApp</span></div>
|
|
215
223
|
</div>
|
|
216
224
|
</article>;
|
|
@@ -126,6 +126,9 @@ body { margin: 0; }
|
|
|
126
126
|
.atelier-product-copy h3 { min-height: 2.4em; margin: 9px 0; font-family: Georgia, serif; font-size: 22px; font-weight: 500; line-height: 1.15; }
|
|
127
127
|
.atelier-product-copy > p { display: -webkit-box; min-height: 3.2em; margin: 0 0 18px; overflow: hidden; color: color-mix(in srgb, var(--atelier-text) 62%, transparent); font-size: 12px; line-height: 1.6; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
|
|
128
128
|
.atelier-product-copy > div { display: flex; min-height: 38px; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid var(--atelier-line); padding-top: 14px; font-size: 11px; font-weight: 800; }
|
|
129
|
+
.atelier-product-price { display: grid; gap: 2px; }
|
|
130
|
+
.atelier-product-price s { color: color-mix(in srgb, var(--atelier-text) 56%, transparent); font-size: 10px; font-weight: 600; text-decoration: line-through; }
|
|
131
|
+
.atelier-product-price b { font-size: 12px; }
|
|
129
132
|
.atelier-product-copy > div a { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 50%; background: var(--atelier-primary); color: var(--atelier-primary-text); }
|
|
130
133
|
.atelier-services { background: var(--atelier-primary); color: var(--atelier-primary-text); padding-block: clamp(72px, 9vw, 130px); }
|
|
131
134
|
.atelier-services .atelier-kicker { color: var(--atelier-accent); }
|
|
@@ -16,6 +16,10 @@ interface CartLine extends ThemeCartItem {
|
|
|
16
16
|
quantity: number;
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
+
function money(value: number): string {
|
|
20
|
+
return new Intl.NumberFormat("pt-BR", { style: "currency", currency: "BRL" }).format(value);
|
|
21
|
+
}
|
|
22
|
+
|
|
19
23
|
function catalogHref(route: Extract<ThemeRoute, { type: "catalog" }>, page: number): string {
|
|
20
24
|
const params = new URLSearchParams();
|
|
21
25
|
if (route.search) params.set("busca", route.search);
|
|
@@ -63,7 +67,10 @@ export default function Theme({ context, route = { type: "home" }, sdk, adapters
|
|
|
63
67
|
} as CSSProperties;
|
|
64
68
|
const [cart, setCart] = useState<CartLine[]>([]);
|
|
65
69
|
const [cartOpen, setCartOpen] = useState(false);
|
|
70
|
+
const showPrices = site.settings?.catalog?.showPrices ?? true;
|
|
66
71
|
const cartCount = cart.reduce((total, item) => total + item.quantity, 0);
|
|
72
|
+
const cartTotal = cart.reduce((total, item) => total + (item.unitPrice ?? 0) * item.quantity, 0);
|
|
73
|
+
const hasCompletePrices = cart.length > 0 && cart.every(({ unitPrice }) => typeof unitPrice === "number");
|
|
67
74
|
const addToCart = (item: ThemeCartItem) => {
|
|
68
75
|
const key = `${item.productSlug}::${item.variantId || "parent"}`;
|
|
69
76
|
setCart((current) => {
|
|
@@ -75,7 +82,14 @@ export default function Theme({ context, route = { type: "home" }, sdk, adapters
|
|
|
75
82
|
sdk?.cart.add(item);
|
|
76
83
|
setCartOpen(true);
|
|
77
84
|
};
|
|
78
|
-
const message = useMemo(() =>
|
|
85
|
+
const message = useMemo(() => {
|
|
86
|
+
const lines = cart.map((item, index) => {
|
|
87
|
+
const price = showPrices && typeof item.unitPrice === "number" ? `\nValor unitário: ${money(item.unitPrice)}` : "";
|
|
88
|
+
return `${index + 1}. ${item.quantity}x ${item.title}${item.variantName ? ` (${item.variantName})` : ""}${item.sku ? ` — ref. ${item.sku}` : ""}${price}`;
|
|
89
|
+
});
|
|
90
|
+
const summary = showPrices && hasCompletePrices ? `\n\nTotal estimado: ${money(cartTotal)}` : "";
|
|
91
|
+
return `Olá! Gostaria de solicitar um orçamento para:\n\n${lines.join("\n\n")}${summary}`;
|
|
92
|
+
}, [cart, cartTotal, hasCompletePrices, showPrices]);
|
|
79
93
|
const whatsapp = site.settings?.contact.whatsapp?.replace(/\D/g, "");
|
|
80
94
|
|
|
81
95
|
let content;
|
|
@@ -89,13 +103,13 @@ export default function Theme({ context, route = { type: "home" }, sdk, adapters
|
|
|
89
103
|
<form action={route.categoryPath.length ? `/${route.categoryPath.join("/")}` : "/produtos"}><label htmlFor="atelier-catalog-search">Refine sua busca</label><div><input id="atelier-catalog-search" name="busca" defaultValue={route.search} placeholder="Nome, marca ou referência" /><button>↗</button></div></form>
|
|
90
104
|
{route.facets.map((facet) => <fieldset key={facet.name}><legend>{facet.name}</legend>{facet.values.map(({ value, count }) => { const token = `${facet.name}::${value}`; return <label key={token}><input type="checkbox" name="variante" value={token} defaultChecked={route.variants.includes(token)} /><span>{value}</span><small>{count}</small></label>; })}</fieldset>)}
|
|
91
105
|
</aside>
|
|
92
|
-
<section><ProductGrid products={route.products} columns={site.settings?.catalog?.desktopColumns || 3} showCategory={site.settings?.catalog?.showCategory} showDescription={site.settings?.catalog?.showDescription} />
|
|
106
|
+
<section><ProductGrid products={route.products} columns={site.settings?.catalog?.desktopColumns || 3} showPrices={showPrices} showCategory={site.settings?.catalog?.showCategory} showDescription={site.settings?.catalog?.showDescription} />
|
|
93
107
|
{route.pagination.totalPages > 1 && <nav className="atelier-pagination" aria-label="Paginação"><a className={!route.pagination.hasPreviousPage ? "disabled" : ""} href={catalogHref(route, route.pagination.page - 1)}>← Anterior</a><span>{route.pagination.page} / {route.pagination.totalPages}</span><a className={!route.pagination.hasNextPage ? "disabled" : ""} href={catalogHref(route, route.pagination.page + 1)}>Próxima →</a></nav>}
|
|
94
108
|
</section>
|
|
95
109
|
</div>
|
|
96
110
|
</main>;
|
|
97
111
|
} else if (route.type === "product") {
|
|
98
|
-
content = <main className="atelier-page atelier-container"><nav className="atelier-breadcrumb"><a href="/">Início</a><span>·</span><a href="/produtos">Produtos</a><span>·</span><strong>{route.product.title}</strong></nav><ProductDetail product={route.product} contact={site.settings?.contact} productUrl={typeof window === "undefined" ? null : window.location.href} descriptionContent={<p>{plainText(route.product.description)}</p>} onAddToCart={addToCart} /></main>;
|
|
112
|
+
content = <main className="atelier-page atelier-container"><nav className="atelier-breadcrumb"><a href="/">Início</a><span>·</span><a href="/produtos">Produtos</a><span>·</span><strong>{route.product.title}</strong></nav><ProductDetail product={route.product} showPrices={showPrices} contact={site.settings?.contact} productUrl={typeof window === "undefined" ? null : window.location.href} descriptionContent={<p>{plainText(route.product.description)}</p>} onAddToCart={addToCart} /></main>;
|
|
99
113
|
} else if (route.type === "editorial-list") {
|
|
100
114
|
content = <EditorialList title={route.title} basePath={route.basePath} items={route.items} />;
|
|
101
115
|
} else if (route.type === "editorial-detail") {
|
|
@@ -111,6 +125,12 @@ export default function Theme({ context, route = { type: "home" }, sdk, adapters
|
|
|
111
125
|
<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} />
|
|
112
126
|
{content}
|
|
113
127
|
<Footer site={site} pages={context.navigation.pages} template={themeDefinition.template} />
|
|
114
|
-
{cartOpen && <div className="atelier-cart-backdrop" onPointerDown={(event) => event.target === event.currentTarget && setCartOpen(false)}
|
|
128
|
+
{cartOpen && <div className="atelier-cart-backdrop" onPointerDown={(event) => event.target === event.currentTarget && setCartOpen(false)}>
|
|
129
|
+
<aside className="atelier-cart-drawer">
|
|
130
|
+
<header><div><small>Sua curadoria</small><h2>{cartCount} {cartCount === 1 ? "item" : "itens"}</h2></div><button onClick={() => setCartOpen(false)} aria-label="Fechar">×</button></header>
|
|
131
|
+
<div className="atelier-cart-lines">{cart.length === 0 ? <p>Sua seleção está vazia. Explore os produtos e adicione o que interessar.</p> : cart.map((item) => <article key={item.key}><AtelierImage image={item.image} alt={item.title} /><div><strong>{item.title}</strong><small>{item.variantName || item.sku}</small>{showPrices && typeof item.unitPrice === "number" && <b>{money(item.unitPrice)}</b>}<span><button onClick={() => setCart((current) => current.flatMap((candidate) => candidate.key !== item.key ? [candidate] : candidate.quantity > 1 ? [{ ...candidate, quantity: candidate.quantity - 1 }] : []))}>−</button>{item.quantity}<button onClick={() => setCart((current) => current.map((candidate) => candidate.key === item.key ? { ...candidate, quantity: candidate.quantity + 1 } : candidate))}>+</button></span></div></article>)}</div>
|
|
132
|
+
{cart.length > 0 && <footer>{showPrices && hasCompletePrices && <strong>Total estimado: {money(cartTotal)}</strong>}<p>Valores e disponibilidade serão confirmados pela equipe.</p>{whatsapp ? <a className="atelier-button atelier-button-light" href={`https://wa.me/${whatsapp}?text=${encodeURIComponent(message)}`} target="_blank" rel="noreferrer">Enviar pelo WhatsApp ↗</a> : <span>Configure o WhatsApp da loja para concluir.</span>}</footer>}
|
|
133
|
+
</aside>
|
|
134
|
+
</div>}
|
|
115
135
|
</div>;
|
|
116
136
|
}
|
|
@@ -65,7 +65,7 @@ Para compilar, gerar o artefato ou publicar, execute na raiz do tooling:
|
|
|
65
65
|
|
|
66
66
|
```bash
|
|
67
67
|
npm run pack:store
|
|
68
|
-
npm publish ./artifacts/nuvler-theme-default-1.
|
|
68
|
+
npm publish ./artifacts/nuvler-theme-default-1.1.4.tgz --access public
|
|
69
69
|
|
|
70
70
|
node packages/cli/dist/nuvler.js theme build --theme themes/nuvler-default
|
|
71
71
|
npm run pack:theme -- nuvler-default
|
|
@@ -73,7 +73,7 @@ node packages/cli/dist/nuvler.js theme publish --theme themes/nuvler-default --o
|
|
|
73
73
|
```
|
|
74
74
|
|
|
75
75
|
O pacote npm contém o renderer local e o CSS. O artefato do Theme Registry é
|
|
76
|
-
gerado separadamente como `artifacts/nuvler-default-1.
|
|
76
|
+
gerado separadamente como `artifacts/nuvler-default-1.1.4.nuvler-theme.tgz`.
|
|
77
77
|
|
|
78
78
|
Exemplo no App Router:
|
|
79
79
|
|
|
@@ -2,13 +2,11 @@
|
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"id": "nuvler-default",
|
|
4
4
|
"name": "Nuvler Default",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.1.4",
|
|
6
6
|
"runtimeVersion": "1",
|
|
7
7
|
"sdkVersion": "^1.3.3",
|
|
8
8
|
"entry": "src/theme.tsx",
|
|
9
|
-
"styles": [
|
|
10
|
-
"src/theme.css"
|
|
11
|
-
],
|
|
9
|
+
"styles": ["src/theme.css"],
|
|
12
10
|
"presentation": {
|
|
13
11
|
"description": "Tema oficial completo, indicado para produção e usado como base confiável.",
|
|
14
12
|
"templateId": "nuvler-default",
|
|
@@ -100,6 +98,26 @@
|
|
|
100
98
|
"control": "text",
|
|
101
99
|
"maxLength": 120
|
|
102
100
|
},
|
|
101
|
+
{
|
|
102
|
+
"key": "layout",
|
|
103
|
+
"label": "Formato",
|
|
104
|
+
"control": "select",
|
|
105
|
+
"defaultValue": "grid",
|
|
106
|
+
"options": [
|
|
107
|
+
{ "label": "Grid", "value": "grid" },
|
|
108
|
+
{ "label": "Carrossel", "value": "carousel" }
|
|
109
|
+
],
|
|
110
|
+
"help": "Escolha como as marcas serão exibidas."
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"key": "gridColumns",
|
|
114
|
+
"label": "Imagens por linha",
|
|
115
|
+
"control": "number",
|
|
116
|
+
"defaultValue": 5,
|
|
117
|
+
"min": 1,
|
|
118
|
+
"max": 6,
|
|
119
|
+
"help": "Usado quando o formato for Grid."
|
|
120
|
+
},
|
|
103
121
|
{
|
|
104
122
|
"key": "items",
|
|
105
123
|
"label": "Marcas",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuvler/theme-default",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"description": "Tema padrão oficial da Nuvler",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": [
|
|
@@ -54,17 +54,18 @@
|
|
|
54
54
|
"scripts": {
|
|
55
55
|
"dev": "nuvler theme dev --theme .",
|
|
56
56
|
"validate": "nuvler theme validate --theme .",
|
|
57
|
-
"build": "nuvler theme build --theme .",
|
|
57
|
+
"build": "nuvler theme build --theme . && node scripts/verify-release.mjs",
|
|
58
58
|
"build:package": "node scripts/clean-dist.mjs && tsc -p tsconfig.json && node scripts/copy-assets.mjs",
|
|
59
|
-
"pack": "nuvler theme pack --theme .",
|
|
60
|
-
"publish:registry": "nuvler theme publish --theme .",
|
|
59
|
+
"pack": "npm run build && nuvler theme pack --theme . --skip-build",
|
|
60
|
+
"publish:registry": "npm run build && nuvler theme publish --theme .",
|
|
61
|
+
"verify:release": "node scripts/verify-release.mjs",
|
|
61
62
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
62
63
|
},
|
|
63
64
|
"peerDependencies": {
|
|
64
65
|
"react": "^19.0.0"
|
|
65
66
|
},
|
|
66
67
|
"dependencies": {
|
|
67
|
-
"@nuvler/theme-sdk": "^1.4.
|
|
68
|
+
"@nuvler/theme-sdk": "^1.4.3"
|
|
68
69
|
},
|
|
69
70
|
"devDependencies": {
|
|
70
71
|
"@types/react": "^19.0.0",
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { fileURLToPath } from "node:url";
|
|
5
|
+
|
|
6
|
+
const themeRoot = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
|
7
|
+
const [packageJson, manifest, javascript, stylesheet] = await Promise.all([
|
|
8
|
+
readFile(path.join(themeRoot, "package.json"), "utf8").then(JSON.parse),
|
|
9
|
+
readFile(path.join(themeRoot, "nuvler.theme.json"), "utf8").then(JSON.parse),
|
|
10
|
+
readFile(path.join(themeRoot, "dist", "theme.js"), "utf8"),
|
|
11
|
+
readFile(path.join(themeRoot, "dist", "theme.css"), "utf8"),
|
|
12
|
+
]);
|
|
13
|
+
|
|
14
|
+
assert.equal(
|
|
15
|
+
manifest.version,
|
|
16
|
+
packageJson.version,
|
|
17
|
+
"A versão do manifesto deve ser igual à versão do pacote do tema.",
|
|
18
|
+
);
|
|
19
|
+
assert.ok(
|
|
20
|
+
manifest.presentation?.homeComponents?.some(({ key }) => key === "brands"),
|
|
21
|
+
"O manifesto da release não declara o componente brands.",
|
|
22
|
+
);
|
|
23
|
+
assert.match(
|
|
24
|
+
javascript,
|
|
25
|
+
/mini-banners/,
|
|
26
|
+
"O artefato JavaScript não contém o renderer de mini banners.",
|
|
27
|
+
);
|
|
28
|
+
assert.match(
|
|
29
|
+
stylesheet,
|
|
30
|
+
/\.mini-banners-grid/,
|
|
31
|
+
"O artefato CSS não contém os estilos de mini banners.",
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
console.log(`✓ Release ${manifest.id}@${manifest.version} contém brands e suporte a mini banners.`);
|
|
@@ -3,7 +3,13 @@
|
|
|
3
3
|
import { useEffect, useRef, useState, type ReactNode } from "react";
|
|
4
4
|
|
|
5
5
|
function ArrowIcon({ direction }: { direction: "previous" | "next" }) {
|
|
6
|
-
return
|
|
6
|
+
return (
|
|
7
|
+
<svg viewBox="0 0 24 24" aria-hidden="true">
|
|
8
|
+
<path
|
|
9
|
+
d={direction === "previous" ? "m14.5 5-7 7 7 7" : "m9.5 5 7 7-7 7"}
|
|
10
|
+
/>
|
|
11
|
+
</svg>
|
|
12
|
+
);
|
|
7
13
|
}
|
|
8
14
|
|
|
9
15
|
export function BannerCarouselFrame({
|
|
@@ -19,44 +25,143 @@ export function BannerCarouselFrame({
|
|
|
19
25
|
const track = useRef<HTMLDivElement>(null);
|
|
20
26
|
|
|
21
27
|
useEffect(() => {
|
|
22
|
-
const slides = track.current?.querySelectorAll<HTMLElement>(
|
|
23
|
-
|
|
28
|
+
const slides = track.current?.querySelectorAll<HTMLElement>(
|
|
29
|
+
"[data-banner-slide]",
|
|
30
|
+
);
|
|
31
|
+
slides?.forEach((slide, index) =>
|
|
32
|
+
slide.setAttribute("aria-hidden", String(active !== index)),
|
|
33
|
+
);
|
|
24
34
|
}, [active]);
|
|
25
35
|
|
|
26
36
|
useEffect(() => {
|
|
27
37
|
if (!autoplay || count < 2) return;
|
|
28
|
-
const timer = window.setInterval(
|
|
38
|
+
const timer = window.setInterval(
|
|
39
|
+
() => setActive((current) => (current + 1) % count),
|
|
40
|
+
6000,
|
|
41
|
+
);
|
|
29
42
|
return () => window.clearInterval(timer);
|
|
30
43
|
}, [autoplay, count]);
|
|
31
44
|
|
|
32
45
|
return (
|
|
33
|
-
<section
|
|
34
|
-
|
|
46
|
+
<section
|
|
47
|
+
className="banner-carousel"
|
|
48
|
+
aria-roledescription="carrossel"
|
|
49
|
+
aria-label="Banners da loja"
|
|
50
|
+
>
|
|
51
|
+
<div
|
|
52
|
+
className="banner-track"
|
|
53
|
+
ref={track}
|
|
54
|
+
style={{ transform: `translateX(-${active * 100}%)` }}
|
|
55
|
+
>
|
|
35
56
|
{children}
|
|
36
57
|
</div>
|
|
37
|
-
{count > 1 &&
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
58
|
+
{count > 1 && (
|
|
59
|
+
<>
|
|
60
|
+
<button
|
|
61
|
+
className="carousel-arrow carousel-arrow-prev"
|
|
62
|
+
type="button"
|
|
63
|
+
aria-label="Banner anterior"
|
|
64
|
+
onClick={() => setActive((active - 1 + count) % count)}
|
|
65
|
+
>
|
|
66
|
+
<ArrowIcon direction="previous" />
|
|
67
|
+
</button>
|
|
68
|
+
<button
|
|
69
|
+
className="carousel-arrow carousel-arrow-next"
|
|
70
|
+
type="button"
|
|
71
|
+
aria-label="Próximo banner"
|
|
72
|
+
onClick={() => setActive((active + 1) % count)}
|
|
73
|
+
>
|
|
74
|
+
<ArrowIcon direction="next" />
|
|
75
|
+
</button>
|
|
76
|
+
<div className="carousel-dots">
|
|
77
|
+
{Array.from({ length: count }, (_, index) => (
|
|
78
|
+
<button
|
|
79
|
+
key={index}
|
|
80
|
+
type="button"
|
|
81
|
+
className={index === active ? "active" : ""}
|
|
82
|
+
aria-label={`Ir para banner ${index + 1}`}
|
|
83
|
+
onClick={() => setActive(index)}
|
|
84
|
+
/>
|
|
85
|
+
))}
|
|
86
|
+
</div>
|
|
87
|
+
</>
|
|
88
|
+
)}
|
|
44
89
|
</section>
|
|
45
90
|
);
|
|
46
91
|
}
|
|
47
92
|
|
|
48
93
|
export function ProductCarouselFrame({ children }: { children: ReactNode }) {
|
|
49
94
|
const track = useRef<HTMLDivElement>(null);
|
|
50
|
-
const move = (direction: -1 | 1) =>
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
95
|
+
const move = (direction: -1 | 1) =>
|
|
96
|
+
track.current?.scrollBy({
|
|
97
|
+
left: direction * Math.min(track.current.clientWidth, 900),
|
|
98
|
+
behavior: "smooth",
|
|
99
|
+
});
|
|
54
100
|
|
|
55
101
|
return (
|
|
56
102
|
<div className="product-carousel">
|
|
57
|
-
<div className="product-carousel-track" ref={track}>
|
|
58
|
-
|
|
59
|
-
|
|
103
|
+
<div className="product-carousel-track" ref={track}>
|
|
104
|
+
{children}
|
|
105
|
+
</div>
|
|
106
|
+
<button
|
|
107
|
+
type="button"
|
|
108
|
+
className="carousel-arrow carousel-arrow-prev"
|
|
109
|
+
onClick={() => move(-1)}
|
|
110
|
+
aria-label="Produtos anteriores"
|
|
111
|
+
>
|
|
112
|
+
<ArrowIcon direction="previous" />
|
|
113
|
+
</button>
|
|
114
|
+
<button
|
|
115
|
+
type="button"
|
|
116
|
+
className="carousel-arrow carousel-arrow-next"
|
|
117
|
+
onClick={() => move(1)}
|
|
118
|
+
aria-label="Próximos produtos"
|
|
119
|
+
>
|
|
120
|
+
<ArrowIcon direction="next" />
|
|
121
|
+
</button>
|
|
122
|
+
</div>
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export function BrandsCarouselFrame({
|
|
127
|
+
children,
|
|
128
|
+
count,
|
|
129
|
+
}: {
|
|
130
|
+
children: ReactNode;
|
|
131
|
+
count: number;
|
|
132
|
+
}) {
|
|
133
|
+
const track = useRef<HTMLDivElement>(null);
|
|
134
|
+
const move = (direction: -1 | 1) =>
|
|
135
|
+
track.current?.scrollBy({
|
|
136
|
+
left: direction * Math.min(track.current.clientWidth, 900),
|
|
137
|
+
behavior: "smooth",
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
return (
|
|
141
|
+
<div className="brands-carousel">
|
|
142
|
+
<div className="brands-carousel-track" ref={track}>
|
|
143
|
+
{children}
|
|
144
|
+
</div>
|
|
145
|
+
{count > 1 && (
|
|
146
|
+
<>
|
|
147
|
+
<button
|
|
148
|
+
type="button"
|
|
149
|
+
className="carousel-arrow carousel-arrow-prev"
|
|
150
|
+
onClick={() => move(-1)}
|
|
151
|
+
aria-label="Marcas anteriores"
|
|
152
|
+
>
|
|
153
|
+
<ArrowIcon direction="previous" />
|
|
154
|
+
</button>
|
|
155
|
+
<button
|
|
156
|
+
type="button"
|
|
157
|
+
className="carousel-arrow carousel-arrow-next"
|
|
158
|
+
onClick={() => move(1)}
|
|
159
|
+
aria-label="Próximas marcas"
|
|
160
|
+
>
|
|
161
|
+
<ArrowIcon direction="next" />
|
|
162
|
+
</button>
|
|
163
|
+
</>
|
|
164
|
+
)}
|
|
60
165
|
</div>
|
|
61
166
|
);
|
|
62
167
|
}
|
|
@@ -167,7 +167,7 @@ export function ConfiguredNavigation({ menu, categories: initialCategories, inli
|
|
|
167
167
|
return inline ? navigation : <div className="primary-nav-shell">{navigation}</div>;
|
|
168
168
|
}
|
|
169
169
|
|
|
170
|
-
export function SmartProductSearch({ endpoint = "/api/product-suggestions", queryParam = "q", searchProducts }: { endpoint?: string; queryParam?: string; searchProducts?: (query: string) => Promise<ThemeProduct[]
|
|
170
|
+
export function SmartProductSearch({ endpoint = "/api/product-suggestions", queryParam = "q", searchProducts, showPrices = true }: { endpoint?: string; queryParam?: string; searchProducts?: (query: string) => Promise<ThemeProduct[]>; showPrices?: boolean }) {
|
|
171
171
|
const [value, setValue] = useState("");
|
|
172
172
|
const [results, setResults] = useState<ThemeProduct[]>([]);
|
|
173
173
|
const [loading, setLoading] = useState(false);
|
|
@@ -267,7 +267,7 @@ export function SmartProductSearch({ endpoint = "/api/product-suggestions", quer
|
|
|
267
267
|
{!loading && results.map((product, index) => <a id={`theme-search-result-${index}`} className={activeIndex === index ? "active" : ""} href={productUrl(product)} role="option" aria-selected={activeIndex === index} key={product.slug} onPointerEnter={() => setActiveIndex(index)}>
|
|
268
268
|
<span className="search-suggestion-image"><ThemeImageView image={product.image} fallbackAlt={product.title} sizes="56px" fallbackWidth={112} fallbackHeight={112} /></span>
|
|
269
269
|
<span className="search-suggestion-copy"><strong>{product.title}</strong><span className="search-suggestion-meta">{product.categories[0]?.name && <small>{product.categories[0].name}</small>}{product.sku && <small>Ref. {product.sku}</small>}</span></span>
|
|
270
|
-
{displayPrice(product) && <b>{displayPrice(product)}</b>}
|
|
270
|
+
{showPrices && displayPrice(product) && <b>{displayPrice(product)}</b>}
|
|
271
271
|
<span className="search-suggestion-arrow" aria-hidden="true">→</span>
|
|
272
272
|
</a>)}
|
|
273
273
|
{!loading && !results.length && <div className="search-suggestions-empty"><strong>Nenhum produto encontrado</strong><p>Tente outro nome, marca ou referência.</p></div>}
|
|
@@ -27,5 +27,5 @@ export function Header({ site, categories, menu = [], headerButton, cart, sugges
|
|
|
27
27
|
return () => window.removeEventListener("scroll", update);
|
|
28
28
|
}, []);
|
|
29
29
|
|
|
30
|
-
return <header className={`store-header${compact ? " is-compact" : ""}`}><div className="store-container header-inner"><MobileStoreMenu site={site} categories={categories} menu={configuredMenu} headerButton={headerButton} /><a className="brand" href="/" aria-label={`${name} — início`}>{site.settings?.logo?.url ? <ThemeImageView image={site.settings.logo} fallbackAlt={name} className="brand-logo" sizes="200px" fallbackWidth={240} fallbackHeight={96} /> : <><span className="brand-mark">7</span><span>{name}</span></>}</a>{configuredMenu.length > 0 && <ConfiguredNavigation inline menu={configuredMenu} categories={categories} />}<div className="header-tools">{site.modules.includes("PRODUCTS") && <SmartProductSearch endpoint={suggestionsEndpoint} queryParam={suggestionsQueryParam} />}{headerButton?.enabled && <a className="header-highlight-link" href={headerButton.href} target={headerButton.openInNewTab ? "_blank" : undefined} rel={headerButton.openInNewTab ? "noopener noreferrer" : undefined} style={{ backgroundColor: headerButton.backgroundColor, color: headerButton.textColor }}>{headerButton.label}</a>}{cart}</div></div></header>;
|
|
30
|
+
return <header className={`store-header${compact ? " is-compact" : ""}`}><div className="store-container header-inner"><MobileStoreMenu site={site} categories={categories} menu={configuredMenu} headerButton={headerButton} /><a className="brand" href="/" aria-label={`${name} — início`}>{site.settings?.logo?.url ? <ThemeImageView image={site.settings.logo} fallbackAlt={name} className="brand-logo" sizes="200px" fallbackWidth={240} fallbackHeight={96} /> : <><span className="brand-mark">7</span><span>{name}</span></>}</a>{configuredMenu.length > 0 && <ConfiguredNavigation inline menu={configuredMenu} categories={categories} />}<div className="header-tools">{site.modules.includes("PRODUCTS") && <SmartProductSearch endpoint={suggestionsEndpoint} queryParam={suggestionsQueryParam} showPrices={site.settings?.catalog?.showPrices ?? true} />}{headerButton?.enabled && <a className="header-highlight-link" href={headerButton.href} target={headerButton.openInNewTab ? "_blank" : undefined} rel={headerButton.openInNewTab ? "noopener noreferrer" : undefined} style={{ backgroundColor: headerButton.backgroundColor, color: headerButton.textColor }}>{headerButton.label}</a>}{cart}</div></div></header>;
|
|
31
31
|
}
|