@nuvler/cli 0.4.2 → 0.4.4
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 +225 -0
- package/dist/commands/theme/create.js +6 -4
- package/dist/commands/theme/create.js.map +1 -1
- package/dist/commands/theme/upgrade.js +128 -0
- package/dist/commands/theme/upgrade.js.map +1 -0
- package/dist/index.js +39 -1
- package/dist/index.js.map +1 -1
- package/dist/migrate/analyzer.js +147 -11
- package/dist/migrate/analyzer.js.map +1 -1
- package/dist/migrate/classifier.js +10 -6
- package/dist/migrate/classifier.js.map +1 -1
- package/dist/migrate/generator.js +8 -6
- package/dist/migrate/generator.js.map +1 -1
- package/dist/migrate/transformer.js +150 -27
- package/dist/migrate/transformer.js.map +1 -1
- package/dist/nuvler.js +462 -58
- package/dist/nuvler.js.map +1 -1
- package/dist/templates/nuvler-atelier/README.md +1 -1
- package/dist/templates/nuvler-atelier/nuvler.theme.json +2 -2
- package/dist/templates/nuvler-atelier/package.json +4 -3
- package/dist/templates/nuvler-atelier/src/definition.tsx +10 -9
- package/dist/templates/nuvler-atelier/src/theme.tsx +2 -2
- package/dist/templates/nuvler-default/README.md +2 -2
- package/dist/templates/nuvler-default/nuvler.theme.json +2 -2
- package/dist/templates/nuvler-default/package.json +3 -3
- package/dist/templates/nuvler-default/src/header-interactions.tsx +113 -11
- package/dist/templates/nuvler-default/src/header.tsx +6 -4
- package/dist/templates/nuvler-default/src/home.tsx +22 -5
- package/dist/templates/nuvler-default/src/product-detail-interactive.tsx +32 -1
- package/dist/templates/nuvler-default/src/products.tsx +4 -2
- package/dist/templates/nuvler-default/src/server-shell.tsx +4 -1
- package/dist/templates/nuvler-default/src/shared.tsx +3 -7
- package/dist/templates/nuvler-default/src/theme-component.tsx +6 -5
- package/dist/templates/nuvler-default/src/theme.css +138 -2
- package/dist/templates/starter/nuvler.theme.json +1 -1
- package/dist/templates/starter/package.json +3 -2
- package/dist/templates/starter/src/definition.tsx +3 -2
- package/package.json +2 -2
- package/preview-host/package.json +1 -1
- package/preview-host/vendor/theme-runtime/default-theme.tsx +13 -12
|
@@ -36,7 +36,7 @@ O token fica na configuração global do usuário. A seleção do tenant fica em
|
|
|
36
36
|
O código-fonte deste projeto deve ser versionado em um repositório Git do tema.
|
|
37
37
|
Somente `manifest.json`, `theme.js`, `theme.css` e `assets/` entram no Registry.
|
|
38
38
|
|
|
39
|
-
O arquivo final será `artifacts/nuvler-atelier-0.1.
|
|
39
|
+
O arquivo final será `artifacts/nuvler-atelier-0.1.2.nuvler-theme.tgz`.
|
|
40
40
|
`npm run publish` envia esse mesmo arquivo ao Theme Registry.
|
|
41
41
|
|
|
42
42
|
Antes de publicar uma alteração, incremente a versão do manifesto. Use
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"id": "nuvler-atelier",
|
|
4
4
|
"name": "Nuvler Atelier",
|
|
5
|
-
"version": "0.1.
|
|
5
|
+
"version": "0.1.2",
|
|
6
6
|
"runtimeVersion": "1",
|
|
7
|
-
"sdkVersion": "^1.2.
|
|
7
|
+
"sdkVersion": "^1.2.2",
|
|
8
8
|
"entry": "src/theme.tsx",
|
|
9
9
|
"styles": ["src/theme.css"],
|
|
10
10
|
"presentation": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuvler-theme-nuvler-atelier",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -9,16 +9,17 @@
|
|
|
9
9
|
"build": "nuvler theme build --theme .",
|
|
10
10
|
"pack": "nuvler theme pack --theme .",
|
|
11
11
|
"publish": "nuvler theme publish --theme .",
|
|
12
|
+
"upgrade": "nuvler theme upgrade --theme .",
|
|
12
13
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
13
14
|
},
|
|
14
15
|
"dependencies": {
|
|
15
|
-
"@nuvler/theme-sdk": "^1.2.
|
|
16
|
+
"@nuvler/theme-sdk": "^1.2.2"
|
|
16
17
|
},
|
|
17
18
|
"peerDependencies": {
|
|
18
19
|
"react": "^19.0.0"
|
|
19
20
|
},
|
|
20
21
|
"devDependencies": {
|
|
21
|
-
"@nuvler/cli": "^0.4.
|
|
22
|
+
"@nuvler/cli": "^0.4.4",
|
|
22
23
|
"@types/react": "^19.0.0",
|
|
23
24
|
"react": "^19.0.0",
|
|
24
25
|
"typescript": "^5.9.0"
|
|
@@ -2,6 +2,7 @@ import { useEffect, useMemo, useState } from "react";
|
|
|
2
2
|
import manifestData from "../nuvler.theme.json" with { type: "json" };
|
|
3
3
|
import {
|
|
4
4
|
defineTheme,
|
|
5
|
+
productUrl,
|
|
5
6
|
type FooterProps,
|
|
6
7
|
type HeaderProps,
|
|
7
8
|
type HomeProps,
|
|
@@ -67,7 +68,7 @@ function SmartSearch({ searchProducts }: Pick<HeaderProps, "searchProducts">) {
|
|
|
67
68
|
</form>
|
|
68
69
|
{normalized.length >= 2 && <div className="atelier-suggestions">
|
|
69
70
|
<small>{loading ? "Pesquisando…" : `${results.length} resultado(s)`}</small>
|
|
70
|
-
{!loading && results.map((product) => <a href={
|
|
71
|
+
{!loading && results.map((product) => <a href={productUrl(product)} key={product.slug}>
|
|
71
72
|
<AtelierImage image={product.image} alt={product.title} />
|
|
72
73
|
<span><strong>{product.title}</strong><em>{product.sku || product.categories[0]?.name || "Ver produto"}</em></span>
|
|
73
74
|
<b>→</b>
|
|
@@ -97,10 +98,10 @@ function Header({ site, categories, pages, cart, searchProducts, template }: Hea
|
|
|
97
98
|
</div>
|
|
98
99
|
<div className="atelier-nav-shell">
|
|
99
100
|
<nav className="atelier-container atelier-nav" aria-label="Categorias">
|
|
100
|
-
<details className="atelier-mobile-menu"><summary>Menu <span>+</span></summary><div>{categories.map((category) => <a href={
|
|
101
|
+
<details className="atelier-mobile-menu"><summary>Menu <span>+</span></summary><div>{categories.map((category) => <a href={`/${category.slug}`} key={category.slug}>{category.name}</a>)}{pages.map((page) => <a href={`/${page.slug}`} key={page.slug}>{page.title}</a>)}</div></details>
|
|
101
102
|
<a className="atelier-all-products" href="/produtos"><span>◫</span> Catálogo completo</a>
|
|
102
|
-
{visibleCategories.map((category, index) => <a href={
|
|
103
|
-
<details className="atelier-more"><summary>Mais</summary><div>{categories.slice(6).map((category) => <a href={
|
|
103
|
+
{visibleCategories.map((category, index) => <a href={`/${category.slug}`} key={category.slug}><small>0{index + 1}</small>{category.name}</a>)}
|
|
104
|
+
<details className="atelier-more"><summary>Mais</summary><div>{categories.slice(6).map((category) => <a href={`/${category.slug}`} key={category.slug}>{category.name}</a>)}{pages.map((page) => <a href={`/${page.slug}`} key={page.slug}>{page.title}</a>)}</div></details>
|
|
104
105
|
</nav>
|
|
105
106
|
</div>
|
|
106
107
|
</header>
|
|
@@ -123,12 +124,12 @@ function Footer({ site, pages }: FooterProps) {
|
|
|
123
124
|
|
|
124
125
|
function ProductGrid({ products, columns = 3, showCategory = true, showDescription = true }: ProductGridProps) {
|
|
125
126
|
return <div className="atelier-products" data-columns={columns}>{products.map((product, index) => <article className="atelier-product-card" key={product.slug}>
|
|
126
|
-
<a className="atelier-product-media" href={
|
|
127
|
+
<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>
|
|
127
128
|
<div className="atelier-product-copy">
|
|
128
129
|
{showCategory && <small>{product.categories[0]?.name || product.brand || "Seleção"}</small>}
|
|
129
|
-
<h3><a href={
|
|
130
|
+
<h3><a href={productUrl(product)}>{product.title}</a></h3>
|
|
130
131
|
{showDescription && product.description && <p>{plainText(product.description)}</p>}
|
|
131
|
-
<div><span>{price(product) || (product.sku ? `Ref. ${product.sku}` : "Consulte condições")}</span><a href={
|
|
132
|
+
<div><span>{price(product) || (product.sku ? `Ref. ${product.sku}` : "Consulte condições")}</span><a href={productUrl(product)} aria-label={`Ver ${product.title}`}>↗</a></div>
|
|
132
133
|
</div>
|
|
133
134
|
</article>)}</div>;
|
|
134
135
|
}
|
|
@@ -147,7 +148,7 @@ function Home({ sections, products, posts, services, cases, site, template }: Ho
|
|
|
147
148
|
<div className="atelier-hero-visual">
|
|
148
149
|
<span className="atelier-orbit" /><span className="atelier-orbit second" />
|
|
149
150
|
<AtelierImage image={highlight?.image} alt={highlight?.title || heroTitle} />
|
|
150
|
-
{highlight && <a href={
|
|
151
|
+
{highlight && <a href={productUrl(highlight)}><small>Destaque da semana</small><strong>{highlight.title}</strong><span>{price(highlight) || "Conheça o produto"} →</span></a>}
|
|
151
152
|
</div>
|
|
152
153
|
</section>
|
|
153
154
|
<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>
|
|
@@ -173,7 +174,7 @@ function ProductDetail({ product, descriptionContent, onAddToCart }: ProductDeta
|
|
|
173
174
|
<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>
|
|
174
175
|
<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"><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>
|
|
175
176
|
{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>)}
|
|
176
|
-
<button className="atelier-button atelier-button-dark atelier-add" type="button" disabled={product.variantOptions.length > 0 && !variant} onClick={() => onAddToCart?.({ productSlug: product.slug, 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>
|
|
177
|
+
<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>
|
|
177
178
|
<div className="atelier-detail-benefits"><span><b>01</b> Atendimento especializado</span><span><b>02</b> Orçamento pelo WhatsApp</span></div>
|
|
178
179
|
</div>
|
|
179
180
|
</article>;
|
|
@@ -22,7 +22,7 @@ function catalogHref(route: Extract<ThemeRoute, { type: "catalog" }>, page: numb
|
|
|
22
22
|
route.variants.forEach((variant) => params.append("variante", variant));
|
|
23
23
|
if (page > 1) params.set("pagina", String(page));
|
|
24
24
|
const pathname = route.categoryPath.length
|
|
25
|
-
?
|
|
25
|
+
? `/${route.categoryPath.map(encodeURIComponent).join("/")}`
|
|
26
26
|
: "/produtos";
|
|
27
27
|
return params.size ? `${pathname}?${params}` : pathname;
|
|
28
28
|
}
|
|
@@ -86,7 +86,7 @@ export default function Theme({ context, route = { type: "home" }, sdk, adapters
|
|
|
86
86
|
<header className="atelier-page-heading"><span className="atelier-kicker">Catálogo editorial</span><h1>{route.search ? `Resultados para “${route.search}”` : "Todos os produtos"}</h1><p>{route.pagination.total} produto(s) encontrados para sua seleção.</p></header>
|
|
87
87
|
<div className="atelier-catalog-layout">
|
|
88
88
|
<aside className="atelier-filters">
|
|
89
|
-
<form action={route.categoryPath.length ?
|
|
89
|
+
<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
90
|
{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
91
|
</aside>
|
|
92
92
|
<section><ProductGrid products={route.products} columns={site.settings?.catalog?.desktopColumns || 3} showCategory={site.settings?.catalog?.showCategory} showDescription={site.settings?.catalog?.showDescription} />
|
|
@@ -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.0.
|
|
68
|
+
npm publish ./artifacts/nuvler-theme-default-1.0.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.0.
|
|
76
|
+
gerado separadamente como `artifacts/nuvler-default-1.0.4.nuvler-theme.tgz`.
|
|
77
77
|
|
|
78
78
|
Exemplo no App Router:
|
|
79
79
|
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"id": "nuvler-default",
|
|
4
4
|
"name": "Nuvler Default",
|
|
5
|
-
"version": "1.0.
|
|
5
|
+
"version": "1.0.4",
|
|
6
6
|
"runtimeVersion": "1",
|
|
7
|
-
"sdkVersion": "^1.2.
|
|
7
|
+
"sdkVersion": "^1.2.2",
|
|
8
8
|
"entry": "src/theme.tsx",
|
|
9
9
|
"styles": ["src/theme.css"],
|
|
10
10
|
"presentation": {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nuvler/theme-default",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Tema padrão oficial da Nuvler",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": ["**/*.css"],
|
|
@@ -52,14 +52,14 @@
|
|
|
52
52
|
"build": "nuvler theme build --theme .",
|
|
53
53
|
"build:package": "node scripts/clean-dist.mjs && tsc -p tsconfig.json && node scripts/copy-assets.mjs",
|
|
54
54
|
"pack": "nuvler theme pack --theme .",
|
|
55
|
-
"publish": "nuvler theme publish --theme .",
|
|
55
|
+
"publish:registry": "nuvler theme publish --theme .",
|
|
56
56
|
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"react": "^19.0.0"
|
|
60
60
|
},
|
|
61
61
|
"dependencies": {
|
|
62
|
-
"@nuvler/theme-sdk": "^1.2.
|
|
62
|
+
"@nuvler/theme-sdk": "^1.2.2"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@types/react": "^19.0.0",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { useEffect, useLayoutEffect, useRef, useState, type KeyboardEvent } from "react";
|
|
4
|
-
import type
|
|
3
|
+
import { useCallback, useEffect, useLayoutEffect, useRef, useState, type KeyboardEvent } from "react";
|
|
4
|
+
import { productUrl, type ThemeCategory, type ThemeNavigationItem, type ThemePageSummary, type ThemeProduct, type ThemeSite } from "@nuvler/theme-sdk";
|
|
5
5
|
import { categoryUrl, displayPrice, ThemeImageView } from "./shared.js";
|
|
6
6
|
|
|
7
7
|
function CategoryTree({ categories, path = [], depth = 0 }: {
|
|
@@ -21,11 +21,71 @@ function CategoryTree({ categories, path = [], depth = 0 }: {
|
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
type CategoryLoadStatus = "idle" | "loading" | "loaded" | "error";
|
|
25
|
+
|
|
26
|
+
interface CategoryMatch {
|
|
27
|
+
category: ThemeCategory;
|
|
28
|
+
path: string[];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function categorySlugFromMenuItem(item: ThemeNavigationItem) {
|
|
32
|
+
if (item.type !== "CATEGORY") return null;
|
|
33
|
+
const keySlug = item.key.startsWith("CATEGORY:") ? item.key.slice("CATEGORY:".length) : "";
|
|
34
|
+
if (keySlug) return keySlug;
|
|
35
|
+
const segments = item.href.split(/[?#]/, 1)[0].split("/").filter(Boolean);
|
|
36
|
+
return segments.length ? decodeURIComponent(segments.at(-1)!) : null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function findCategory(categories: ThemeCategory[], slug: string, path: string[] = []): CategoryMatch | null {
|
|
40
|
+
for (const category of categories) {
|
|
41
|
+
const currentPath = [...path, category.slug];
|
|
42
|
+
if (category.slug === slug) return { category, path: currentPath };
|
|
43
|
+
const child = findCategory(category.children ?? [], slug, currentPath);
|
|
44
|
+
if (child) return child;
|
|
45
|
+
}
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function useLazyCategories(initialCategories: ThemeCategory[]) {
|
|
50
|
+
const [categories, setCategories] = useState(initialCategories);
|
|
51
|
+
const [status, setStatus] = useState<CategoryLoadStatus>("idle");
|
|
52
|
+
const pendingRequest = useRef<Promise<void> | null>(null);
|
|
53
|
+
|
|
54
|
+
const load = useCallback(() => {
|
|
55
|
+
if (status === "loaded") return Promise.resolve();
|
|
56
|
+
if (pendingRequest.current) return pendingRequest.current;
|
|
57
|
+
|
|
58
|
+
setStatus("loading");
|
|
59
|
+
const request = fetch("/api/product-categories", {
|
|
60
|
+
headers: { accept: "application/json" },
|
|
61
|
+
})
|
|
62
|
+
.then(async (response) => {
|
|
63
|
+
if (!response.ok) throw new Error(`Categorias indisponíveis (${response.status})`);
|
|
64
|
+
const payload: unknown = await response.json();
|
|
65
|
+
if (!Array.isArray(payload)) throw new Error("Resposta de categorias inválida");
|
|
66
|
+
setCategories(payload as ThemeCategory[]);
|
|
67
|
+
setStatus("loaded");
|
|
68
|
+
})
|
|
69
|
+
.catch(() => {
|
|
70
|
+
setStatus("error");
|
|
71
|
+
})
|
|
72
|
+
.finally(() => {
|
|
73
|
+
pendingRequest.current = null;
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
pendingRequest.current = request;
|
|
77
|
+
return request;
|
|
78
|
+
}, [status]);
|
|
79
|
+
|
|
80
|
+
return { categories, status, load };
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function CategoryNavigation({ categories: initialCategories }: { categories: ThemeCategory[] }) {
|
|
25
84
|
const innerRef = useRef<HTMLDivElement>(null);
|
|
26
85
|
const allRef = useRef<HTMLDetailsElement>(null);
|
|
27
86
|
const itemRefs = useRef<Array<HTMLDivElement | null>>([]);
|
|
28
87
|
const [visibleCount, setVisibleCount] = useState(0);
|
|
88
|
+
const { categories, status, load } = useLazyCategories(initialCategories);
|
|
29
89
|
|
|
30
90
|
useLayoutEffect(() => {
|
|
31
91
|
const inner = innerRef.current;
|
|
@@ -59,24 +119,57 @@ export function CategoryNavigation({ categories }: { categories: ThemeCategory[]
|
|
|
59
119
|
|
|
60
120
|
return <nav className="category-nav" aria-label="Categorias de produtos">
|
|
61
121
|
<div className="store-container category-nav-inner" ref={innerRef}>
|
|
62
|
-
<details
|
|
122
|
+
<details
|
|
123
|
+
className="category-nav-all"
|
|
124
|
+
ref={allRef}
|
|
125
|
+
onToggle={(event) => {
|
|
126
|
+
if (event.currentTarget.open) void load();
|
|
127
|
+
}}
|
|
128
|
+
>
|
|
63
129
|
<summary className="all-categories"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M4 7h16M4 12h16M4 17h16" /></svg><span>Todas as categorias</span><svg className="category-nav-chevron" viewBox="0 0 20 20" aria-hidden="true"><path d="m6 8 4 4 4-4" /></svg></summary>
|
|
64
130
|
<div className="category-nav-all-panel">
|
|
65
131
|
<div className="category-nav-panel-heading"><div><span>Explore o catálogo</span><strong>Todas as categorias</strong></div><a href="/produtos">Ver todos</a></div>
|
|
132
|
+
{status === "loading" && <p className="category-nav-status" role="status">Carregando categorias…</p>}
|
|
133
|
+
{status === "error" && <p className="category-nav-status">Não foi possível atualizar as categorias.</p>}
|
|
66
134
|
<div className="category-nav-tree"><CategoryTree categories={categories} /></div>
|
|
67
135
|
</div>
|
|
68
136
|
</details>
|
|
69
137
|
{categories.map((category, index) => {
|
|
70
138
|
const overflowed = index >= visibleCount;
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
{category.
|
|
139
|
+
const hasSubmenu = status !== "loaded" || category.children?.length > 0;
|
|
140
|
+
return <div className="category-nav-group" data-overflowed={overflowed || undefined} aria-hidden={overflowed || undefined} key={category.slug} ref={(node) => { itemRefs.current[index] = node; }} onPointerEnter={() => { void load(); }} onFocusCapture={() => { void load(); }}>
|
|
141
|
+
<a href={categoryUrl([category.slug])}>{category.name}{hasSubmenu && <svg className="category-item-chevron" viewBox="0 0 20 20" aria-hidden="true"><path d="m6 8 4 4 4-4" /></svg>}</a>
|
|
142
|
+
{hasSubmenu && <div className="category-nav-submenu">
|
|
143
|
+
{status !== "loaded" && category.children.length === 0 && <p className="category-nav-status" role="status">{status === "error" ? "Não foi possível carregar as subcategorias." : "Carregando subcategorias…"}</p>}
|
|
144
|
+
{category.children?.length > 0 && <CategoryTree categories={category.children} path={[category.slug]} />}
|
|
145
|
+
</div>}
|
|
74
146
|
</div>;
|
|
75
147
|
})}
|
|
76
148
|
</div>
|
|
77
149
|
</nav>;
|
|
78
150
|
}
|
|
79
151
|
|
|
152
|
+
export function ConfiguredNavigation({ menu, categories: initialCategories }: { menu: ThemeNavigationItem[]; categories: ThemeCategory[] }) {
|
|
153
|
+
const { categories, status, load } = useLazyCategories(initialCategories);
|
|
154
|
+
return <div className="primary-nav-shell"><nav className="store-container main-nav" aria-label="Navegação principal">
|
|
155
|
+
<a href="/">Início</a>
|
|
156
|
+
{menu.map((item) => {
|
|
157
|
+
const categorySlug = categorySlugFromMenuItem(item);
|
|
158
|
+
if (!categorySlug) return <a href={item.href} key={item.key}>{item.label}</a>;
|
|
159
|
+
const match = findCategory(categories, categorySlug);
|
|
160
|
+
const hasSubcategories = status !== "loaded" || Boolean(match?.category.children.length);
|
|
161
|
+
return <div className="main-nav-group" key={item.key} onPointerEnter={() => { void load(); }} onFocusCapture={() => { void load(); }}>
|
|
162
|
+
<a href={item.href}>{item.label}{hasSubcategories && <svg className="category-item-chevron" viewBox="0 0 20 20" aria-hidden="true"><path d="m6 8 4 4 4-4" /></svg>}</a>
|
|
163
|
+
{hasSubcategories && <div className="category-nav-submenu configured-category-submenu">
|
|
164
|
+
<div className="configured-category-heading"><div><span>Explore a categoria</span><strong>{match?.category.name ?? item.label}</strong></div><a href={item.href}>Ver todos</a></div>
|
|
165
|
+
{status !== "loaded" && !match?.category.children.length && <p className="category-nav-status" role="status">{status === "error" ? "Não foi possível carregar as subcategorias." : "Carregando subcategorias…"}</p>}
|
|
166
|
+
{match?.category.children.length ? <div className="configured-category-grid"><CategoryTree categories={match.category.children} path={match.path} /></div> : null}
|
|
167
|
+
</div>}
|
|
168
|
+
</div>;
|
|
169
|
+
})}
|
|
170
|
+
</nav></div>;
|
|
171
|
+
}
|
|
172
|
+
|
|
80
173
|
export function SmartProductSearch({ endpoint = "/api/product-suggestions", queryParam = "q", searchProducts }: { endpoint?: string; queryParam?: string; searchProducts?: (query: string) => Promise<ThemeProduct[]> }) {
|
|
81
174
|
const [value, setValue] = useState("");
|
|
82
175
|
const [results, setResults] = useState<ThemeProduct[]>([]);
|
|
@@ -142,7 +235,7 @@ export function SmartProductSearch({ endpoint = "/api/product-suggestions", quer
|
|
|
142
235
|
}
|
|
143
236
|
if (event.key === "Enter" && activeIndex >= 0) {
|
|
144
237
|
event.preventDefault();
|
|
145
|
-
window.location.assign(
|
|
238
|
+
window.location.assign(productUrl(results[activeIndex]));
|
|
146
239
|
}
|
|
147
240
|
}
|
|
148
241
|
|
|
@@ -158,7 +251,7 @@ export function SmartProductSearch({ endpoint = "/api/product-suggestions", quer
|
|
|
158
251
|
{open && query.length >= 2 && <div className="search-suggestions" id="theme-search-suggestions" role="listbox" aria-label="Sugestões de produtos">
|
|
159
252
|
<div className="search-suggestions-heading"><strong>Sugestões para “{query}”</strong>{!loading && <span>{resultLabel}</span>}</div>
|
|
160
253
|
{loading && <div className="search-suggestions-loading"><span aria-hidden="true" /><p>Procurando os produtos mais próximos…</p></div>}
|
|
161
|
-
{!loading && results.map((product, index) => <a id={`theme-search-result-${index}`} className={activeIndex === index ? "active" : ""} href={
|
|
254
|
+
{!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)}>
|
|
162
255
|
<span className="search-suggestion-image"><ThemeImageView image={product.image} fallbackAlt={product.title} sizes="56px" fallbackWidth={112} fallbackHeight={112} /></span>
|
|
163
256
|
<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>
|
|
164
257
|
{displayPrice(product) && <b>{displayPrice(product)}</b>}
|
|
@@ -177,8 +270,9 @@ function MobileCategories({ categories, path = [] }: { categories: ThemeCategory
|
|
|
177
270
|
});
|
|
178
271
|
}
|
|
179
272
|
|
|
180
|
-
export function MobileStoreMenu({ site, categories, pages }: { site: ThemeSite; categories: ThemeCategory[]; pages: ThemePageSummary[] }) {
|
|
273
|
+
export function MobileStoreMenu({ site, categories: initialCategories, pages, menu = [] }: { site: ThemeSite; categories: ThemeCategory[]; pages: ThemePageSummary[]; menu?: ThemeNavigationItem[] }) {
|
|
181
274
|
const [open, setOpen] = useState(false);
|
|
275
|
+
const { categories, status, load } = useLazyCategories(initialCategories);
|
|
182
276
|
useEffect(() => {
|
|
183
277
|
if (!open) return;
|
|
184
278
|
const previous = document.body.style.overflow;
|
|
@@ -186,5 +280,13 @@ export function MobileStoreMenu({ site, categories, pages }: { site: ThemeSite;
|
|
|
186
280
|
return () => { document.body.style.overflow = previous; };
|
|
187
281
|
}, [open]);
|
|
188
282
|
const settings = site.settings;
|
|
189
|
-
|
|
283
|
+
const configuredMenu = [...menu].sort((left, right) => left.order - right.order);
|
|
284
|
+
const configuredHasCategories = configuredMenu.some((item) => item.type === "CATEGORY");
|
|
285
|
+
return <><button type="button" className="mobile-menu-trigger" onClick={() => { setOpen(true); if (!configuredMenu.length || configuredHasCategories) void load(); }} aria-label="Abrir menu"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M4 7h16M4 12h16M4 17h16" /></svg></button>{open && <div className="mobile-menu-backdrop" role="presentation" onPointerDown={(event) => event.target === event.currentTarget && setOpen(false)}><aside className="mobile-menu-drawer" aria-label="Menu da loja"><div className="mobile-menu-heading"><div><small>Navegue pela loja</small><strong>{settings?.siteName || site.tenant.name}</strong></div><button type="button" onClick={() => setOpen(false)} aria-label="Fechar menu">×</button></div><nav className="mobile-menu-links"><a href="/">Início</a>{configuredMenu.length ? configuredMenu.map((item) => {
|
|
286
|
+
const categorySlug = categorySlugFromMenuItem(item);
|
|
287
|
+
if (!categorySlug) return <a href={item.href} key={item.key}>{item.label}</a>;
|
|
288
|
+
const match = findCategory(categories, categorySlug);
|
|
289
|
+
const hasSubcategories = status !== "loaded" || Boolean(match?.category.children.length);
|
|
290
|
+
return hasSubcategories ? <details key={item.key} className="mobile-menu-category"><summary><span>{item.label}</span><span aria-hidden="true">+</span></summary><div><a href={item.href}>Ver tudo em {item.label}</a>{status !== "loaded" && !match?.category.children.length && <p className="mobile-menu-category-status" role="status">{status === "error" ? "Não foi possível carregar as subcategorias." : "Carregando subcategorias…"}</p>}{match?.category.children.length ? <MobileCategories categories={match.category.children} path={match.path} /> : null}</div></details> : <a href={item.href} key={item.key}>{item.label}</a>;
|
|
291
|
+
}) : <>{site.modules.includes("PRODUCTS") && <a href="/produtos">Todos os produtos</a>}{site.modules.includes("BLOG") && <a href="/blog">Blog</a>}{site.modules.includes("SERVICES") && <a href="/servicos">Serviços</a>}{site.modules.includes("CASES") && <a href="/cases">Cases</a>}{pages.slice(0, 8).map((page) => <a href={`/${page.slug}`} key={page.slug}>{page.title}</a>)}</>}</nav>{!configuredMenu.length && categories.length > 0 && <section className="mobile-menu-categories"><h2>Categorias</h2>{status === "loading" && <p className="mobile-menu-category-status" role="status">Carregando categorias…</p>}{status === "error" && <p className="mobile-menu-category-status">Não foi possível atualizar as categorias.</p>}<MobileCategories categories={categories} /></section>}</aside></div>}</>;
|
|
190
292
|
}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import type { HeaderProps } from "@nuvler/theme-sdk";
|
|
2
|
-
import { CategoryNavigation, MobileStoreMenu, SmartProductSearch } from "./header-interactions.js";
|
|
2
|
+
import { CategoryNavigation, ConfiguredNavigation, MobileStoreMenu, SmartProductSearch } from "./header-interactions.js";
|
|
3
3
|
import { ThemeImageView, type ThemeImageComponent } from "./shared.js";
|
|
4
4
|
|
|
5
5
|
function SupplementaryLinks({ site, pages }: Pick<HeaderProps, "site" | "pages">) {
|
|
6
6
|
return <>{site.modules.includes("BLOG") && <a href="/blog">Blog</a>}{site.modules.includes("SERVICES") && <a href="/servicos">Serviços</a>}{site.modules.includes("CASES") && <a href="/cases">Cases</a>}{pages.slice(0, 6).map((page) => <a key={page.slug} href={`/${page.slug}`}>{page.title}</a>)}</>;
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export function Header({ site, categories, pages, template, cart, suggestionsEndpoint, suggestionsQueryParam, searchProducts, ImageComponent = ThemeImageView }: HeaderProps & { ImageComponent?: ThemeImageComponent }) {
|
|
9
|
+
export function Header({ site, categories, pages, menu = [], template, cart, suggestionsEndpoint, suggestionsQueryParam, searchProducts, ImageComponent = ThemeImageView }: HeaderProps & { ImageComponent?: ThemeImageComponent }) {
|
|
10
10
|
const name = site.settings?.siteName || site.tenant.name;
|
|
11
11
|
const hasCategories = categories.length > 0;
|
|
12
|
-
const
|
|
13
|
-
|
|
12
|
+
const configuredMenu = [...menu].sort((left, right) => left.order - right.order);
|
|
13
|
+
const hasConfiguredMenu = configuredMenu.length > 0;
|
|
14
|
+
const hasExtra = !hasConfiguredMenu && (site.modules.some((module) => ["BLOG", "SERVICES", "CASES"].includes(module)) || pages.length > 0);
|
|
15
|
+
return <><div className="announcement"><div className="store-container announcement-inner"><span>{template.announcement}</span>{site.settings?.contact.phone && <span>{site.settings.contact.phone}</span>}</div></div><header className="store-header"><div className={`store-container header-inner${hasCategories && hasExtra ? "" : " header-inner-simple"}`}><MobileStoreMenu site={site} categories={categories} pages={pages} menu={configuredMenu} /><a className="brand" href="/" aria-label={`${name} — início`}>{site.settings?.logo?.url ? <ImageComponent 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>{site.modules.includes("PRODUCTS") && <SmartProductSearch endpoint={suggestionsEndpoint} queryParam={suggestionsQueryParam} searchProducts={searchProducts} />}<div className="header-message"><span className="header-message-icon" aria-hidden="true"><svg viewBox="0 0 24 24"><path d="m12 3 2.1 4.9L19 10l-4.9 2.1L12 17l-2.1-4.9L5 10l4.9-2.1L12 3Z" /></svg></span><span className="header-message-copy"><small>Nossa loja</small><strong>{site.settings?.description?.trim() || template.announcement}</strong></span></div>{hasCategories && hasExtra && <div className="header-actions"><details className="header-more-menu"><summary>Mais <span aria-hidden="true">⌄</span></summary><div className="header-more-panel"><SupplementaryLinks site={site} pages={pages} /></div></details></div>}{cart}</div>{hasConfiguredMenu ? <ConfiguredNavigation menu={configuredMenu} categories={categories} /> : hasCategories ? <CategoryNavigation categories={categories} /> : <div className="primary-nav-shell"><nav className="store-container main-nav" aria-label="Navegação principal"><a href="/">Início</a>{site.modules.includes("PRODUCTS") && <a href="/produtos">Produtos</a>}<SupplementaryLinks site={site} pages={pages} /></nav></div>}</header></>;
|
|
14
16
|
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { HomeProps, ThemeEditorialItem, ThemeHomeSection, ThemeImage, ThemeSite } from "@nuvler/theme-sdk";
|
|
2
2
|
import { BannerCarousel, type ThemeBanner } from "./banner-carousel.js";
|
|
3
3
|
import { ProductCarousel } from "./product-carousel.js";
|
|
4
|
-
import {
|
|
4
|
+
import { ProductGrid } from "./products.js";
|
|
5
|
+
import { categoryUrl, ThemeImageView, type ThemeImageComponent } from "./shared.js";
|
|
5
6
|
|
|
6
7
|
function text(data: Record<string, unknown>, key: string, fallback = "") {
|
|
7
8
|
const value = data[key];
|
|
@@ -13,6 +14,12 @@ function limit(data: Record<string, unknown>) {
|
|
|
13
14
|
return Number.isInteger(value) ? Math.min(12, Math.max(1, value)) : 6;
|
|
14
15
|
}
|
|
15
16
|
|
|
17
|
+
function productCategory(data: Record<string, unknown>) {
|
|
18
|
+
const value = text(data, "categorySlug").toLocaleLowerCase("pt-BR");
|
|
19
|
+
if (["", "all", "todos", "todas", "all-categories", "todas-as-categorias"].includes(value)) return "";
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
22
|
+
|
|
16
23
|
function imageValue(value: unknown): ThemeImage | null {
|
|
17
24
|
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
18
25
|
const image = value as Record<string, unknown>;
|
|
@@ -77,15 +84,25 @@ function TextSection({ section, ImageComponent = ThemeImageView }: { section: Th
|
|
|
77
84
|
export function Home({ sections, products, posts, services, cases, site, template, ImageComponent = ThemeImageView }: HomeProps & { ImageComponent?: ThemeImageComponent }) {
|
|
78
85
|
const visible = [...sections].filter((section) => section.enabled).sort((a, b) => a.order - b.order);
|
|
79
86
|
const rendered = visible.length ? visible : template.fallbackSections(site.modules);
|
|
80
|
-
const catalog = site.settings?.catalog ?? { showCategory: true, showDescription: true };
|
|
87
|
+
const catalog = site.settings?.catalog ?? { showCategory: true, showDescription: true, desktopColumns: 4 as const };
|
|
81
88
|
return <>{rendered.map((section, index) => {
|
|
82
89
|
if (section.type === "hero") return <Hero key={section.id || index} section={section} site={site} action={template.primaryAction(site.modules)} priority={index === 0} ImageComponent={ImageComponent} />;
|
|
83
90
|
if (section.type === "banner-carousel") return <BannerCarousel key={section.id || index} banners={banners(section.data)} autoplay={section.data.autoplay !== false} priority={index === 0} ImageComponent={ImageComponent} />;
|
|
84
91
|
if (["image-text", "rich-text", "cta"].includes(section.type)) return <TextSection key={section.id || index} section={section} ImageComponent={ImageComponent} />;
|
|
85
92
|
if (section.type === "products-grid" || section.type === "products-carousel") {
|
|
86
|
-
const category =
|
|
87
|
-
const items = products.filter((product) => !category || product.categories.some(({ slug }) => slug === category)).slice(0, limit(section.data));
|
|
88
|
-
|
|
93
|
+
const category = productCategory(section.data);
|
|
94
|
+
const items = products.filter((product) => !category || product.categories.some(({ slug }) => slug === category) || product.categoryPath?.includes(category)).slice(0, limit(section.data));
|
|
95
|
+
const matchingPath = category
|
|
96
|
+
? items.find((product) => product.categoryPath?.includes(category))?.categoryPath
|
|
97
|
+
: undefined;
|
|
98
|
+
const categoryIndex = matchingPath?.indexOf(category) ?? -1;
|
|
99
|
+
const allProductsHref = categoryIndex >= 0 && matchingPath
|
|
100
|
+
? categoryUrl(matchingPath.slice(0, categoryIndex + 1))
|
|
101
|
+
: category ? `/produtos?categoria=${encodeURIComponent(category)}` : "/produtos";
|
|
102
|
+
const productsView = section.type === "products-grid"
|
|
103
|
+
? <ProductGrid products={items} columns={catalog.desktopColumns} showCategory={catalog.showCategory} showDescription={catalog.showDescription} ImageComponent={ImageComponent} />
|
|
104
|
+
: <ProductCarousel products={items} showCategory={catalog.showCategory} showDescription={catalog.showDescription} ImageComponent={ImageComponent} />;
|
|
105
|
+
return <section className="store-section" key={section.id || index}><div className="store-container"><Heading data={section.data} title={section.type === "products-grid" ? "Produtos em destaque" : "Vitrine de produtos"} href={allProductsHref} />{productsView}</div></section>;
|
|
89
106
|
}
|
|
90
107
|
const map = section.type === "services-grid" ? { items: services, path: "/servicos", title: "Nossos serviços" } : section.type === "cases-grid" ? { items: cases, path: "/cases", title: "Cases e resultados" } : { items: posts, path: "/blog", title: "Conteúdos recentes" };
|
|
91
108
|
return <section className="store-section" key={section.id || index}><div className="store-container"><Heading data={section.data} title={map.title} href={map.path} /><EditorialGrid items={map.items.slice(0, limit(section.data))} basePath={map.path} ImageComponent={ImageComponent} /></div></section>;
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
type PointerEvent,
|
|
11
11
|
type ReactNode,
|
|
12
12
|
} from "react";
|
|
13
|
-
import type
|
|
13
|
+
import { productUrl as relativeProductUrl, type ProductDetailProps, type ThemeCartItem, type ThemeImage } from "@nuvler/theme-sdk";
|
|
14
14
|
|
|
15
15
|
type AddToCart = NonNullable<ProductDetailProps["onAddToCart"]>;
|
|
16
16
|
|
|
@@ -27,6 +27,36 @@ export function ThemeInteractionProvider({
|
|
|
27
27
|
return <ThemeInteractionContext.Provider value={value}>{children}</ThemeInteractionContext.Provider>;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
export function ProductCardAction({
|
|
31
|
+
href,
|
|
32
|
+
item,
|
|
33
|
+
hasVariants,
|
|
34
|
+
}: {
|
|
35
|
+
href: string;
|
|
36
|
+
item: ThemeCartItem;
|
|
37
|
+
hasVariants: boolean;
|
|
38
|
+
}) {
|
|
39
|
+
const { onAddToCart } = useContext(ThemeInteractionContext);
|
|
40
|
+
|
|
41
|
+
if (hasVariants) {
|
|
42
|
+
return <a className="button button-secondary button-block product-card-action" href={href}>Escolher opções</a>;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (!onAddToCart) {
|
|
46
|
+
return <a className="button button-secondary button-block product-card-action" href={href}>Ver detalhes</a>;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<button
|
|
51
|
+
type="button"
|
|
52
|
+
className="button button-primary button-block product-card-action"
|
|
53
|
+
onClick={() => onAddToCart(item)}
|
|
54
|
+
>
|
|
55
|
+
Adicionar ao carrinho
|
|
56
|
+
</button>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
30
60
|
interface ProductDetailInteractiveProps extends Omit<ProductDetailProps, "descriptionContent"> {
|
|
31
61
|
information: ReactNode;
|
|
32
62
|
benefits: ReactNode;
|
|
@@ -211,6 +241,7 @@ export function ProductDetailInteractive({
|
|
|
211
241
|
className="button button-primary button-block"
|
|
212
242
|
onClick={() => addToCart({
|
|
213
243
|
productSlug: product.slug,
|
|
244
|
+
productUrl: relativeProductUrl(product),
|
|
214
245
|
title: product.title,
|
|
215
246
|
sku: variant?.sku || product.sku,
|
|
216
247
|
variantId: variant?.id,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { productUrl, type ProductGridProps, type ThemeProduct } from "@nuvler/theme-sdk";
|
|
2
|
+
import { ProductCardAction } from "./product-detail-interactive.js";
|
|
2
3
|
import { plainText, ThemeImageView, type ThemeImageComponent } from "./shared.js";
|
|
3
4
|
|
|
4
5
|
export function ProductCard({ product, showCategory = true, showDescription = true, ImageComponent = ThemeImageView }: {
|
|
@@ -7,7 +8,8 @@ export function ProductCard({ product, showCategory = true, showDescription = tr
|
|
|
7
8
|
showDescription?: boolean;
|
|
8
9
|
ImageComponent?: ThemeImageComponent;
|
|
9
10
|
}) {
|
|
10
|
-
|
|
11
|
+
const href = productUrl(product);
|
|
12
|
+
return <article className="product-card"><a className="product-card-image" href={href} aria-label={`Ver ${product.title}`}><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 className="product-card-details-link" href={href}>{product.title}</a></h3>{showDescription && product.description && <p className="product-card-description">{plainText(product.description)}</p>}<ProductCardAction href={href} hasVariants={product.variantOptions.length > 0} item={{ productSlug: product.slug, productUrl: href, title: product.title, sku: product.sku, image: product.image, unitPrice: product.promotionalPrice ?? product.price }} /></div></article>;
|
|
11
13
|
}
|
|
12
14
|
|
|
13
15
|
export function ProductGrid({ products, columns = 4, showCategory = true, showDescription = true, ImageComponent = ThemeImageView }: ProductGridProps & { ImageComponent?: ThemeImageComponent }) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CSSProperties, ReactNode } from "react";
|
|
2
|
-
import type { ThemeCategory, ThemePageSummary, ThemeSite } from "@nuvler/theme-sdk";
|
|
2
|
+
import type { ThemeCategory, ThemeNavigationItem, ThemePageSummary, ThemeSite } from "@nuvler/theme-sdk";
|
|
3
3
|
|
|
4
4
|
import { Footer } from "./footer.js";
|
|
5
5
|
import { Header } from "./header.js";
|
|
@@ -14,6 +14,7 @@ export interface NuvlerDefaultShellProps {
|
|
|
14
14
|
site: ThemeSite;
|
|
15
15
|
categories: ThemeCategory[];
|
|
16
16
|
pages: ThemePageSummary[];
|
|
17
|
+
menu?: ThemeNavigationItem[];
|
|
17
18
|
children: ReactNode;
|
|
18
19
|
cart?: ReactNode;
|
|
19
20
|
platformBrand?: ReactNode;
|
|
@@ -26,6 +27,7 @@ export function NuvlerDefaultShell({
|
|
|
26
27
|
site,
|
|
27
28
|
categories,
|
|
28
29
|
pages,
|
|
30
|
+
menu,
|
|
29
31
|
children,
|
|
30
32
|
cart,
|
|
31
33
|
platformBrand,
|
|
@@ -70,6 +72,7 @@ export function NuvlerDefaultShell({
|
|
|
70
72
|
site={site}
|
|
71
73
|
categories={categories}
|
|
72
74
|
pages={pages}
|
|
75
|
+
menu={menu}
|
|
73
76
|
template={nuvlerDefaultTemplate}
|
|
74
77
|
cart={cart}
|
|
75
78
|
suggestionsEndpoint={suggestionsEndpoint}
|